Skip to content

Commit

Permalink
fix(cli): e2e babel default config #80
Browse files Browse the repository at this point in the history
  • Loading branch information
fanniehuang committed Sep 16, 2020
1 parent 992c5cb commit 7d90e5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
30 changes: 20 additions & 10 deletions packages/wxa-cli/src/const/defaultBabelConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,34 @@ const cwd = process.cwd();
const babelRuntime = path.join(cwd, 'node_modules', '@babel/runtime/package.json');
let hasRuntime = existsSync(babelRuntime);

const defaultConfigs = {
'cwd': path.join(__dirname, '../../'),
'sourceMap': false,
'presets': ['@babel/preset-env'],
const commonConfigs = {
'plugins': [
['@babel/plugin-proposal-decorators', {'decoratorsBeforeExport': true}],
['@babel/plugin-proposal-class-properties'],
],
'ignore': [
'node_modules',
'wxa-cli',
],
};
'presets': ['@babel/preset-env'],

}
if (hasRuntime) {
const pkg = require(babelRuntime);

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

const defaultConfigs = {
'cwd': path.join(__dirname, '../../'),
'sourceMap': false,
overrides: [{
exclude: [/node_modules/, /wxa-cli/],
...commonConfigs
}
,{
test: /wxa-e2eTest/,
...commonConfigs
}

]
};


export default defaultConfigs;
2 changes: 1 addition & 1 deletion packages/wxa-cli/src/helpers/wrapWxa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function(code, category='', path) {
let temp = `
var wrapWxa = require('wxa://wxa_wrap').default;
var wrapWxa = require('wxa://wxa_wrap.js').default;
wrapWxa(exports, "${category.toUpperCase()}", "${path}");
${code}`;
Expand Down

0 comments on commit 7d90e5c

Please sign in to comment.