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

TODO: mjs and cjs file extension support #14

Closed
2 tasks done
3cp opened this issue Oct 24, 2019 · 2 comments
Closed
2 tasks done

TODO: mjs and cjs file extension support #14

3cp opened this issue Oct 24, 2019 · 2 comments

Comments

@3cp
Copy link
Member

3cp commented Oct 24, 2019

Nodejs v12 has brought support of esm format.

There are two added file extensions: mjs and cjs.

  1. mjs is treated as esm module.
  2. cjs is treated as commonjs module.
  3. js is treated as either esm or commonjs module based on nearest package.json "type" field.

While dumber doesn't care which module format the file is (dumber uses AST to find out), we still need to add the file extensions.

  • add file extensions to dumber-module-loader's known extensions, add extensions to nodejsIds helper.
  • cannot assume nodejs file always ends in .js, also need to update nodejs module resolution algorithm to cover new file extensions.

https://nodejs.org/dist/latest-v12.x/docs/api/esm.html

Need to support the new "exports" field in package.json defined in the above doc.

@3cp
Copy link
Member Author

3cp commented Oct 24, 2019

This is very odd...

Mandatory file extensions
A file extension must be provided when using the import keyword. Directory indexes (e.g. './startup/index.js') must also be fully specified.

3cp added a commit to dumberjs/dumber-module-loader that referenced this issue Dec 6, 2019
@3cp
Copy link
Member Author

3cp commented Mar 15, 2020

Basic support is done.
But nodejs v12 esm comes with exports #17.

@3cp 3cp closed this as completed Mar 15, 2020
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

No branches or pull requests

1 participant