From e38c5d27e0d9bfbe8d5e661b506b40c785f2d011 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 13 Apr 2021 20:18:43 +0800 Subject: [PATCH] chore: remove friendly-errors-webpack-plugin --- packages/vant-cli/package.json | 1 - packages/vant-cli/src/common/constant.ts | 4 +- .../src/compiler/gen-component-style.ts | 10 ++-- .../src/compiler/gen-package-style.ts | 4 +- .../src/compiler/gen-style-deps-map.ts | 18 +++---- packages/vant-cli/src/config/webpack.base.ts | 5 -- .../vant-cli/src/config/webpack.site.dev.ts | 5 +- packages/vant-cli/src/module.d.ts | 1 - packages/vant-cli/yarn.lock | 54 +++---------------- 9 files changed, 26 insertions(+), 76 deletions(-) diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index aa4bcf91d..6cbfb81ae 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -42,7 +42,6 @@ "@babel/preset-typescript": "^7.12.7", "@docsearch/css": "3.0.0-alpha.33", "@docsearch/js": "3.0.0-alpha.33", - "@nuxt/friendly-errors-webpack-plugin": "^2.5.0", "@types/webpack-dev-server": "^3.11.1", "@vant/eslint-config": "^3.2.0", "@vant/markdown-loader": "^4.1.0", diff --git a/packages/vant-cli/src/common/constant.ts b/packages/vant-cli/src/common/constant.ts index dec3eac5c..a3f396d3d 100644 --- a/packages/vant-cli/src/common/constant.ts +++ b/packages/vant-cli/src/common/constant.ts @@ -39,12 +39,12 @@ export const CONFIG_DIR = join(__dirname, '../config'); // Dist files export const PACKAGE_ENTRY_FILE = join(DIST_DIR, 'package-entry.js'); export const PACKAGE_STYLE_FILE = join(DIST_DIR, 'package-style.css'); -export const SITE_MODILE_SHARED_FILE = join(DIST_DIR, 'site-mobile-shared.js'); +export const SITE_MOBILE_SHARED_FILE = join(DIST_DIR, 'site-mobile-shared.js'); export const SITE_DESKTOP_SHARED_FILE = join( DIST_DIR, 'site-desktop-shared.js' ); -export const STYPE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json'); +export const STYLE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json'); // Config files export const BABEL_CONFIG_FILE = join(CONFIG_DIR, 'babel.config.js'); diff --git a/packages/vant-cli/src/compiler/gen-component-style.ts b/packages/vant-cli/src/compiler/gen-component-style.ts index 94781646b..092826c1e 100644 --- a/packages/vant-cli/src/compiler/gen-component-style.ts +++ b/packages/vant-cli/src/compiler/gen-component-style.ts @@ -11,11 +11,11 @@ import { ES_DIR, SRC_DIR, LIB_DIR, - STYPE_DEPS_JSON_FILE, + STYLE_DEPS_JSON_FILE, } from '../common/constant'; function getDeps(component: string): string[] { - const styleDepsJson = require(STYPE_DEPS_JSON_FILE); + const styleDepsJson = require(STYLE_DEPS_JSON_FILE); if (styleDepsJson.map[component]) { const deps = styleDepsJson.map[component].slice(0); @@ -57,7 +57,7 @@ function genEntry(params: { }) { const { ext, filename, component, baseFile } = params; const deps = getDeps(component); - const depsPath = deps.map(dep => getRelativePath(component, dep, ext)); + const depsPath = deps.map((dep) => getRelativePath(component, dep, ext)); OUTPUT_CONFIG.forEach(({ dir, template }) => { const outputDir = join(dir, component, 'style'); @@ -81,13 +81,13 @@ export function genComponentStyle( options: { cache: boolean } = { cache: true } ) { if (!options.cache) { - delete require.cache[STYPE_DEPS_JSON_FILE]; + delete require.cache[STYLE_DEPS_JSON_FILE]; } const components = getComponents(); const baseFile = getCssBaseFile(); - components.forEach(component => { + components.forEach((component) => { genEntry({ baseFile, component, diff --git a/packages/vant-cli/src/compiler/gen-package-style.ts b/packages/vant-cli/src/compiler/gen-package-style.ts index 5bde59a5f..930a4f36c 100644 --- a/packages/vant-cli/src/compiler/gen-package-style.ts +++ b/packages/vant-cli/src/compiler/gen-package-style.ts @@ -2,7 +2,7 @@ import { join } from 'path'; import { existsSync } from 'fs-extra'; import { smartOutputFile, normalizePath } from '../common'; import { CSS_LANG, getCssBaseFile } from '../common/css'; -import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant'; +import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant'; type Options = { outputPath: string; @@ -10,7 +10,7 @@ type Options = { }; export function genPackageStyle(options: Options) { - const styleDepsJson = require(STYPE_DEPS_JSON_FILE); + const styleDepsJson = require(STYLE_DEPS_JSON_FILE); const ext = '.' + CSS_LANG; let content = ''; diff --git a/packages/vant-cli/src/compiler/gen-style-deps-map.ts b/packages/vant-cli/src/compiler/gen-style-deps-map.ts index 9df4e135d..2d3cf9446 100644 --- a/packages/vant-cli/src/compiler/gen-style-deps-map.ts +++ b/packages/vant-cli/src/compiler/gen-style-deps-map.ts @@ -3,7 +3,7 @@ import { CSS_LANG } from '../common/css'; import { existsSync } from 'fs-extra'; import { getDeps, clearDepsCache, fillExt } from './get-deps'; import { getComponents, smartOutputFile } from '../common'; -import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant'; +import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant'; function matchPath(path: string, component: string): boolean { const p = relative(SRC_DIR, path); @@ -28,15 +28,15 @@ function analyzeComponentDeps(components: string[], component: string) { function search(filePath: string) { record.add(filePath); - getDeps(filePath).forEach(key => { + getDeps(filePath).forEach((key) => { if (record.has(key)) { return; } search(key); components - .filter(item => matchPath(key, item)) - .forEach(item => { + .filter((item) => matchPath(key, item)) + .forEach((item) => { if (!checkList.includes(item) && item !== component) { checkList.push(item); } @@ -80,7 +80,7 @@ function getSequence(components: string[], depsMap: DepsMap) { return; } - const maxIndex = Math.max(...deps.map(dep => sequence.indexOf(dep))); + const maxIndex = Math.max(...deps.map((dep) => sequence.indexOf(dep))); sequence.splice(maxIndex + 1, 0, item); } @@ -93,25 +93,25 @@ function getSequence(components: string[], depsMap: DepsMap) { export async function genStyleDepsMap() { const components = getComponents(); - return new Promise(resolve => { + return new Promise((resolve) => { clearDepsCache(); const map = {} as DepsMap; - components.forEach(component => { + components.forEach((component) => { map[component] = analyzeComponentDeps(components, component); }); const sequence = getSequence(components, map); - Object.keys(map).forEach(key => { + Object.keys(map).forEach((key) => { map[key] = map[key].sort( (a, b) => sequence.indexOf(a) - sequence.indexOf(b) ); }); smartOutputFile( - STYPE_DEPS_JSON_FILE, + STYLE_DEPS_JSON_FILE, JSON.stringify({ map, sequence }, null, 2) ); diff --git a/packages/vant-cli/src/config/webpack.base.ts b/packages/vant-cli/src/config/webpack.base.ts index 8e1024b75..02900925e 100644 --- a/packages/vant-cli/src/config/webpack.base.ts +++ b/packages/vant-cli/src/config/webpack.base.ts @@ -1,6 +1,5 @@ import sass from 'sass'; import webpack from 'webpack'; -import FriendlyErrorsPlugin from '@nuxt/friendly-errors-webpack-plugin'; import { VueLoaderPlugin } from 'vue-loader'; import { join } from 'path'; import { consola } from '../common/logger'; @@ -39,10 +38,6 @@ const plugins = [ __VUE_PROD_DEVTOOLS__: 'false', }), new VueLoaderPlugin(), - new FriendlyErrorsPlugin({ - clearConsole: false, - logLevel: 'WARNING', - }), ]; const tsconfigPath = join(CWD, 'tsconfig.json'); diff --git a/packages/vant-cli/src/config/webpack.site.dev.ts b/packages/vant-cli/src/config/webpack.site.dev.ts index c017b243e..d80beb2b0 100644 --- a/packages/vant-cli/src/config/webpack.site.dev.ts +++ b/packages/vant-cli/src/config/webpack.site.dev.ts @@ -9,7 +9,7 @@ import { getVantConfig, getWebpackConfig } from '../common'; import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin'; import { GREEN, - SITE_MODILE_SHARED_FILE, + SITE_MOBILE_SHARED_FILE, SITE_DESKTOP_SHARED_FILE, } from '../common/constant'; @@ -48,7 +48,6 @@ export function getSiteDevBaseConfig(): WebpackConfig { }, devServer: { port: 8080, - quiet: true, host: '0.0.0.0', stats: 'errors-only', publicPath: '/', @@ -56,7 +55,7 @@ export function getSiteDevBaseConfig(): WebpackConfig { }, resolve: { alias: { - 'site-mobile-shared': SITE_MODILE_SHARED_FILE, + 'site-mobile-shared': SITE_MOBILE_SHARED_FILE, 'site-desktop-shared': SITE_DESKTOP_SHARED_FILE, }, }, diff --git a/packages/vant-cli/src/module.d.ts b/packages/vant-cli/src/module.d.ts index d18a11718..033927a91 100644 --- a/packages/vant-cli/src/module.d.ts +++ b/packages/vant-cli/src/module.d.ts @@ -10,4 +10,3 @@ declare module 'html-webpack-plugin'; declare module 'conventional-changelog'; declare module '@vant/markdown-vetur'; declare module '@babel/helper-plugin-utils'; -declare module '@nuxt/friendly-errors-webpack-plugin'; diff --git a/packages/vant-cli/yarn.lock b/packages/vant-cli/yarn.lock index ba63e4b00..a177eca84 100644 --- a/packages/vant-cli/yarn.lock +++ b/packages/vant-cli/yarn.lock @@ -1247,16 +1247,6 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" -"@nuxt/friendly-errors-webpack-plugin@^2.5.0": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@nuxt/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-2.5.0.tgz#5374665bc72d34b7dbadcc361a4777e3f0f5d46b" - integrity sha512-pUgPFmRL56/xuTCGN5rqgTfxvs1N/AYJw7q7tUHiZaBm3UyPgbIVPkadS9njwbFbPD2XcebVy7npQMMVwQJWfA== - dependencies: - chalk "^2.3.2" - consola "^2.6.0" - error-stack-parser "^2.0.0" - string-width "^2.0.0" - "@octokit/auth-token@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f" @@ -2191,11 +2181,6 @@ ansi-regex@^2.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= - ansi-regex@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" @@ -2848,7 +2833,7 @@ chalk@4.1.0, chalk@^4.0.0, chalk@^4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.2, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3192,7 +3177,7 @@ connect-history-api-fallback@^1.6.0: resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc" integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg== -consola@^2.15.0, consola@^2.6.0: +consola@^2.15.0: version "2.15.0" resolved "https://registry.npm.taobao.org/consola/download/consola-2.15.0.tgz?cache=0&sync_timestamp=1596625649554&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fconsola%2Fdownload%2Fconsola-2.15.0.tgz#40fc4eefa4d2f8ef2e2806147f056ea207fcc0e9" integrity sha1-QPxO76TS+O8uKAYUfwVuogf8wOk= @@ -3973,13 +3958,6 @@ error-ex@^1.2.0, error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -error-stack-parser@^2.0.0: - version "2.0.6" - resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8" - integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ== - dependencies: - stackframe "^1.1.1" - es-abstract@^1.17.0, es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: version "1.17.6" resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" @@ -8141,10 +8119,10 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@^2.2.1: - version "2.2.1" - resolved "https://registry.npm.taobao.org/prettier/download/prettier-2.2.1.tgz?cache=0&sync_timestamp=1606523097359&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" - integrity sha1-eVoaeN1S8HPaDNQrIfnJE4GSP/U= +prettier@2.1.0: + version "2.1.0" + resolved "http://registry.npm.qima-inc.com/prettier/download/prettier-2.1.0.tgz#5a9789f767a243118c60f3e56d95cb6544914fbb" + integrity sha1-WpeJ92eiQxGMYPPlbZXLZUSRT7s= pretty-error@^2.1.1: version "2.1.1" @@ -9363,11 +9341,6 @@ stack-utils@^2.0.2: dependencies: escape-string-regexp "^2.0.0" -stackframe@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.1.1.tgz#ffef0a3318b1b60c3b58564989aca5660729ec71" - integrity sha512-0PlYhdKh6AfFxRyK/v+6/k+/mMfyiEBbTM5L94D0ZytQnJ166wuwoTYLHFWGbs2dpA8Rgq763KGWmN1EQEYHRQ== - state-toggle@^1.0.0: version "1.0.3" resolved "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.3.tgz#e123b16a88e143139b09c6852221bc9815917dfe" @@ -9416,14 +9389,6 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -string-width@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" - string-width@^3.0.0, string-width@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" @@ -9488,13 +9453,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= - dependencies: - ansi-regex "^3.0.0" - strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"