chore: add babel.config to fix build error
This commit is contained in:
parent
f9e6913c20
commit
bc5ec03884
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
plugins: [
|
||||
['@babel/plugin-proposal-decorators', { legacy: true }],
|
||||
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
|
||||
],
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -1,22 +0,0 @@
|
|||
const babelJest = require('babel-jest');
|
||||
const getBabelConfig = require('build-scripts-config/lib/config/babel/index.js');
|
||||
const formatWinPath = require('build-scripts-config/lib/config/jest/formatWinPath');
|
||||
const babelConfig = getBabelConfig();
|
||||
|
||||
babelConfig.plugins.push(['@babel/plugin-proposal-class-properties', { loose: true }]);
|
||||
|
||||
const jestBabelConfig = {
|
||||
...babelConfig,
|
||||
presets: babelConfig.presets.map((preset) => {
|
||||
if (Array.isArray(preset) && formatWinPath(preset[0]).indexOf('@babel/preset-env') > -1) {
|
||||
return [preset[0], {
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
}];
|
||||
}
|
||||
return preset;
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports = babelJest.createTransformer(jestBabelConfig);
|
|
@ -1,8 +1,4 @@
|
|||
module.exports = {
|
||||
transform: {
|
||||
'^.+\\.(js|jsx|ts|tsx)$': './babelTransform.js',
|
||||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': 'build-scripts-config/lib/config/jest/fileTransform.js',
|
||||
},
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
transformIgnorePatterns: ['/node_modules/(?!core-js)/'],
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -1,22 +0,0 @@
|
|||
const babelJest = require('babel-jest');
|
||||
const getBabelConfig = require('build-scripts-config/lib/config/babel/index.js');
|
||||
const formatWinPath = require('build-scripts-config/lib/config/jest/formatWinPath');
|
||||
const babelConfig = getBabelConfig();
|
||||
|
||||
babelConfig.plugins.push(['@babel/plugin-proposal-class-properties', { loose: true }]);
|
||||
|
||||
const jestBabelConfig = {
|
||||
...babelConfig,
|
||||
presets: babelConfig.presets.map((preset) => {
|
||||
if (Array.isArray(preset) && formatWinPath(preset[0]).indexOf('@babel/preset-env') > -1) {
|
||||
return [preset[0], {
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
}];
|
||||
}
|
||||
return preset;
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports = babelJest.createTransformer(jestBabelConfig);
|
|
@ -4,10 +4,6 @@ const esModules = [].join('|');
|
|||
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
|
||||
|
||||
const jestConfig = {
|
||||
transform: {
|
||||
'^.+\\.(js|jsx|ts|tsx)$': './babelTransform.js',
|
||||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': 'build-scripts-config/lib/config/jest/fileTransform.js',
|
||||
},
|
||||
// transform: {
|
||||
// '^.+\\.[jt]sx?$': 'babel-jest',
|
||||
// // '^.+\\.(ts|tsx)$': 'ts-jest',
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -25,24 +25,6 @@ const releaseVersion = getVersion();
|
|||
|
||||
module.exports = ({ context, onGetWebpackConfig }) => {
|
||||
onGetWebpackConfig((config) => {
|
||||
['jsx', 'tsx'].forEach((rule) => {
|
||||
config.module
|
||||
.rule(rule)
|
||||
.exclude.clear()
|
||||
.add(/node_modules(?!(.+_component_demo|.+build-plugin-component))/)
|
||||
.end()
|
||||
.use('babel-loader')
|
||||
.tap((options) => {
|
||||
const { plugins = [] } = options;
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...plugins,
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
],
|
||||
};
|
||||
});
|
||||
});
|
||||
config.resolve
|
||||
.plugin('tsconfigpaths')
|
||||
.use(TsconfigPathsPlugin, [{
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -6,26 +6,6 @@ const { version } = lernaConfig;
|
|||
|
||||
module.exports = ({ context, onGetWebpackConfig }) => {
|
||||
onGetWebpackConfig((config) => {
|
||||
['jsx', 'tsx'].forEach((rule) => {
|
||||
config.module
|
||||
.rule(rule)
|
||||
.exclude.clear()
|
||||
.add(/node_modules(?!(.+_component_demo|.+build-plugin-component))/)
|
||||
.end()
|
||||
.use('babel-loader')
|
||||
.tap((options) => {
|
||||
const { plugins = [] } = options;
|
||||
console.log('plugins', plugins);
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...plugins,
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
],
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [
|
||||
{
|
||||
configFile: './tsconfig.json',
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
const esModules = [].join('|');
|
||||
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
|
||||
|
||||
const jestConfig = {
|
||||
// transform: {
|
||||
// '^.+\\.[jt]sx?$': 'babel-jest',
|
||||
// // '^.+\\.(ts|tsx)$': 'ts-jest',
|
||||
// // '^.+\\.(js|jsx)$': 'babel-jest',
|
||||
// },
|
||||
// testMatch: ['**/node-children.test.ts'],
|
||||
// testMatch: ['**/plugin-manager.test.ts'],
|
||||
// testMatch: ['**/history/history.test.ts'],
|
||||
// testMatch: ['**/document-model.test.ts'],
|
||||
// testMatch: ['**/prop.test.ts'],
|
||||
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
|
||||
transformIgnorePatterns: [
|
||||
`/node_modules/(?!${esModules})/`,
|
||||
],
|
||||
setupFiles: ['./tests/fixtures/unhandled-rejection.ts'],
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||
collectCoverage: false,
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.ts',
|
||||
'!src/**/*.d.ts',
|
||||
'!src/icons/**',
|
||||
'!src/locale/**',
|
||||
'!src/builtin-simulator/utils/**',
|
||||
'!src/plugin/sequencify.ts',
|
||||
'!src/document/node/exclusive-group.ts',
|
||||
'!src/document/node/props/value-to-source.ts',
|
||||
'!src/builtin-simulator/live-editing/live-editing.ts',
|
||||
'!src/designer/offset-observer.ts',
|
||||
'!src/designer/clipboard.ts',
|
||||
'!src/designer/scroller.ts',
|
||||
'!src/builtin-simulator/host.ts',
|
||||
'!**/node_modules/**',
|
||||
'!**/vendor/**',
|
||||
],
|
||||
};
|
||||
|
||||
// 只对本仓库内的 pkg 做 mapping
|
||||
jestConfig.moduleNameMapper = {};
|
||||
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
|
||||
|
||||
module.exports = jestConfig;
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -1,24 +1,5 @@
|
|||
module.exports = ({ onGetWebpackConfig }) => {
|
||||
onGetWebpackConfig((config) => {
|
||||
['jsx', 'tsx'].forEach((rule) => {
|
||||
config.module
|
||||
.rule(rule)
|
||||
.exclude.clear()
|
||||
.add(/node_modules(?!(.+_component_demo|.+build-plugin-component))/)
|
||||
.end()
|
||||
.use('babel-loader')
|
||||
.tap((options) => {
|
||||
const { plugins = [] } = options;
|
||||
console.log('plugins', plugins);
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...plugins,
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
],
|
||||
};
|
||||
});
|
||||
});
|
||||
config.performance.hints(false);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../../babel.config');
|
|
@ -1,24 +1,5 @@
|
|||
module.exports = ({ onGetWebpackConfig }) => {
|
||||
onGetWebpackConfig((config) => {
|
||||
['jsx', 'tsx'].forEach((rule) => {
|
||||
config.module
|
||||
.rule(rule)
|
||||
.exclude.clear()
|
||||
.add(/node_modules(?!(.+_component_demo|.+build-plugin-component))/)
|
||||
.end()
|
||||
.use('babel-loader')
|
||||
.tap((options) => {
|
||||
const { plugins = [] } = options;
|
||||
console.log('plugins', plugins);
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...plugins,
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
],
|
||||
};
|
||||
});
|
||||
});
|
||||
config.performance.hints(false);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue