Skip to content

Commit 7d90e5c

Browse files
author
fanniehuang
committed
fix(cli): e2e babel default config #80
1 parent 992c5cb commit 7d90e5c

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

packages/wxa-cli/src/const/defaultBabelConfigs.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@ const cwd = process.cwd();
66
const babelRuntime = path.join(cwd, 'node_modules', '@babel/runtime/package.json');
77
let hasRuntime = existsSync(babelRuntime);
88

9-
const defaultConfigs = {
10-
'cwd': path.join(__dirname, '../../'),
11-
'sourceMap': false,
12-
'presets': ['@babel/preset-env'],
9+
const commonConfigs = {
1310
'plugins': [
1411
['@babel/plugin-proposal-decorators', {'decoratorsBeforeExport': true}],
1512
['@babel/plugin-proposal-class-properties'],
1613
],
17-
'ignore': [
18-
'node_modules',
19-
'wxa-cli',
20-
],
21-
};
14+
'presets': ['@babel/preset-env'],
2215

16+
}
2317
if (hasRuntime) {
2418
const pkg = require(babelRuntime);
2519

26-
defaultConfigs.plugins.unshift(['@babel/plugin-transform-runtime', {'version': pkg.version || '7.2.0'}]);
20+
commonConfigs.plugins.unshift(['@babel/plugin-transform-runtime', {'version': pkg.version || '7.2.0'}]);
2721
}
2822

23+
const defaultConfigs = {
24+
'cwd': path.join(__dirname, '../../'),
25+
'sourceMap': false,
26+
overrides: [{
27+
exclude: [/node_modules/, /wxa-cli/],
28+
...commonConfigs
29+
}
30+
,{
31+
test: /wxa-e2eTest/,
32+
...commonConfigs
33+
}
34+
35+
]
36+
};
37+
38+
2939
export default defaultConfigs;

packages/wxa-cli/src/helpers/wrapWxa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function(code, category='', path) {
22
let temp = `
3-
var wrapWxa = require('wxa://wxa_wrap').default;
3+
var wrapWxa = require('wxa://wxa_wrap.js').default;
44
wrapWxa(exports, "${category.toUpperCase()}", "${path}");
55
66
${code}`;

0 commit comments

Comments
 (0)