Repository navigation
[CDX-398] Backwards Compatibility Fix for CJS users #480
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,22 @@ | |
| "version": "2.90.0", | ||
| "description": "Constructor.io JavaScript client", | ||
| "main": "lib/constructorio.js", | ||
| "module": "lib/esm/constructorio.js", | ||
| "types": "lib/types/index.d.ts", | ||
| "exports": { | ||
|
Mudaafi marked this conversation as resolved.
|
||
| ".": { | ||
| "types": "./lib/types/index.d.ts", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, adding something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered that actually. I discarded it though, but I'll need to dig up the reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The PR description mentions (limitation #2) that TypeScript consumers using ".": {
"import": {
"types": "./lib/types/index.d.mts",
"default": "./lib/esm/constructorio.mjs"
},
"require": {
"types": "./lib/types/index.d.ts",
"default": "./lib/constructorio.js"
}
}This is a known best-practice for dual CJS/ESM packages with TypeScript support. If splitting |
||
| "node": "./lib/constructorio.js", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important Issue: The |
||
| "import": "./lib/esm/constructorio.mjs", | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
Alexey-Pavlov marked this conversation as resolved.
|
||
| "require": "./lib/constructorio.js", | ||
| "default": "./lib/constructorio.js" | ||
| }, | ||
| "./lib/*": "./lib/*.js", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important Issue: The wildcard subpath export |
||
| "./lib/*.js": "./lib/*.js", | ||
| "./lib/*.mjs": "./lib/*.mjs", | ||
| "./lib/*.d.ts": "./lib/*.d.ts", | ||
| "./lib/*.map": "./lib/*.map", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "scripts": { | ||
| "clean": "sudo rm -rf node_modules package-lock.json", | ||
| "version": "node ./src/generateVersion.js && npm run docs && git add ./docs/* && npm run bundle && git add -A ./dist && git add ./src/version.js", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,5 +8,7 @@ require('esbuild').build({ | |
| define: { | ||
| global: 'window', | ||
| }, | ||
| outfile: './lib/esm/constructorio.js', | ||
| // .mjs so Node classifies this as ESM without `"type": "module"`, which would | ||
| // reclassify every .js in the package and break CJS consumers. | ||
| outfile: './lib/esm/constructorio.mjs', | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The |
||
| }).catch(() => process.exit(1)); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modern bundlers ignore the module when exports match, so keeping it changes nothing for them. It only helps old tooling, which just reads the fields and now falls back to CJS
Can we just put it back as
"module": "lib/esm/constructorio.mjs"?Then limitation #3 is gone then