From ae111393f2e14504de78613f9e85431b3f8af748 Mon Sep 17 00:00:00 2001 From: "Sean G. Wright" Date: Fri, 25 Oct 2019 04:04:27 -0400 Subject: [PATCH 001/804] Update migrating-from-v3 README typo (#4746) Changed `--sav-dev` to `--save-dev` --- docs/migrating-from-v3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migrating-from-v3/README.md b/docs/migrating-from-v3/README.md index e69227c3d2..df7a64ca48 100644 --- a/docs/migrating-from-v3/README.md +++ b/docs/migrating-from-v3/README.md @@ -224,7 +224,7 @@ It now requires `eslint`, `eslint-plugin-prettier` and `prettier` as peer depend For older projects, if you encountered issues like `Cannot find module: eslint-plugin-prettier`, please run the following command to fix it: ```sh -npm install --sav-dev eslint@5 @vue/eslint-config-prettier@5 eslint-plugin-prettier prettier +npm install --save-dev eslint@5 @vue/eslint-config-prettier@5 eslint-plugin-prettier prettier ``` ------ From 6347fd26600d66cdd03eec5027c41e7b76d88f41 Mon Sep 17 00:00:00 2001 From: arnaudvalle Date: Sat, 26 Oct 2019 09:54:30 +0200 Subject: [PATCH 002/804] docs: specify default entryFile value for serve command (#4758) --- docs/guide/cli-service.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/cli-service.md b/docs/guide/cli-service.md index 1a4ba4560b..e0502a00e7 100644 --- a/docs/guide/cli-service.md +++ b/docs/guide/cli-service.md @@ -63,7 +63,7 @@ The `vue-cli-service serve` command starts a dev server (based on [webpack-dev-s In addition to the command line flags, you can also configure the dev server using the [devServer](../config/#devserver) field in `vue.config.js`. -`[entry]` in the CLI command is defined as *the entry file*, not *an additional entry file*. If you overwrite the entry in the CLI, then the entries from `config.pages` are no longer considered, which may cause an error. +`[entry]` in the CLI command is defined as *the entry file*, not *an additional entry file*. If you overwrite the entry in the CLI, then the entries from `config.pages` are no longer considered, which may cause an error. Defaults to [entryFile](../dev-guide/generator-api.html#entryfile). ## vue-cli-service build From 77384eced81180b4c39d377d1bfdeeacf1886670 Mon Sep 17 00:00:00 2001 From: Yoshiaki Itakura Date: Wed, 6 Nov 2019 23:14:28 +0900 Subject: [PATCH 003/804] fix docs `css.loaderOptions.css.localsConvention` (#4803) Moved 'localsConvention' to the same level as 'modules'. --- docs/guide/css.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide/css.md b/docs/guide/css.md index aac1986dbf..638633c34b 100644 --- a/docs/guide/css.md +++ b/docs/guide/css.md @@ -112,9 +112,9 @@ module.exports = { // For Vue CLI v3 users, please refer to css-loader v1 documentations // https://github.com/webpack-contrib/css-loader/tree/v1.0.1 modules: { - localIdentName: '[name]-[hash]', - localsConvention: 'camelCaseOnly' - } + localIdentName: '[name]-[hash]' + }, + localsConvention: 'camelCaseOnly' } } } From d4bd9c644fbb563f6c9750143ac70c94a95a2b45 Mon Sep 17 00:00:00 2001 From: gregoiredx Date: Thu, 7 Nov 2019 06:17:48 +0100 Subject: [PATCH 004/804] use gitlab CI env variable for project name (#4716) * use gitlab CI env variable for project name * add explanation on CI_PROJECT_NAME env var * docs: gzip support in GitLab Pages --- docs/guide/deployment.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/guide/deployment.md b/docs/guide/deployment.md index cbf32e1efe..be568a1a04 100644 --- a/docs/guide/deployment.md +++ b/docs/guide/deployment.md @@ -130,6 +130,8 @@ pages: # the job must be named pages - npm run build - mv public public-vue # GitLab Pages hooks on the public folder - mv dist public # rename the dist folder (result of npm run build) + # optionally, you can activate gzip support wih the following line: + - find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec gzip -f -k {} \; artifacts: paths: - public # artifact path must be /public for GitLab Pages to pick it up @@ -137,15 +139,15 @@ pages: # the job must be named pages - master ``` -Typically, your static website will be hosted on https://yourUserName.gitlab.io/yourProjectName, so you will also want to create an initial `vue.config.js` file to [update the `BASE_URL`](https://github.com/vuejs/vue-cli/tree/dev/docs/config#baseurl) value to match: +Typically, your static website will be hosted on https://yourUserName.gitlab.io/yourProjectName, so you will also want to create an initial `vue.config.js` file to [update the `BASE_URL`](https://github.com/vuejs/vue-cli/tree/dev/docs/config#baseurl) value to match your project name (the [`CI_PROJECT_NAME` environment variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) contains this value): + ```javascript // vue.config.js file to be place in the root of your repository -// make sure you update `yourProjectName` with the name of your GitLab project module.exports = { publicPath: process.env.NODE_ENV === 'production' - ? '/yourProjectName/' + ? '/' + process.env.CI_PROJECT_NAME + '/' : '/' } ``` From f9291581e844893e51006b7db883e8d13303dc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E7=BF=B0=E5=BC=9F?= <18233566286@163.com> Date: Mon, 11 Nov 2019 19:16:21 +0800 Subject: [PATCH 005/804] docs(zh): Update browser-compatibility.md (#4831) --- docs/zh/guide/browser-compatibility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/guide/browser-compatibility.md b/docs/zh/guide/browser-compatibility.md index b5a9e848cb..098297ca53 100644 --- a/docs/zh/guide/browser-compatibility.md +++ b/docs/zh/guide/browser-compatibility.md @@ -16,7 +16,7 @@ 如果有依赖需要 polyfill,你有几种选择: -1. **如果该依赖基于一个目标环境不支持的 ES 版本撰写:** 将其添加到 `vue.config.js` 中的 [`transpileDependencies`](../config/#transpiledependencies) 选项。这会为该依赖同时开启语法语法转换和根据使用情况检测 polyfill。 +1. **如果该依赖基于一个目标环境不支持的 ES 版本撰写:** 将其添加到 `vue.config.js` 中的 [`transpileDependencies`](../config/#transpiledependencies) 选项。这会为该依赖同时开启语法转换和根据使用情况检测 polyfill。 2. **如果该依赖交付了 ES5 代码并显式地列出了需要的 polyfill:** 你可以使用 `@vue/babel-preset-app` 的 [polyfills](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app#polyfills) 选项预包含所需要的 polyfill。**注意 `es6.promise` 将被默认包含,因为现在的库依赖 Promise 是非常普遍的。** From 6c4a0bf4f80c279f825322c29780b18c354d529e Mon Sep 17 00:00:00 2001 From: Thomas Kint Date: Tue, 12 Nov 2019 15:33:18 +0100 Subject: [PATCH 006/804] feat: allow use of full url for pwa manifest and icons (#4736) --- .../@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js b/packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js index 8f114e6c45..a42852960e 100644 --- a/packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js +++ b/packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js @@ -75,25 +75,25 @@ module.exports = class HtmlPwaPlugin { rel: 'icon', type: 'image/png', sizes: '32x32', - href: `${publicPath}${iconPaths.favicon32}${assetsVersionStr}` + href: getTagHref(publicPath, iconPaths.favicon32, assetsVersionStr) }), makeTag('link', { rel: 'icon', type: 'image/png', sizes: '16x16', - href: `${publicPath}${iconPaths.favicon16}${assetsVersionStr}` + href: getTagHref(publicPath, iconPaths.favicon16, assetsVersionStr) }), // Add to home screen for Android and modern mobile browsers makeTag('link', manifestCrossorigin ? { rel: 'manifest', - href: `${publicPath}${manifestPath}${assetsVersionStr}`, + href: getTagHref(publicPath, manifestPath, assetsVersionStr), crossorigin: manifestCrossorigin } : { rel: 'manifest', - href: `${publicPath}${manifestPath}${assetsVersionStr}` + href: getTagHref(publicPath, manifestPath, assetsVersionStr) } ), makeTag('meta', { @@ -116,18 +116,18 @@ module.exports = class HtmlPwaPlugin { }), makeTag('link', { rel: 'apple-touch-icon', - href: `${publicPath}${iconPaths.appleTouchIcon}${assetsVersionStr}` + href: getTagHref(publicPath, iconPaths.appleTouchIcon, assetsVersionStr) }), makeTag('link', { rel: 'mask-icon', - href: `${publicPath}${iconPaths.maskIcon}${assetsVersionStr}`, + href: getTagHref(publicPath, iconPaths.maskIcon, assetsVersionStr), color: themeColor }), // Add to home screen for Windows makeTag('meta', { name: 'msapplication-TileImage', - content: `${publicPath}${iconPaths.msTileImage}${assetsVersionStr}` + content: getTagHref(publicPath, iconPaths.msTileImage, assetsVersionStr) }), makeTag('meta', { name: 'msapplication-TileColor', @@ -170,3 +170,11 @@ function makeTag (tagName, attributes, closeTag = false) { attributes } } + +function getTagHref (publicPath, href, assetsVersionStr) { + let tagHref = `${href}${assetsVersionStr}` + if (!(/(http(s?)):\/\//gi.test(href))) { + tagHref = `${publicPath}${tagHref}` + } + return tagHref +} From 2652ab6a6bf7da5efc78e69e95801be0edef3d6e Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 13 Nov 2019 00:13:02 +0800 Subject: [PATCH 007/804] fix: include prereleases for `assert*Version` calls --- packages/@vue/cli-service/lib/PluginAPI.js | 2 +- packages/@vue/cli/lib/GeneratorAPI.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@vue/cli-service/lib/PluginAPI.js b/packages/@vue/cli-service/lib/PluginAPI.js index 66ed0ab0d1..be42a515b5 100644 --- a/packages/@vue/cli-service/lib/PluginAPI.js +++ b/packages/@vue/cli-service/lib/PluginAPI.js @@ -33,7 +33,7 @@ class PluginAPI { throw new Error('Expected string or integer value.') } - if (semver.satisfies(this.version, range)) return + if (semver.satisfies(this.version, range, { includePrerelease: true })) return throw new Error( `Require @vue/cli-service "${range}", but was loaded with "${this.version}".` diff --git a/packages/@vue/cli/lib/GeneratorAPI.js b/packages/@vue/cli/lib/GeneratorAPI.js index 6ae208720d..36cbe1313d 100644 --- a/packages/@vue/cli/lib/GeneratorAPI.js +++ b/packages/@vue/cli/lib/GeneratorAPI.js @@ -90,7 +90,7 @@ class GeneratorAPI { throw new Error('Expected string or integer value.') } - if (semver.satisfies(this.cliVersion, range)) return + if (semver.satisfies(this.cliVersion, range, { includePrerelease: true })) return throw new Error( `Require global @vue/cli "${range}", but was invoked by "${this.cliVersion}".` @@ -124,7 +124,7 @@ class GeneratorAPI { throw new Error('Expected string or integer value.') } - if (semver.satisfies(this.cliServiceVersion, range)) return + if (semver.satisfies(this.cliServiceVersion, range, { includePrerelease: true })) return throw new Error( `Require @vue/cli-service "${range}", but was loaded with "${this.cliServiceVersion}".` From e46ac207846cdc806d03881828c3a08f8f2162fe Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 21 Nov 2019 16:33:02 +0800 Subject: [PATCH 008/804] docs: add warnings on css sideEffects (#4836) These warnings are originally stated in the vue-loader documentation, but the CLI documentation perhaps have more visibility. Fixes #4832 --- docs/guide/build-targets.md | 6 +++++- docs/zh/guide/build-targets.md | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/guide/build-targets.md b/docs/guide/build-targets.md index 064c19b7f2..6414814825 100644 --- a/docs/guide/build-targets.md +++ b/docs/guide/build-targets.md @@ -50,6 +50,10 @@ A lib build outputs: - `dist/myLib.css`: Extracted CSS file (can be forced into inlined by setting `css: { extract: false }` in `vue.config.js`) +::: warning +If you are developing a library or in a monorepo, please be aware that CSS imports **are side effects**. Make sure to **remove** `"sideEffects": false` in the `package.json`, otherwise CSS chunks will be dropped by webpack in production builds. +::: + ### Vue vs. JS/TS Entry Files When using a `.vue` file as entry, your library will directly expose the Vue component itself, because the component is always the default export. @@ -148,7 +152,7 @@ Now on the page, the user only needs to include Vue and the entry file: When building a [Webcomponent](#web-component) or [Library](#library), the entry point is not `main.js`, but an `entry-wc.js` file, generated here: [https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js) -So to use vuex in web component target, you need to initialize the store in `App.vue`: +So to use vuex in web component target, you need to initialize the store in `App.vue`: ``` js import store from './store' diff --git a/docs/zh/guide/build-targets.md b/docs/zh/guide/build-targets.md index ad191878fc..a0cd4d795c 100644 --- a/docs/zh/guide/build-targets.md +++ b/docs/zh/guide/build-targets.md @@ -54,6 +54,10 @@ dist/myLib.css 0.33 kb 0.23 kb - `dist/myLib.css`:提取出来的 CSS 文件 (可以通过在 `vue.config.js` 中设置 `css: { extract: false }` 强制内联) +::: warning 警告 +如果你在开发一个库或多项目仓库 (monorepo),请注意导入 CSS **是具有副作用的**。请确保在 `package.json` 中**移除** `"sideEffects": false`,否则 CSS 代码块会在生产环境构建时被 webpack 丢掉。 +::: + ### Vue vs. JS/TS 入口文件 当使用一个 `.vue` 文件作为入口时,你的库会直接暴露这个 Vue 组件本身,因为组件始终是默认导出的内容。 From f83c44113f993ea1a92ca846109ddc6ef38cd7aa Mon Sep 17 00:00:00 2001 From: "Jose G. Alfonso" Date: Thu, 21 Nov 2019 00:33:38 -0800 Subject: [PATCH 009/804] Update doc section on Git Hooks (#4820) Added complete required entries for lint-staged to work --- docs/guide/cli-service.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guide/cli-service.md b/docs/guide/cli-service.md index e0502a00e7..cce0298632 100644 --- a/docs/guide/cli-service.md +++ b/docs/guide/cli-service.md @@ -167,6 +167,12 @@ When installed, `@vue/cli-service` also installs [yorkie](https://github.com/yyx { "gitHooks": { "pre-commit": "lint-staged" + }, + "lint-staged": { + "*.{js,vue}": [ + "vue-cli-service lint", + "git add" + ] } } ``` From 0f6ec2e53df58881c50df1bf1ec638bd71b2bdb8 Mon Sep 17 00:00:00 2001 From: Yingya Zhang Date: Mon, 25 Nov 2019 16:11:29 +0800 Subject: [PATCH 010/804] fix: typo atfer (#4851) --- packages/@vue/babel-preset-app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/babel-preset-app/index.js b/packages/@vue/babel-preset-app/index.js index 26e1c09e21..3dba7f9ea4 100644 --- a/packages/@vue/babel-preset-app/index.js +++ b/packages/@vue/babel-preset-app/index.js @@ -73,7 +73,7 @@ module.exports = (context, options = {}) => { entryFiles = defaultEntryFiles, // Undocumented option of @babel/plugin-transform-runtime. - // When enabled, an absolute path is used when importing a runtime helper atfer tranforming. + // When enabled, an absolute path is used when importing a runtime helper after tranforming. // This ensures the transpiled file always use the runtime version required in this package. // However, this may cause hash inconsistency if the project is moved to another directory. // So here we allow user to explicit disable this option if hash consistency is a requirement From 2c138000513ef92626f872baef0fd27a75e971f0 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 25 Nov 2019 16:18:35 +0800 Subject: [PATCH 011/804] chore: fix typo in comment [ci skip] --- packages/@vue/babel-preset-app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/babel-preset-app/index.js b/packages/@vue/babel-preset-app/index.js index 3dba7f9ea4..72f77c68f2 100644 --- a/packages/@vue/babel-preset-app/index.js +++ b/packages/@vue/babel-preset-app/index.js @@ -73,7 +73,7 @@ module.exports = (context, options = {}) => { entryFiles = defaultEntryFiles, // Undocumented option of @babel/plugin-transform-runtime. - // When enabled, an absolute path is used when importing a runtime helper after tranforming. + // When enabled, an absolute path is used when importing a runtime helper after transforming. // This ensures the transpiled file always use the runtime version required in this package. // However, this may cause hash inconsistency if the project is moved to another directory. // So here we allow user to explicit disable this option if hash consistency is a requirement From ef2cbae66fd71ed257d6c7d7d8ddf92dce09a767 Mon Sep 17 00:00:00 2001 From: Yann Bertrand <5855339+yannbertrand@users.noreply.github.com> Date: Tue, 26 Nov 2019 08:38:57 +0100 Subject: [PATCH 012/804] fix: invalid version error when modules not installed (#4859) fix #4781 --- packages/@vue/cli/lib/Upgrader.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/@vue/cli/lib/Upgrader.js b/packages/@vue/cli/lib/Upgrader.js index dfa14afc80..31ce20bec0 100644 --- a/packages/@vue/cli/lib/Upgrader.js +++ b/packages/@vue/cli/lib/Upgrader.js @@ -201,6 +201,10 @@ module.exports = class Upgrader { const installed = await this.pm.getInstalledVersion(name) const wanted = await this.pm.getRemoteVersion(name, range) + if (installed === 'N/A') { + throw new Error('At least one dependency is not installed. Please run npm install or yarn before trying to upgrade') + } + let latest = await this.pm.getRemoteVersion(name) if (includeNext) { const next = await this.pm.getRemoteVersion(name, 'next') From b7f83b45ce4e6edeee0582f015a2ae73f86fc8e5 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 26 Nov 2019 15:52:50 +0800 Subject: [PATCH 013/804] fix: support `parser` option for codemods, and enable ts parsing by default (#4883) fixes #4861 --- packages/@vue/cli/__tests__/Generator.spec.js | 18 +++++++++++ packages/@vue/cli/lib/util/runCodemod.js | 30 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/packages/@vue/cli/__tests__/Generator.spec.js b/packages/@vue/cli/__tests__/Generator.spec.js index 5fdc43b349..b2bca9c33a 100644 --- a/packages/@vue/cli/__tests__/Generator.spec.js +++ b/packages/@vue/cli/__tests__/Generator.spec.js @@ -23,6 +23,7 @@ new Vue({ }).$mount('#app') `.trim()) fs.writeFileSync(path.resolve(templateDir, 'empty-entry.js'), `;`) +fs.writeFileSync(path.resolve(templateDir, 'main.ts'), `const a: string = 'hello';`) fs.writeFileSync(path.resolve(templateDir, 'hello.vue'), `