Fix the package entry point failing to load under Node ESM (ERR_MODULE_NOT_FOUND) - #153
Open
eastagiletracker wants to merge 1 commit into
Open
Conversation
src/plugins/shareIntoApp.ts imported '../utils/listener' without a file extension, so dist/plugins/shareIntoApp.js carries the same specifier and Node's ESM resolver, which does no extension guessing, fails the whole entry graph with ERR_MODULE_NOT_FOUND. Every other module already uses an explicit .js specifier. Restore it here, and on the type-only import in msdynamics.ts that is erased at build time today. Add a test that imports the built dist/index.js through the real ESM loader, which is the check that was missing when this regressed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes fixing the package entry point, which fails to load for npm consumers under Node's ESM resolver with
ERR_MODULE_NOT_FOUND. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/339. You can sign in with your GitHub ID to claim ownership of the project.What happens today
src/plugins/shareIntoApp.tsimports'../utils/listener'with no file extension.tscemits that specifier verbatim, sodist/plugins/shareIntoApp.jsships it, and Node's ESM resolver does no extension guessing — resolution of the entire entry graph fails, not just that one module. Every other module insrc/already uses an explicit.jsspecifier, which is the invariant "Fix ESM import issue" (#125) established when it closed theERR_UNSUPPORTED_DIR_IMPORTreport in #123; "Move plugin listeners to the plugin files" (#131) landed one specifier without it afterwards.It reproduces against the published package, so no checkout is needed — in an empty directory whose
package.jsonhas"type": "module":The same failure comes from a fresh build of
mainatb4bcd62(npm ci && npm run build, then importing./dist/index.js). Bundlers that guess extensions (a plain Vite or webpack browser build) resolve it and are unaffected; anything going through Node's own resolver — SSR builds, test runners, plain node scripts — cannot load the library at all.The change
src/plugins/shareIntoApp.ts:'../utils/listener'→'../utils/listener.js'. This is the failing specifier.src/plugins/msdynamics.ts:'../commands/general'→'../commands/general.js'. This one is type-only, sotscerases it and it does not fail today; corrected so it cannot turn into a runtime import later.test/bundle.test.js: a check that imports the builtdist/index.jsthrough Node's real ESM loader, sonpm testcovers the entry point that regressed. The runner nowawaitscheck(), which leaves the existing sixteen checks untouched.Verification
On
mainatb4bcd62,npm run lint,npm run buildandnpm testare all green (16 passed, 0 failed) — that is the baseline this is measured against. With the new check added but the source fix reverted, it is the only failure, and it fails with exactly the error above:With the fix applied: lint clean, build clean,
📊 Results: 17 passed, 0 failed— no new failures against the baseline. As an end-to-end check,npm packon this branch and installing that tarball into the same"type": "module"directory imports cleanly, where the published 2.20.0 tarball raisesERR_MODULE_NOT_FOUND.How this was managed
We imported this repository's issues and pull requests onto a live board and tracked the work there: this change is the story Package entry point fails to load under Node ESM resolution, on the board at https://eastagiletracker.com/projects/339.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com