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

fix(remix-dev): do more tree-shaking in dev mode #3588

Merged
merged 3 commits into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/remix-dev/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,14 @@ function createServerBuild(
platform: config.serverPlatform,
format: config.serverModuleFormat,
treeShaking: true,
// The type of dead code elimination we want to do depends on the
// minify syntax property: https://github.com/evanw/esbuild/issues/672#issuecomment-1029682369
// Dev builds are leaving code that should be optimized away in the
// bundle causing server / testing code to be shipped to the browser.
// These are properly optimized away in prod builds today, and this
// PR makes dev mode behave closer to production in terms of dead
// code elimination / tree shaking is concerned.
minifySyntax: true,
brophdawg11 marked this conversation as resolved.
Show resolved Hide resolved
minify: options.mode === BuildMode.Production && isCloudflareRuntime,
mainFields: isCloudflareRuntime
? ["browser", "module", "main"]
Expand Down