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

[WIP] ES modules #137

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

[WIP] ES modules #137

wants to merge 9 commits into from

Conversation

goto-bus-stop
Copy link
Member

Adds node-style experimental ES modules support. pass esm: true to interpret .mjs files as ES modules.

ES modules get a rec.esm property so that later parts in the browserify pipeline can identify them. rec.esm is an object containing properties:

  • rec.esm.imports - array of imported bindings
  • rec.esm.exports - array of exported bindings

Imported bindings are objects of the form:

  • binding.from - source module (value "a" in import "a")
  • binding.import - imported binding
  • binding.as - local name for the binding (often the same as binding.import)
  • binding.esm - true if the source module is also an ES module, false if it is a commonjs module.

Exported bindings are objects of the form:

  • binding.export - local name of the binding (can be undefined if export default-ing an unnamed expression)
  • binding.as - public name of the binding

Transforms can check opts._flags.esm to see if the module being transformed is an ES module (true) or a CommonJS module (false). It might be useful if transforms could also set opts._flags.esm to mark their output as an ES module, for languages that compile to ES modules.

@arlac77
Copy link
Contributor

arlac77 commented Apr 15, 2020

@goto-bus-stop any plans to continue on this PR ?

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.

None yet

2 participants