-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust lib chunk naming algorithm and prevent duplicate react-dom (#8450
) * Adjust lib chunk naming algorithm and prevent duplicate react-dom * Remove alias for react-dom and update separator replacement logic * Add comment to webpack-config
- Loading branch information
Showing
1 changed file
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,9 @@ export default async function getBaseWebpackConfig( | |
default: false, | ||
vendors: false, | ||
framework: { | ||
// Framework chunk applies to modules in dynamic chunks, unlike shared chunks | ||
// TODO(atcastle): Analyze if other cache groups should be set to 'all' as well | ||
This comment has been minimized.
Sorry, something went wrong. |
||
chunks: 'all', | ||
name: 'framework', | ||
test: /[\\/]node_modules[\\/](react|react-dom|scheduler|prop-types)[\\/]/, | ||
priority: 40, | ||
|
@@ -232,20 +235,22 @@ export default async function getBaseWebpackConfig( | |
) | ||
}, | ||
name(module: { identifier: Function; rawRequest: string }): string { | ||
const rawRequest = | ||
module.rawRequest && | ||
module.rawRequest.replace(/^@(\w+)[/\\]/, '$1-') | ||
if (rawRequest) return rawRequest | ||
This comment has been minimized.
Sorry, something went wrong.
evocateur
|
||
|
||
const identifier = module.identifier() | ||
// Remove everything up through '/node_modules/' | ||
const trimmedIdentifier = /(?:^|[/\\])node_modules[/\\](.*)/.exec( | ||
identifier | ||
) | ||
const processedIdentifier = | ||
trimmedIdentifier && | ||
trimmedIdentifier[1].replace(/^@(\w+)[/\\]/, '$1-') | ||
// Remove the file extension(s) | ||
/[\w-\/\\]+/.exec(trimmedIdentifier[1]) | ||
|
||
let finalName = processedIdentifier && processedIdentifier[0] | ||
|
||
finalName = finalName && finalName.replace(/[\\\/]/g, '~') | ||
const backupName = identifier.replace(/[\\\/]/g, '~') | ||
|
||
return processedIdentifier || identifier | ||
return finalName || backupName | ||
}, | ||
priority: 30, | ||
minChunks: 1, | ||
|
I would argue the only chunks that need
'initial'
arecommons
andshared
, everything else should be'all'
.