question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `.mjs` output [also a TypeScript issue]

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:26 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
cspotcodecommented, May 5, 2020

I recently implemented and released experimental ESM support. Feedback is being tracked in #1007. Please take it for a spin and let us know if it works.

3reactions
SMotaalcommented, Dec 13, 2019

@blakeembrey… thank you for leaving this open all this time.

<div align=center>

🎉

This meant a lot to me personally — thanks!

</div>

Q Is there a roadmap for this, ie a place for others in the extended community to know where they may contribute towards this goal?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support .mjs output #18442 - microsoft/TypeScript - GitHub
This issue is about compiling ts files to mjs instead of js (adding an options to change the compiler output).
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
For the last few years, Node.js has been working to support running ECMAScript modules (ESM). This has been a very difficult feature to...
Read more >
Typescript packages that ship with .mjs and .d.ts, but without .d ...
I just installed the js-base64 package, and tried it in an ESM module that I am working on, and the issue was easy...
Read more >
Axel Rauschmayer (INACTIVE) on Twitter: "1/ .mjs support in ...
2/ My most wished-for TS feature. Work-around I'll experiment with: 1. "module":"ESNext" produces the code I need (but .js instead of .mjs).
Read more >
What's the best bundler to deal with TypeScripts broken .mjs ...
So TypeScript cannot output .mjs files and this creates a massive headache for many years. What's the best bundler which can deal with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found