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

type: "module" support #63

Open
Windvis opened this issue Mar 25, 2024 · 3 comments
Open

type: "module" support #63

Windvis opened this issue Mar 25, 2024 · 3 comments

Comments

@Windvis
Copy link

Windvis commented Mar 25, 2024

Split off from #38 to have the discussion without specific implementation details.

The js template currently transpiles the code to CJS, so we can't easily import ESM modules (in a sync way) in our services. This can become an issue since there are npm packages out there that only publish ESM code now. Since we already write ESM-like code, (or TS) it might be worthwhile to change the setup to output ESM instead.

Some caveats mentioned in #38:

  • node requires that local imports in ESM modules have extensions. This is breaking change since services would have to adjust the import paths. A workaround could be to use the mentioned babel plugin, but I'm not sure if we should.
@Windvis
Copy link
Author

Windvis commented Mar 25, 2024

Someone posted this in the Ember Discord: https://joyeecheung.github.io/blog/2024/03/18/require-esm-in-node-js/

So it seems that the main reason why we wanted this change (cjs can't sync import esm) will not be an issue anymore in the future. I do still think it's a better setup though, especially since we already write ESM-ish code anyways.

@madnificent
Copy link
Member

How does the extension work with respect to transpiling coffeescript and typescript code? Does the extension "stick" to the original extension or does everything need a .js postfix?

@Windvis
Copy link
Author

Windvis commented Mar 25, 2024

It needs to be .js in the transpiled file, yes. I'm not 100% sure what that means in practice for the template here.

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

2 participants