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

esbuild: prioritize "module" over "browser" #37052

Merged
merged 2 commits into from Nov 24, 2021

Conversation

samouri
Copy link
Member

@samouri samouri commented Nov 24, 2021

summary
Partial for #36453

By default esbuild will utilize browser, module, main in that order (docs). This PR swaps the priorities of module/browser for better tree shaking of our dependencies. In particular, this allows for the elision of the cache-url package.

size diff

- ✔ dist/v0/amp-story-0.1.mjs               73.40 kb   –          353.52 kb  
- ✔ dist/v0/amp-story-1.0.mjs               73.40 kb   –          353.52 kb 
+ ✔ dist/v0/amp-story-0.1.mjs               71.09 kb   –          347.51 kb  
+ ✔ dist/v0/amp-story-1.0.mjs               71.09 kb   –          347.51 kb  

@samouri samouri self-assigned this Nov 24, 2021
@samouri samouri changed the title Update esbuild mainFields for better tree shaking esbuild: prioritize "module" over "browser" Nov 24, 2021
@@ -456,6 +456,7 @@ async function esbuildCompile(srcDir, srcFilename, destDir, options) {
incremental: !!options.watch,
logLevel: 'silent',
external: options.externalDependencies,
mainFields: ['module', 'browser', 'main'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the test running with this, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of them:

this.esbuild = {
target: 'es5',
define: {
'process.env.NODE_DEBUG': 'false',
'process.env.NODE_ENV': '"test"',
},
plugins: [importPathPlugin, babelPlugin],
sourcemap: 'inline',
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, forgot about this. Sure

@samouri samouri marked this pull request as ready for review November 24, 2021 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants