Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM Loader API has changed in Node 18 #4

Closed
brev opened this issue Aug 23, 2022 · 2 comments
Closed

ESM Loader API has changed in Node 18 #4

brev opened this issue Aug 23, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@brev
Copy link
Contributor

brev commented Aug 23, 2022

Node.js 18 has changed the ESM Loader API, as I'm getting a new error with node@18.6.0:

Error [ERR_LOADER_CHAIN_INCOMPLETE]: 
        "node-esm-loader 'resolve'" did not call the next hook in its chain and 
        did not explicitly signal a short circuit. 
        If this is intentional, include `shortCircuit: true` in the hook's return.
    at new NodeError (node:internal/errors:387:5)
    at ESMLoader.resolve (node:internal/modules/esm/loader:860:13)
    at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:439:7)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async loadESM (node:internal/process/esm_loader:83:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  code: 'ERR_LOADER_CHAIN_INCOMPLETE'
}

All my code is still working fine under Node 17.

More information on ESM loader API changes in Node 18.6:


Experimental ESM Loader Hooks API

Node.js ESM Loader hooks now support multiple custom loaders, and composition is
achieved via "chaining": foo-loader calls bar-loader calls qux-loader
(a custom loader must now signal a short circuit when intentionally not
calling the next). See the ESM docs for details.

Real-world use-cases are laid out for end-users with working examples in the
article Custom ESM loaders: Who, what, when, where, why, how.

Contributed by Jacob Smith, Geoffrey Booth, and Bradley Farias - nodejs/node#42623

@sebamarynissen sebamarynissen added the bug Something isn't working label Aug 26, 2022
@sebamarynissen sebamarynissen self-assigned this Aug 26, 2022
@sebamarynissen
Copy link
Owner

Thanks for notifying! Fixed in #5 and published to npm as v0.1.2. I published a new version of node-esm-loader too which uses this new version under the hood.

@brev
Copy link
Contributor Author

brev commented Aug 31, 2022

awesome, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants