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

feat: add back cjs output #1964

Merged
merged 8 commits into from
May 23, 2024
Merged

feat: add back cjs output #1964

merged 8 commits into from
May 23, 2024

Conversation

domoritz
Copy link
Member

@domoritz domoritz commented May 23, 2024

Replaces #1956

Version

Published prerelease version: v2.2.0-next.2

Changelog

🎉 This release contains work from new contributors! 🎉

Thanks for all your work!

❤️ Sampsa Kaskela (@SampsaKaskela)

❤️ Rama Krishna Ghanta (@ramaghanta)

❤️ Tim (@timothympace)

🚀 Enhancement

🐛 Bug Fix

🔩 Dependency Updates

Authors: 6

@domoritz domoritz enabled auto-merge (squash) May 23, 2024 13:43
@domoritz domoritz merged commit 4ac21b2 into next May 23, 2024
3 checks passed
@domoritz domoritz deleted the cjs-output branch May 23, 2024 13:51
Copy link

🚀 PR was released in v2.2.0 🚀

@github-actions github-actions bot added released This issue/pull request has been released. and removed prerelease labels May 23, 2024
@arthurfiorette
Copy link
Collaborator

Smart way to import package.json!

@domoritz
Copy link
Member Author

Thanks! This works for node projects but not for browser projects. I wish there was a way to make this work more generally but this feels right for this project.

@sacummings91
Copy link

sacummings91 commented May 24, 2024

Hey guys so unfortunately I think this still doesn't work. Or it's also entirely possible I'm doing something wrong but, whenever I try to import something from ts-json-schema-generator I get this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/stevencummings/workspace/ternary/core-web-server/node_modules/ts-json-schema-generator/cjs/index.js from /Users/stevencummings/workspace/ternary/core-web-server/scripts/docs-gen/Oas3Generator.ts not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/stevencummings/workspace/ternary/core-web-server/node_modules/ts-json-schema-generator/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

Sorry if this isn't the best place to discuss, lmk if I should open a new issue or what the best thing is to do.

@domoritz
Copy link
Member Author

Hmm, we might need to rename the js files to cjs to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants