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(webpack): avoid grouping with default name #7808

Merged
merged 8 commits into from Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -76,6 +76,7 @@
"rollup-plugin-license": "^2.1.0",
"sass-loader": "^8.0.2",
"sort-package-json": "^1.44.0",
"twilio-video": "^2.7.1",
pi0 marked this conversation as resolved.
Show resolved Hide resolved
"typescript": "~3.9",
"vue-jest": "^4.0.0-beta.4"
}
Expand Down
6 changes: 2 additions & 4 deletions packages/config/src/config/build.js
Expand Up @@ -62,11 +62,9 @@ export default () => ({
minimizer: undefined,
splitChunks: {
chunks: 'all',
name: undefined,
automaticNameDelimiter: '/',
cacheGroups: {
default: {
name: undefined
}
default: {}
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions packages/config/test/__snapshots__/options.test.js.snap
Expand Up @@ -113,13 +113,11 @@ Object {
"minimizer": undefined,
"runtimeChunk": "single",
"splitChunks": Object {
"automaticNameDelimiter": "/",
"cacheGroups": Object {
"default": Object {
"name": undefined,
},
"default": Object {},
},
"chunks": "all",
"name": undefined,
},
},
"optimizeCSS": false,
Expand Down
12 changes: 4 additions & 8 deletions packages/config/test/config/__snapshots__/index.test.js.snap
Expand Up @@ -89,13 +89,11 @@ Object {
"minimizer": undefined,
"runtimeChunk": "single",
"splitChunks": Object {
"automaticNameDelimiter": "/",
"cacheGroups": Object {
"default": Object {
"name": undefined,
},
"default": Object {},
},
"chunks": "all",
"name": undefined,
},
},
"optimizeCSS": undefined,
Expand Down Expand Up @@ -469,13 +467,11 @@ Object {
"minimizer": undefined,
"runtimeChunk": "single",
"splitChunks": Object {
"automaticNameDelimiter": "/",
"cacheGroups": Object {
"default": Object {
"name": undefined,
},
"default": Object {},
},
"chunks": "all",
"name": undefined,
},
},
"optimizeCSS": undefined,
Expand Down
19 changes: 6 additions & 13 deletions packages/webpack/src/config/client.js
Expand Up @@ -64,11 +64,10 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
cacheGroups.commons === undefined
) {
cacheGroups.commons = {
name: 'vendors/commons',
test: /node_modules[\\/](vue|vue-loader|vue-router|vuex|vue-meta|core-js|@babel\/runtime|axios|webpack|setimmediate|timers-browserify|process|regenerator-runtime|cookie|js-cookie|is-buffer|dotprop|nuxt\.js)[\\/]/,
chunks: 'all',
priority: 10,
name: true,
automaticNameDelimiter: '/'
priority: 10
}
}

Expand All @@ -85,23 +84,17 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
.filter(Boolean)
.sort()

// Fixes https://github.com/nuxt/nuxt.js/issues/7665
// TODO: We need a reproduction for this case (test/fixtures/shared-chunk)
if (!names.length) {
return 'commons/default'
}

// Single chunk is not common
if (names.length === 1) {
return names[0]
// Fallback to webpack chunk name or generated cache group key
if (names.length < 2) {
return chunks[0].name
}

// Use compact name for concatinated modules
let compactName = names.join('~')
if (compactName.length > 32) {
compactName = hash(compactName)
}
return 'commons/' + compactName
return 'vendors/' + compactName
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/shared-chunk/components/lazy.vue
Expand Up @@ -3,3 +3,11 @@
Lazy Components
</div>
</template>

<script>
import 'twilio-video'

export default {

}
</script>
3 changes: 1 addition & 2 deletions test/fixtures/shared-chunk/nuxt.config.js
@@ -1,4 +1,3 @@
export default {
components: true,
modern: true
components: true
}
46 changes: 46 additions & 0 deletions yarn.lock
Expand Up @@ -2137,6 +2137,11 @@
dependencies:
defer-to-connect "^2.0.0"

"@twilio/webrtc@4.3.1":
version "4.3.1"
resolved "https://registry.npmjs.org/@twilio/webrtc/-/webrtc-4.3.1.tgz#35acd0bda1ce65424d9617defb0b6d9b333c77c7"
integrity sha512-T9Slk8TyKrKqjc4PH4aPknjmEozny/M1TzVyfRRyEQSt548hXXhLYrSp3nUcK49bfzVrgbYuRj6ojExYh2qLqw==

"@types/anymatch@*":
version "1.3.1"
resolved "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
Expand Down Expand Up @@ -3389,6 +3394,13 @@ babel-preset-jest@^26.1.0:
babel-plugin-jest-hoist "^26.1.0"
babel-preset-current-node-syntax "^0.1.2"

backoff@^2.5.0:
version "2.5.0"
resolved "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz#f616eda9d3e4b66b8ca7fca79f695722c5f8e26f"
integrity sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=
dependencies:
precond "0.2"

balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
Expand Down Expand Up @@ -10682,6 +10694,11 @@ postcss@7.x.x, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17,
source-map "^0.6.1"
supports-color "^6.1.0"

precond@0.2:
version "0.2.3"
resolved "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz#aa9591bcaa24923f1e0f4849d240f47efc1075ac"
integrity sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw=

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
Expand Down Expand Up @@ -12813,6 +12830,16 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=

twilio-video@^2.7.1:
version "2.7.1"
resolved "https://registry.npmjs.org/twilio-video/-/twilio-video-2.7.1.tgz#ad4ae5fdca188bb6c64e32c2db9d26ccc5e30448"
integrity sha512-SBPLclQroekLANO7TtmLPtDs2cgiMiJvg4zA+na/0vcDMBIegP5jnwvZKJFONNJacOh+0BNSf6dQl+41/OAi2g==
dependencies:
"@twilio/webrtc" "4.3.1"
backoff "^2.5.0"
ws "^3.3.1"
xmlhttprequest "^1.8.0"

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
Expand Down Expand Up @@ -12897,6 +12924,11 @@ uid-number@0.0.6:
resolved "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
integrity sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=

ultron@~1.1.0:
version "1.1.1"
resolved "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c"
integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==

umask@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d"
Expand Down Expand Up @@ -13651,6 +13683,15 @@ write@1.0.3:
dependencies:
mkdirp "^0.5.1"

ws@^3.3.1:
version "3.3.3"
resolved "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"
integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==
dependencies:
async-limiter "~1.0.0"
safe-buffer "~5.1.0"
ultron "~1.1.0"

ws@^6.0.0:
version "6.2.1"
resolved "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb"
Expand All @@ -13673,6 +13714,11 @@ xmlchars@^2.2.0:
resolved "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==

xmlhttprequest@^1.8.0:
version "1.8.0"
resolved "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc"
integrity sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=

xtend@^4.0.0, xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
Expand Down