Skip to content

Support .mjs output [also a TypeScript issue] #436

@SMotaal

Description

@SMotaal

I guess we are kind of being forced a little here but someone has to be the bigger guy here :)

Can you please make it possible to plug into node's new mjs ESMLoader workflow?

There is a TypeScript issue open already.

Some notes:

  • must run node --experimental-modules something.mjs (yes mjs)

    No longer the case, but .mjs is always reserved for ESM.

  • that --experimental-modules will go away obviously.

    It did but more --experimental-related flags still linger.

  • that kicks in a new layer of loaders in node's internals that completely do not honour conventional require hooks I know you must have hit that already.

    Support for ESM uses a new subsystem that handles all import operations.

  • we can't really force it on non-mjs, unless we get the nodejs team is willing to open things a little.

    No longer the case, now package.json supports { "type": "module" }... etc.

  • TypeScript already supports "commonjs" as a module, maybe "mjs" too. But it seems they might be recommending npm install renamer -g then renamer -regex --find '\.js^' --replace '.mjs' './outDir/**/*.js' as a solid contribution to making things just work.

    Can't speak to this because I no longer transpile from TS as much.

  • not sure how well source maps work yet, but that will be a next step on everyone's agenda.

    Not sure how well sourcemaps are handled by native ESM implementations.

  • Some nonstandard ways exist to import/export in .js files (@std/esm and babel) but they are shredded into commonjs on demand.

    Native support for ESM is not as open yet.

  • You can transpile inline and produce standard-compliant javascript that does not get shredded into commonjs, as long as you can name it mjs.

    See above!

  • You are exceptionally positioned to make a difference here.

    And people want to help if they can (ie know where they would)

Further references:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementresearchNeeds design work, investigation, or prototyping. Implementation uncertain.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions