Skip to content

How ImportObject works with ESM? #5

@xtuc

Description

@xtuc

I don't think this is an issue with the current spec but rather a convention in the tooling (but still wanted to discuss about it).

For context, here's the definition of a module import:
screenshot from 2018-03-30 14-06-46

We can easily map that into ESM:

  • module is a ES module
  • name the identifier used in the ExportDeclaration of the module.

If the notion of module has the same semantics as ES Module it should be possible to include modules directly from npm as well as local files (or custom rules defined by bundlers).

Here's my issue

When using emscripten (for example) the imports of the wasm modules are using the env or global module, which can't be found using the current bundlers (since they will resolve it to an npm module, note that it's even dangerous).

While there's not reason to prevent using npm modules we should refer to local files first. I can see a few solutions for that problem:

  • Bundlers could search for local files before searching on npm.
  • Emscripten could use ./env and ./global instead (impacts manual usage).
  • Extra linking phase that changes the name of the modules.

"Bundlers" means currently Webpack and Rollup in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions