From d4dbc0b72bc755b80f19cec0d60015c35f3480f7 Mon Sep 17 00:00:00 2001 From: luckyadam Date: Wed, 18 Sep 2019 21:25:41 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/loaders/fileParseLoader.ts | 3 +-- .../src/plugins/TaroLoadChunksPlugin.ts | 2 +- packages/taro-mini-runner/src/utils/index.ts | 3 +-- packages/taro-mini-runner/src/webpack/chain.ts | 15 +++++++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/taro-mini-runner/src/loaders/fileParseLoader.ts b/packages/taro-mini-runner/src/loaders/fileParseLoader.ts index c341baa6c463..ef8ac3a34ed3 100644 --- a/packages/taro-mini-runner/src/loaders/fileParseLoader.ts +++ b/packages/taro-mini-runner/src/loaders/fileParseLoader.ts @@ -14,8 +14,7 @@ import { taroJsRedux, QUICKAPP_SPECIAL_COMPONENTS, PARSE_AST_TYPE, - NODE_MODULES_REG, - REG_STYLE + NODE_MODULES_REG } from '../utils/constants' import { isNpmPkg, diff --git a/packages/taro-mini-runner/src/plugins/TaroLoadChunksPlugin.ts b/packages/taro-mini-runner/src/plugins/TaroLoadChunksPlugin.ts index d0f51b0f4054..c31836b6c82d 100644 --- a/packages/taro-mini-runner/src/plugins/TaroLoadChunksPlugin.ts +++ b/packages/taro-mini-runner/src/plugins/TaroLoadChunksPlugin.ts @@ -24,7 +24,7 @@ export default class TaroLoadChunksPlugin { } apply (compiler: webpack.Compiler) { - compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: compilation.Compilation) => { + compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: any) => { let commonChunks compilation.hooks.afterOptimizeChunks.tap(PLUGIN_NAME, (chunks: compilation.Chunk[]) => { commonChunks = chunks.filter(chunk => this.commonChunks.includes(chunk.name)).reverse() diff --git a/packages/taro-mini-runner/src/utils/index.ts b/packages/taro-mini-runner/src/utils/index.ts index b3794a49e909..2f87f917f1ee 100644 --- a/packages/taro-mini-runner/src/utils/index.ts +++ b/packages/taro-mini-runner/src/utils/index.ts @@ -4,9 +4,8 @@ import * as fs from 'fs-extra' import * as resolvePath from 'resolve' import * as t from 'babel-types' import { mergeWith } from 'lodash' -import { Transform } from 'stream' -import { CONFIG_MAP, JS_EXT, TS_EXT, NODE_MODULES_REG, MINI_APP_FILES, BUILD_TYPES, CSS_IMPORT_REG, REG_STYLE } from './constants' +import { CONFIG_MAP, JS_EXT, TS_EXT, NODE_MODULES_REG } from './constants' import { IOption, IComponentObj } from './types' export const isNodeModule = (filename: string) => NODE_MODULES_REG.test(filename) diff --git a/packages/taro-mini-runner/src/webpack/chain.ts b/packages/taro-mini-runner/src/webpack/chain.ts index 4233441eb8fa..6aa00db8cc64 100644 --- a/packages/taro-mini-runner/src/webpack/chain.ts +++ b/packages/taro-mini-runner/src/webpack/chain.ts @@ -15,7 +15,17 @@ import { getPostcssPlugins } from './postcss.conf' import MiniPlugin from '../plugins/MiniPlugin' import { IOption } from '../utils/types' import { recursiveMerge, isNodeModule } from '../utils' -import { REG_SASS, REG_LESS, REG_STYLUS, REG_STYLE, REG_MEDIA, REG_FONT, REG_IMAGE, BUILD_TYPES, REG_SCRIPTS, MINI_APP_FILES, REG_UX } from '../utils/constants' +import { + REG_SASS, + REG_LESS, + REG_STYLUS, + REG_STYLE, + REG_MEDIA, + REG_FONT, + REG_IMAGE, + BUILD_TYPES, + REG_SCRIPTS +} from '../utils/constants' const globalObjectMap = { [BUILD_TYPES.WEAPP]: 'wx', @@ -23,6 +33,7 @@ const globalObjectMap = { [BUILD_TYPES.SWAN]: 'swan', [BUILD_TYPES.QQ]: 'qq', [BUILD_TYPES.TT]: 'tt', + [BUILD_TYPES.JD]: 'jd', [BUILD_TYPES.QUICKAPP]: 'global' } @@ -91,7 +102,7 @@ export const mergeOption = ([...options]: IOption[]): IOption => { const styleModuleReg = /(.*\.module).*\.(css|s[ac]ss|less|styl)\b/ const styleGlobalReg = /(.*\.global).*\.(css|s[ac]ss|less|styl)\b/ -export const processEnvOption = partial(mapKeys, (key: string) => `process.env.${key}`) +export const processEnvOption = partial(mapKeys as any, (key: string) => `process.env.${key}`) export const getCssLoader = pipe(mergeOption, partial(getLoader, 'css-loader')) export const getPostcssLoader = pipe(mergeOption, partial(getLoader, 'postcss-loader'))