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.

I’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 the tsconfig.json
  • Run nest build
  • Start the project
  • Throws errors on start

Error 2

  • Set "module": "ES6" in the tsconfig.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:open
  • Created 2 years ago
  • Reactions:22
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
jmcdo29commented, Dec 11, 2021

no updates

the field is being forced to comply with ESM now

higher level STANDARD (like angular) frameworks have imposed their choice to go with ESM

AND LOWER LEVEL FRAMEWORKS ARE ALL BEING TAKEN OUT RENDERING THEM UNUSABLE

nestJS being one of them

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.

3reactions
sebasptschcommented, May 23, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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 Hashnode Post

No results found