Skip to content

Commit

Permalink
Fix facebook#6132 react build size regression from facebook#6088
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed May 17, 2024
1 parent a48687c commit 492816e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ function resolveExternalEsm(id) {
* party dependencies or peerDependencies that we do not want to include
* in the bundles.
*/
const externals = [
...Object.entries(wwwMappings).flat(),
'react-dom',
'react',
'yjs',
'y-websocket',
].sort();
const monorepoExternalsSet = new Set(Object.entries(wwwMappings).flat());
const thirdPartyExternals = ['react', 'react-dom', 'yjs', 'y-websocket'];
const thirdPartyExternalsRegExp = new RegExp(
`^(${thirdPartyExternals.join('|')})(\\/|$)`,
);

const strictWWWMappings = {};

Expand Down Expand Up @@ -131,7 +129,10 @@ async function build(name, inputFile, outputPath, outputFile, isProd, format) {
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
const inputOptions = {
external(modulePath, src) {
return externals.includes(modulePath);
return (
monorepoExternalsSet.has(modulePath) ||
thirdPartyExternalsRegExp.test(modulePath)
);
},
input: inputFile,
onwarn(warning) {
Expand Down

0 comments on commit 492816e

Please sign in to comment.