Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mini-runner): 修复对 vue3 的支持,close #7708 #7759

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
NODE_MODULES_REG,
FRAMEWORK_EXT_MAP,
printLog,
processTypeEnum
processTypeEnum,
FRAMEWORK_MAP
} from '@tarojs/helper'

import TaroSingleEntryDependency from '../dependencies/TaroSingleEntryDependency'
Expand Down Expand Up @@ -64,14 +65,19 @@ interface FilesConfig {
}
}

export const createTarget = function createTarget (_) {
export const createTarget = function createTarget ({ framework }) {
return (compiler: webpack.compiler.Compiler) => {
const { options } = compiler
new JsonpTemplatePlugin().apply(compiler)
new FunctionModulePlugin(options.output).apply(compiler)
new NodeSourcePlugin(options.node).apply(compiler)
if (process.env.NODE_ENV !== 'jest') {
new LoaderTargetPlugin('node').apply(compiler)
// 暂时性修复 vue3 兼容问题,后续再改进写法
if (framework === FRAMEWORK_MAP.VUE3) {
new LoaderTargetPlugin('web').apply(compiler)
} else {
new LoaderTargetPlugin('node').apply(compiler)
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/taro-mini-runner/src/webpack/build.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ export default (appPath: string, mode, config: Partial<IBuildConfig>): any => {
publicPath: '/',
globalObject
}, output]),
target: createTarget(buildAdapter),
target: createTarget({
framework
}),
resolve: { alias },
module: getModule(appPath, {
sourceDir,
Expand Down