2019-05-06 12:44:58 +02:00
|
|
|
const withTests = {
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{ shippedProposals: true, useBuiltIns: 'usage', corejs: '3', targets: { node: 'current' } },
|
|
|
|
],
|
|
|
|
],
|
|
|
|
plugins: [
|
2021-11-11 19:35:47 +11:00
|
|
|
'@storybook/babel-plugin-require-context-hook',
|
2019-05-06 12:44:58 +02:00
|
|
|
'babel-plugin-dynamic-import-node',
|
|
|
|
'@babel/plugin-transform-runtime',
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2021-05-17 16:54:08 +08:00
|
|
|
// type BabelMode = 'cjs' | 'esm' | 'modern';
|
|
|
|
|
|
|
|
const modules = process.env.BABEL_MODE === 'cjs' ? 'auto' : false;
|
2021-05-17 18:01:30 +08:00
|
|
|
|
|
|
|
// FIXME: optional chaining introduced in chrome 80, not supported by wepback4
|
|
|
|
// https://github.com/webpack/webpack/issues/10227#issuecomment-642734920
|
|
|
|
const targets = process.env.BABEL_MODE === 'modern' ? { chrome: '79' } : 'defaults';
|
2021-02-03 22:34:44 +08:00
|
|
|
|
2018-11-09 09:46:31 +01:00
|
|
|
module.exports = {
|
2019-11-14 18:43:44 +08:00
|
|
|
ignore: [
|
|
|
|
'./lib/codemod/src/transforms/__testfixtures__',
|
|
|
|
'./lib/postinstall/src/__testfixtures__',
|
|
|
|
],
|
2018-11-19 17:21:53 +01:00
|
|
|
presets: [
|
2021-02-03 22:34:44 +08:00
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
shippedProposals: true,
|
|
|
|
useBuiltIns: 'usage',
|
|
|
|
corejs: '3',
|
2021-05-17 16:54:08 +08:00
|
|
|
targets,
|
2021-02-03 22:34:44 +08:00
|
|
|
modules,
|
|
|
|
},
|
|
|
|
],
|
2018-12-28 01:39:01 +01:00
|
|
|
'@babel/preset-typescript',
|
2018-11-19 17:21:53 +01:00
|
|
|
'@babel/preset-react',
|
|
|
|
'@babel/preset-flow',
|
|
|
|
],
|
2018-11-09 09:46:31 +01:00
|
|
|
plugins: [
|
2019-04-04 19:51:28 +02:00
|
|
|
[
|
|
|
|
'@babel/plugin-proposal-decorators',
|
|
|
|
{
|
|
|
|
legacy: true,
|
|
|
|
},
|
|
|
|
],
|
2019-01-05 22:15:03 +01:00
|
|
|
['@babel/plugin-proposal-class-properties', { loose: true }],
|
2020-05-27 16:48:21 +02:00
|
|
|
['@babel/plugin-proposal-private-methods', { loose: true }],
|
2018-11-09 09:46:31 +01:00
|
|
|
'@babel/plugin-proposal-export-default-from',
|
2018-11-30 17:43:33 +01:00
|
|
|
'@babel/plugin-syntax-dynamic-import',
|
2019-03-02 20:33:20 +01:00
|
|
|
['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
|
2018-11-30 17:43:33 +01:00
|
|
|
'babel-plugin-macros',
|
2018-12-06 16:49:52 +01:00
|
|
|
['emotion', { sourceMap: true, autoLabel: true }],
|
2018-11-09 09:46:31 +01:00
|
|
|
],
|
|
|
|
env: {
|
2019-05-06 12:44:58 +02:00
|
|
|
test: withTests,
|
2018-11-09 09:46:31 +01:00
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
test: './examples/vue-kitchen-sink',
|
2020-05-25 18:56:33 +09:00
|
|
|
presets: ['@vue/babel-preset-jsx'],
|
2019-05-06 12:44:58 +02:00
|
|
|
env: {
|
|
|
|
test: withTests,
|
|
|
|
},
|
2018-11-09 09:46:31 +01:00
|
|
|
},
|
2019-02-04 20:12:47 +01:00
|
|
|
{
|
|
|
|
test: './lib',
|
|
|
|
presets: [
|
2021-02-03 22:34:44 +08:00
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
shippedProposals: true,
|
|
|
|
useBuiltIns: 'usage',
|
|
|
|
corejs: '3',
|
|
|
|
modules,
|
2021-05-17 16:54:08 +08:00
|
|
|
targets,
|
2021-02-03 22:34:44 +08:00
|
|
|
},
|
|
|
|
],
|
2019-02-04 20:12:47 +01:00
|
|
|
'@babel/preset-react',
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
|
|
|
|
'@babel/plugin-proposal-export-default-from',
|
|
|
|
'@babel/plugin-syntax-dynamic-import',
|
|
|
|
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
|
|
'babel-plugin-macros',
|
|
|
|
['emotion', { sourceMap: true, autoLabel: true }],
|
|
|
|
'babel-plugin-add-react-displayname',
|
|
|
|
],
|
2019-05-06 12:44:58 +02:00
|
|
|
env: {
|
|
|
|
test: withTests,
|
|
|
|
},
|
2019-02-04 20:12:47 +01:00
|
|
|
},
|
2018-11-09 09:46:31 +01:00
|
|
|
{
|
|
|
|
test: [
|
|
|
|
'./lib/node-logger',
|
2021-02-06 15:30:52 +01:00
|
|
|
'./lib/core',
|
|
|
|
'./lib/core-common',
|
|
|
|
'./lib/core-server',
|
|
|
|
'./lib/builder-webpack4',
|
|
|
|
'./lib/builder-webpack5',
|
2018-11-09 09:46:31 +01:00
|
|
|
'./lib/codemod',
|
|
|
|
'./addons/storyshots',
|
2019-07-20 21:48:30 +02:00
|
|
|
'**/src/server/**',
|
|
|
|
'**/src/bin/**',
|
2018-11-09 09:46:31 +01:00
|
|
|
],
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
2018-12-04 16:27:02 +01:00
|
|
|
shippedProposals: true,
|
|
|
|
useBuiltIns: 'usage',
|
2018-11-09 09:46:31 +01:00
|
|
|
targets: {
|
2021-02-03 22:34:44 +08:00
|
|
|
node: '10',
|
2018-11-09 09:46:31 +01:00
|
|
|
},
|
2021-02-03 22:34:44 +08:00
|
|
|
modules,
|
2019-04-26 17:46:58 +02:00
|
|
|
corejs: '3',
|
2018-11-09 09:46:31 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
2019-01-05 22:15:03 +01:00
|
|
|
plugins: [
|
2019-03-02 21:00:28 +01:00
|
|
|
'emotion',
|
2019-01-05 22:15:03 +01:00
|
|
|
'babel-plugin-macros',
|
2020-04-02 23:22:04 +02:00
|
|
|
'@babel/plugin-transform-arrow-functions',
|
|
|
|
'@babel/plugin-transform-shorthand-properties',
|
|
|
|
'@babel/plugin-transform-block-scoping',
|
|
|
|
'@babel/plugin-transform-destructuring',
|
2019-01-05 22:15:03 +01:00
|
|
|
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
|
|
'@babel/plugin-proposal-object-rest-spread',
|
|
|
|
'@babel/plugin-proposal-export-default-from',
|
|
|
|
],
|
2019-05-06 12:44:58 +02:00
|
|
|
env: {
|
|
|
|
test: withTests,
|
|
|
|
},
|
2018-11-09 09:46:31 +01:00
|
|
|
},
|
2021-02-03 22:34:44 +08:00
|
|
|
{
|
|
|
|
test: ['**/virtualModuleEntry.template.js'],
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
shippedProposals: true,
|
|
|
|
useBuiltIns: 'usage',
|
|
|
|
targets: {
|
|
|
|
node: '10',
|
|
|
|
},
|
|
|
|
corejs: '3',
|
|
|
|
modules: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
2018-11-09 09:46:31 +01:00
|
|
|
],
|
|
|
|
};
|