Skip to content

Commit 782abe0

Browse files
committed
fix: eliminateDeadCode require plugin
1 parent faf54cf commit 782abe0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/jsx2mp-loader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsx2mp-loader",
3-
"version": "0.4.37-8",
3+
"version": "0.4.37-9",
44
"description": "",
55
"files": [
66
"src"

packages/jsx2mp-loader/src/utils/dce.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ function removeDeadCode(source) {
1919
return transformSync(source, {
2020
parserOpts,
2121
plugins: [
22-
'babel-plugin-remove-unused-reference'
22+
// 只传入插件名称时,云构建运行异常,babel 加载插件出错。所以必须增加 require()
23+
// Error: Cannot find module 'babel-plugin-remove-unused-reference'
24+
// Make sure that all the Babel plugins and presets you are using are defined as dependencies or devDependencies in your package.json file.
25+
require('babel-plugin-remove-unused-reference')
2326
]
2427
}).code;
2528
}
@@ -29,7 +32,7 @@ function removeUnusedImport(source) {
2932
parserOpts,
3033
plugins: [
3134
[
32-
'babel-plugin-danger-remove-unused-imports',
35+
require('babel-plugin-danger-remove-unused-imports'),
3336
{
3437
ignore: 'rax'
3538
}

0 commit comments

Comments
 (0)