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

Bug report: broken with ESM #239

Closed
damianobarbati opened this issue Jan 10, 2021 · 1 comment · Fixed by #246
Closed

Bug report: broken with ESM #239

damianobarbati opened this issue Jan 10, 2021 · 1 comment · Fixed by #246

Comments

@damianobarbati
Copy link

damianobarbati commented Jan 10, 2021

The generation of openapi.json is broken on node v14 and type=module:

$ yarn swagger-jsdoc -d openapi.js -o docs/openapi.json src/**/*.js
Error while loading definition file 'openapi.js':
Must use import to load ES Module: .../openapi.js
require() of ES modules is not supported.
require() of .../openapi.js from .../node_modules/swagger-jsdoc/src/utils.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename openapi.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from ...package.json.

Renaming to openapi.cjs as a workaround is broken nonetheless because swagger-jsdoc is expecting only js/json/yml extensions.

@kalinchernev
Copy link
Contributor

Hi @damianobarbati I spent an hour looking at sindresorhus/meta#15 and your bug report in order to try solving it. I haven't had the time to solve the issue fully, I tried something really quick and you can have a look and suggest further changes.

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

Successfully merging a pull request may close this issue.

2 participants