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

Supporting ES5 module output (.mjs) #8

Open
phoenix-ru opened this issue Oct 18, 2021 · 2 comments
Open

Supporting ES5 module output (.mjs) #8

phoenix-ru opened this issue Oct 18, 2021 · 2 comments

Comments

@phoenix-ru
Copy link

Is there a way to generate code which is compatible with ES5?
Currently the code generated by the plugin uses require to link http(s), vm, etc. even when module output is explicitly enabled (output.module, experiments.outputModule, output.libraryTarget, output.chunkFormat, etc.). I believe that it is not a correct behaviour, as require is not available in the module context.
On top of that, the plugin also uses exports, __dirname and similar globals, which is also problematic.

The reason that modules support is needed is that new Nuxt 3 uses modules output format and our company is interested in integrating Nuxt and Module Federation.
I am willing to work on adding this feature to the plugin if my help is needed.

@telenko
Copy link
Owner

telenko commented Oct 19, 2021

Hi @phoenix-ru , thanks for raising an issue. I agree that plugin injected code should depend on the module format. Will take a look.

@phoenix-ru
Copy link
Author

Thank you for your answer, and by the way, I managed to solve it using unjs/mlly which shims the commonjs specifics in es modules.
But it would be very nice to see it work out of the box without the need to inject this hack to the generated code 😃

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