Skip to content

Commit

Permalink
chore: 修复语法报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jan 7, 2020
1 parent 890ae14 commit d4dbc0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/taro-mini-runner/src/loaders/fileParseLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions packages/taro-mini-runner/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions packages/taro-mini-runner/src/webpack/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@ 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',
[BUILD_TYPES.ALIPAY]: 'my',
[BUILD_TYPES.SWAN]: 'swan',
[BUILD_TYPES.QQ]: 'qq',
[BUILD_TYPES.TT]: 'tt',
[BUILD_TYPES.JD]: 'jd',
[BUILD_TYPES.QUICKAPP]: 'global'
}

Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit d4dbc0b

Please sign in to comment.