Fix stepper plugin directory resolving to a nonexistent .js entry#59
Conversation
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.
|
There was a problem hiding this comment.
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.
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.
Summary
directory.jsonresolves the stepper web plugin to./web/stepper/index.js, which 404s. The actual build (src/web/stepper/wrap.mjs) emitsindex.mjs.generateManifest()inlib/build.tshardcoded the.jsextension for every external plugin's directory entry, regardless of what that plugin's build actually produces.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 fromindex.mjstoindex.js. That was harmless at the time (no external plugin existed yet).96c1eafthen added the stepper's web plugin, whose build deliberately emitsindex.mjs(real ESM, needed for the frontend's nativeawait 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— confirmeddist/directory.jsonnow emits"web": "./web/stepper/index.mjs", matching the real file indist/web/stepper/yarn test-coverage— 96 tests pass (9 files)yarn lint— clean (one pre-existing unrelated warning)source-academy.github.io/plugins/directory.jsonpicks up the corrected path and the Stepper tab loads in production🤖 Generated with Claude Code
https://claude.ai/code/session_01PtafwFAYacm4Xyjgnq5yE2