From c2a7362324fbcc158e6606fa99f171bd026d8949 Mon Sep 17 00:00:00 2001 From: dtcz <617710664@qq.com> Date: Thu, 18 Jun 2020 10:43:50 +0800 Subject: [PATCH 1/2] fix(cli-service): fix polyfill injection when building app on multiple threads --- packages/@vue/cli-service/lib/Service.js | 5 ++++- .../lib/commands/build/resolveAppConfig.js | 18 ++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 28a914d49e..bec630a3dc 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -279,7 +279,10 @@ module.exports = class Service { ) } - if (typeof config.entry !== 'function') { + if ( + !process.env.VUE_CLI_ENTRY_FILES && + typeof config.entry !== 'function' + ) { let entryFiles if (typeof config.entry === 'string') { entryFiles = [config.entry] diff --git a/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js index 3e98d3cab3..564482cf40 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js @@ -1,4 +1,11 @@ module.exports = (api, args, options) => { + // respect inline entry + if (args.entry && !options.pages) { + api.configureWebpack(config => { + config.entry = { app: api.resolve(args.entry) } + }) + } + const config = api.resolveChainableWebpackConfig() const targetDir = api.resolve(args.dest || options.outputDir) @@ -36,14 +43,5 @@ module.exports = (api, args, options) => { } } - const rawConfig = api.resolveWebpackConfig(config) - - // respect inline entry - if (args.entry && !options.pages) { - const entry = api.resolve(args.entry) - rawConfig.entry = { app: entry } - process.env.VUE_CLI_ENTRY_FILES = JSON.stringify([entry]) - } - - return rawConfig + return api.resolveWebpackConfig(config) } From 20d454bd7e912ce1818fd411f2f044d7265f53b5 Mon Sep 17 00:00:00 2001 From: dtcz <617710664@qq.com> Date: Thu, 18 Jun 2020 11:16:34 +0800 Subject: [PATCH 2/2] test(cli-service): improve test case about VUE_CLI_ENTRY_FILES check --- packages/@vue/cli-service/__tests__/Service.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@vue/cli-service/__tests__/Service.spec.js b/packages/@vue/cli-service/__tests__/Service.spec.js index 37658ba0f4..4d06390228 100644 --- a/packages/@vue/cli-service/__tests__/Service.spec.js +++ b/packages/@vue/cli-service/__tests__/Service.spec.js @@ -318,6 +318,8 @@ test('api: configureWebpack preserve ruleNames', () => { }) test('internal: should correctly set VUE_CLI_ENTRY_FILES', () => { + delete process.env.VUE_CLI_ENTRY_FILES + const service = createMockService([{ id: 'test', apply: api => {