-
Notifications
You must be signed in to change notification settings - Fork 588
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
Publish CJS and ES transpiled files in different versions #2889
Comments
Removing For $ npm install @aws-sdk/[email protected]
...
$ du -sh --apparent-size node_modules/@aws-sdk/client-s3
5.2M node_modules/@aws-sdk/client-s3
$ rm -rf node_modules/@aws-sdk/client-s3/dist-es node_modules/@aws-sdk/client-s3/dist-types
1.4M node_modules/@aws-sdk/client-s3 |
FYI: node-fetch uses a different approach
// mod.cjs
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); https://github.com/node-fetch/node-fetch#loading-and-configuring-the-module Kind regards, |
Revisiting this idea: looking at semver 2.0 specifications, it would be more helpful to use build metadata instead of prerelease tags. For example:
|
Revisiting this idea: npm does not support publishing versions with build metadata as described in npm/npm#12825 We will need to use prerelease tags, as shown in example below:
The prefix |
@trivikr bikeshedding, but I'd prefer |
We'd thought of using I'll provide an update here, once the design is internally reviewed. |
Huh, I dunno how well that would integrate with the various package managers out there, but I'm happy to wait and see. The package size thing isn't really an issue for me, because I bundle everything, and they deal quite well, especially with |
Revisiting. We only need Node.js specific variant to reduce install size. |
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Is your feature request related to a problem? Please describe.
Each modular package on npm ships with both CJS and ES transpiles files.
Since
dist-cjs
is used in Node.js anddist-es
is consumed by browser, they can be shipped into two different packages/versions.Describe the solution you'd like
Ship browser and Node.js versions in different package names (say with suffix
-node
and-browser
)This suggestion was followed in preview versions of AWS SDK for JavaScript (v3).
For example: @aws-sdk/client-s3-node
It was discontinued primarily because it's not scalable.
-rn
).node-esm
)Ship different dist in prerelease tags
This suggestion includes using prerelease tags for shipping specific versions where reducing npm install size is important. For example:
dist-*
in versionX.Y.Z
dist-node-cjs
in versionX.Y.Z-node-cjs
dist-node-esm
in versionX.Y.Z-node-esm
dist-node-types
in versionX.Y.Z-node-types
The separate tags are not required for browser and react-native environments, as they are expected to use bundlers and are not dependent on npm install size.
In environments where npm install size is not a concern, developers can use
X.Y.Z
version as follows:In environments where npm install size is a concern (while using ESM on Node.js), developers can use
X.Y.Z-node-esm
version as follows:For developers requiring types for while using prerelease versions, then can just add
X.Y.Z-node-esm
in devDependencies as follows:The different versions will be managed in the repo by creating custom
package.json
files for each prerelease tag, similar to how it's done in tsconfig. The release script will use custompackage.json
when publishing packages on npm.package.json
: will include all configurations.package.node.cjs.json
: will include configurations and dependencies only for CommonJS.package.node.esm.json
: will include configurations and dependencies only for ESM.package.types.json
: will include configurations and dependencies only for types.Describe alternatives you've considered
Scrapping of
dist-*
folders which are not being used in postinstall script.Additional context
Request proposed earlier in:
The text was updated successfully, but these errors were encountered: