-
Notifications
You must be signed in to change notification settings - Fork 606
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
ESBuild doesn't tree shake *Client imports #3542
Comments
This is probably an issue with esbuild or some configuration, as it's present in $ ./node_modules/.bin/esbuild bare-bones-client.mjs --bundle --outfile=out.js --platform=node
out.js 542.4kb
$ ./node_modules/.bin/esbuild aggregated-client.mjs --bundle --outfile=out.js --platform=node
out.js 542.4kb |
Probably related evanw/esbuild#1420 |
I don't see you supplied a |
From esbuild docs on tree shaking, it's enabled when bundling
I force-enabled tree-shaking by setting $ ./node_modules/.bin/esbuild bare-bones-client.mjs --bundle --outfile=out.js --platform=node --tree-shaking=true
out.js 750.0kb
$ ./node_modules/.bin/esbuild aggregated-client.mjs --bundle --outfile=out.js --platform=node --tree-shaking=true
out.mjs 749.9kb |
Experimented with cjs code, but there's no difference: // bare-bones-client.js
const { ACMClient, ListCertificatesCommand } = require("@aws-sdk/client-acm");
export const listCertificates = () => {
const client = new ACMClient({ region: "us-west-2" });
return client.send(new ListCertificatesCommand({}));
}; // aggregated-client.js
const { ACM } = require("@aws-sdk/client-acm");
export const listCertificates = () => {
const client = new ACM({ region: "us-west-2" });
return client.listCertificates({});
}; $ ./node_modules/.bin/esbuild bare-bones-client.js --bundle --outfile=out.js --platform=node
out.js 749.7kb
$ ./node_modules/.bin/esbuild aggregated-client.js --bundle --outfile=out.js --platform=node
out.js 749.6kb |
This happens as esbuild can't tree shake commonjs modules
The application can explicitly pass $ ./node_modules/.bin/esbuild aggregated-client.mjs --bundle --outfile=out.js --platform=node --main-fields=module,main
out.js 591.5kb
$ ./node_modules/.bin/esbuild bare-bones-client.mjs --bundle --outfile=out.js --platform=node --main-fields=module,main
out.js 486.9kb |
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. |
Describe the bug
ESBuild doesn't tree shake *Client imports
Your environment
SDK version number
@aws-sdk/[email protected]
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Steps to reproduce
Observed behavior
Expected behavior
I was expecting the bundle created from
bare-bones-client.mjs
to be much smaller.The text was updated successfully, but these errors were encountered: