Skip to content

Fix stepper plugin directory resolving to a nonexistent .js entry#59

Merged
Shrey5132 merged 2 commits into
source-academy:mainfrom
Shrey5132:fix-stepper-plugin-directory-extension
Jul 21, 2026
Merged

Fix stepper plugin directory resolving to a nonexistent .js entry#59
Shrey5132 merged 2 commits into
source-academy:mainfrom
Shrey5132:fix-stepper-plugin-directory-extension

Conversation

@Shrey5132

Copy link
Copy Markdown
Contributor

Summary

  • Production's Python (and Source) stepper side panel is stuck on "Loading the stepper…" — the deployed directory.json resolves the stepper web plugin to ./web/stepper/index.js, which 404s. The actual build (src/web/stepper/wrap.mjs) emits index.mjs.
  • generateManifest() in lib/build.ts hardcoded the .js extension for every external plugin's directory entry, regardless of what that plugin's build actually produces.
  • Verified live: https://source-academy.github.io/plugins/web/stepper/index.js → 404, .../index.mjs → 200.

Root cause

8ca80c5 ("Add Tab Functionality to the Plugins (#25)") changed the hardcoded literal from index.mjs to index.js. That was harmless at the time (no external plugin existed yet). 96c1eaf then added the stepper's web plugin, whose build deliberately emits index.mjs (real ESM, needed for the frontend's native await import(url)) — so its directory entry has been wrong since it was introduced, and 404s for anyone resolving it.

Fix

Derive the entry filename from the plugin's own package.json (main/module) instead of assuming an extension, since each plugin already declares its real entry point there (stepper: "main": "dist/index.mjs").

Test plan

  • yarn build — confirmed dist/directory.json now emits "web": "./web/stepper/index.mjs", matching the real file in dist/web/stepper/
  • yarn test-coverage — 96 tests pass (9 files)
  • yarn lint — clean (one pre-existing unrelated warning)
  • Confirm on deploy that source-academy.github.io/plugins/directory.json picks up the corrected path and the Stepper tab loads in production

🤖 Generated with Claude Code

https://claude.ai/code/session_01PtafwFAYacm4Xyjgnq5yE2

generateManifest() hardcoded "index.js" as every external plugin's web
resolution path in the published directory.json. The stepper plugin's
build (wrap.mjs) emits "index.mjs", so the live directory.json has
pointed at a 404 since the stepper package was added - silently
breaking dynamic loading of the stepper web plugin (frontend's
resolveWebPluginUrl gets a URL back, import() 404s, the error is
caught and only console.warn'd, so the host plugin never registers its
tab and the Stepper side panel is stuck on "Loading the stepper...").

Derive the entry filename from the plugin's own package.json
(main/module) instead of assuming an extension.
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4fda85a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "@sourceacademy/web-stepper" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the plugin build process in lib/build.ts to dynamically resolve the entry file using the plugin's declared main or module fields from its package.json instead of hardcoding index.js. The review feedback recommends defensively validating that these fields are strings before passing them to pathlib.basename to prevent potential runtime type errors and build crashes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lib/build.ts Outdated
@Shrey5132
Shrey5132 marked this pull request as ready for review July 21, 2026 07:14
package.json is untyped JSON, so a malformed or unusually-shaped
main/module field could otherwise throw a TypeError and crash the
build. Addresses Gemini Code Assist review feedback on source-academy#59.
@Shrey5132
Shrey5132 merged commit 044513e into source-academy:main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant