fix: tree-shake Node.js code from browser bundles#415
Closed
joshuaellis wants to merge 0 commit intomodule-federation:mainfrom
Closed
fix: tree-shake Node.js code from browser bundles#415joshuaellis wants to merge 0 commit intomodule-federation:mainfrom
joshuaellis wants to merge 0 commit intomodule-federation:mainfrom
Conversation
0d17824 to
b264616
Compare
398724b to
40195aa
Compare
40195aa to
4007291
Compare
4007291 to
4a49db9
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ENV_TARGETexists in the@module-federation/sdkpackage to infer tree shaking e.g. if you set it towebthen the node branches will be eliminated in theory (there's a PR to change this from func to constant to improve the tree-shaking see Notes section). We now have atargetoption that will deliver this to the rest of the setup correctly, it falls back towebif not set unlessbuild.ssris set in which we set it tonodethese defaults align with vite's default behaviours.Converts the virtual modules to be ESM in
buildmode to enable rollup to tree-shake more effectively, however Dev mode still uses CJS becausesyntheticNamedExportsare not respected since vite doesn't use rollup for dev &import { useState } from 'react'would thereby fail. This also seems to be some work required to support vite7 identified in #369 which is nice.Related Issues
Notes
This PR requires:
Related PRS: