ESM Build Issues
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[?] Feature request
[ ] Documentation issue or request
[ ] Support request
Current behavior
Using anything other than commonjs
(ES6
etc) does not generate the proper js code.
Using nest build
: causes ReferenceError: openapi is not defined
when trying to run the code.
Using tsc
: can run code but does not auto generate any of the dto schema properties (just shows an empty object).
Expected behavior
nest build
would create error free code, and auto generate proper swagger/openapi docs for the api using ESM compilation.
Minimal reproduction of the problem with instructions
Repro repo: https://github.com/mr-short/nestjs-esm-test
Error 1
- Set
"module": "ES6"
in thetsconfig.json
- Run
nest build
- Start the project
- Throws errors on start
Error 2
- Set
"module": "ES6"
in thetsconfig.json
- Run
tsc
- Start the project
- Visit swagger docs, view entity schema
What is the motivation / use case for changing the behavior?
My organization’s projects use ESM and we are migrating existing large Expressjs projects over to Nestjs.
Environment
@nestjs/core@8.0.2
@nestjs/swagger@5.0.1
For Tooling issues:
- Node version: 14.17.1
- Platform: Linux/Ubuntu
Issue Analytics
- State:
- Created 2 years ago
- Reactions:22
- Comments:12 (2 by maintainers)
Top Results From Across the Web
2 ESM interoperability issue with Node + Typescript + Webpack
At the end I've been able to figure out what was creating issues on the interoperability of the 2 ESM esm1 and esm2....
Read more >tsc-esm-fix - npm
Solutions · Post-process tsc-compiled outputs each time after build. · Patch project sources once as Sindre recommends in ESM migration guide · Use ......
Read more >ES Modules · Nuxt Concepts
You can rename your ESM files to end with .mjs . This is the recommended and simplest approach. You may have to sort...
Read more >The awkward valley to ESM: Node.js, Victory, and D3
In this post, we look at the challenges and lessons in handling ESM-only ... choose option #1 to make Victory only work in...
Read more >What does it take to support Node.js ESM? – The Guild
Building for a library to be compatible with ESM might not be as straight-forward as we would like, and it's for the simple...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
I understand you’re desperate for us to start supporting ESM. Please calm down on how you request we support this. I’ve seen your messages across three different issues so far, and none of them come off as professional or kind. We are working on this, but it appears not as fast as you’d like. If you really really need this now, feel free to make a Pull Request to help us out.
Has there been any updates regarding ESM imports? I’m having a similar issue that was referenced at the top of this thread and am trying to solve it.