chore: fix babel config (#2714)
This commit is contained in:
parent
9076530238
commit
afbc15d59b
154
babel.config.js
154
babel.config.js
@ -7,80 +7,81 @@ const isESM = process.env.NODE_ENV === 'esm';
|
|||||||
|
|
||||||
console.log('Build Package:', path.basename(process.cwd()));
|
console.log('Build Package:', path.basename(process.cwd()));
|
||||||
|
|
||||||
|
const defaultPlugins = [
|
||||||
|
'lodash',
|
||||||
|
[
|
||||||
|
'babel-plugin-transform-builtin-extend',
|
||||||
|
{
|
||||||
|
globals: ['Error'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'transform-export-extensions',
|
||||||
|
'@babel/plugin-proposal-class-properties',
|
||||||
|
'@babel/plugin-proposal-object-rest-spread',
|
||||||
|
'@babel/plugin-proposal-export-default-from',
|
||||||
|
[
|
||||||
|
'module-resolver',
|
||||||
|
isESM
|
||||||
|
? {
|
||||||
|
root: ['./src'],
|
||||||
|
alias: {
|
||||||
|
coreSrc: './src',
|
||||||
|
Actions: './src/actions',
|
||||||
|
App: './src/components/App',
|
||||||
|
Collection: './src/components/Collection',
|
||||||
|
Constants: './src/constants',
|
||||||
|
Editor: './src/components/Editor',
|
||||||
|
EditorWidgets: './src/components/EditorWidgets',
|
||||||
|
Formats: './src/formats',
|
||||||
|
Integrations: './src/integrations',
|
||||||
|
Lib: './src/lib',
|
||||||
|
MediaLibrary: './src/components/MediaLibrary',
|
||||||
|
Reducers: './src/reducers',
|
||||||
|
ReduxStore: './src/redux',
|
||||||
|
Routing: './src/routing',
|
||||||
|
UI: './src/components/UI',
|
||||||
|
Workflow: './src/components/Workflow',
|
||||||
|
ValueObjects: './src/valueObjects',
|
||||||
|
localforage: 'localforage',
|
||||||
|
redux: 'redux',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
root: path.join(__dirname, 'packages/netlify-cms-core/src/components'),
|
||||||
|
alias: {
|
||||||
|
coreSrc: path.join(__dirname, 'packages/netlify-cms-core/src'),
|
||||||
|
Actions: path.join(__dirname, 'packages/netlify-cms-core/src/actions/'),
|
||||||
|
Constants: path.join(__dirname, 'packages/netlify-cms-core/src/constants/'),
|
||||||
|
Formats: path.join(__dirname, 'packages/netlify-cms-core/src/formats/'),
|
||||||
|
Integrations: path.join(__dirname, 'packages/netlify-cms-core/src/integrations/'),
|
||||||
|
Lib: path.join(__dirname, 'packages/netlify-cms-core/src/lib/'),
|
||||||
|
Reducers: path.join(__dirname, 'packages/netlify-cms-core/src/reducers/'),
|
||||||
|
ReduxStore: path.join(__dirname, 'packages/netlify-cms-core/src/redux/'),
|
||||||
|
Routing: path.join(__dirname, 'packages/netlify-cms-core/src/routing/'),
|
||||||
|
ValueObjects: path.join(__dirname, 'packages/netlify-cms-core/src/valueObjects/'),
|
||||||
|
localforage: 'localforage',
|
||||||
|
redux: 'redux',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
const presets = () => {
|
const presets = () => {
|
||||||
return ['@babel/preset-react', '@babel/preset-env'];
|
return ['@babel/preset-react', '@babel/preset-env'];
|
||||||
};
|
};
|
||||||
|
|
||||||
const plugins = () => {
|
const plugins = () => {
|
||||||
const defaultPlugins = [
|
|
||||||
'lodash',
|
|
||||||
[
|
|
||||||
'babel-plugin-transform-builtin-extend',
|
|
||||||
{
|
|
||||||
globals: ['Error'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'transform-export-extensions',
|
|
||||||
'@babel/plugin-proposal-class-properties',
|
|
||||||
'@babel/plugin-proposal-object-rest-spread',
|
|
||||||
'@babel/plugin-proposal-export-default-from',
|
|
||||||
[
|
|
||||||
'emotion',
|
|
||||||
{
|
|
||||||
sourceMap: true,
|
|
||||||
autoLabel: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'module-resolver',
|
|
||||||
isESM
|
|
||||||
? {
|
|
||||||
root: ['./src'],
|
|
||||||
alias: {
|
|
||||||
coreSrc: './src',
|
|
||||||
Actions: './src/actions',
|
|
||||||
App: './src/components/App',
|
|
||||||
Collection: './src/components/Collection',
|
|
||||||
Constants: './src/constants',
|
|
||||||
Editor: './src/components/Editor',
|
|
||||||
EditorWidgets: './src/components/EditorWidgets',
|
|
||||||
Formats: './src/formats',
|
|
||||||
Integrations: './src/integrations',
|
|
||||||
Lib: './src/lib',
|
|
||||||
MediaLibrary: './src/components/MediaLibrary',
|
|
||||||
Reducers: './src/reducers',
|
|
||||||
ReduxStore: './src/redux',
|
|
||||||
Routing: './src/routing',
|
|
||||||
UI: './src/components/UI',
|
|
||||||
Workflow: './src/components/Workflow',
|
|
||||||
ValueObjects: './src/valueObjects',
|
|
||||||
localforage: 'localforage',
|
|
||||||
redux: 'redux',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
root: path.join(__dirname, 'packages/netlify-cms-core/src/components'),
|
|
||||||
alias: {
|
|
||||||
coreSrc: path.join(__dirname, 'packages/netlify-cms-core/src'),
|
|
||||||
Actions: path.join(__dirname, 'packages/netlify-cms-core/src/actions/'),
|
|
||||||
Constants: path.join(__dirname, 'packages/netlify-cms-core/src/constants/'),
|
|
||||||
Formats: path.join(__dirname, 'packages/netlify-cms-core/src/formats/'),
|
|
||||||
Integrations: path.join(__dirname, 'packages/netlify-cms-core/src/integrations/'),
|
|
||||||
Lib: path.join(__dirname, 'packages/netlify-cms-core/src/lib/'),
|
|
||||||
Reducers: path.join(__dirname, 'packages/netlify-cms-core/src/reducers/'),
|
|
||||||
ReduxStore: path.join(__dirname, 'packages/netlify-cms-core/src/redux/'),
|
|
||||||
Routing: path.join(__dirname, 'packages/netlify-cms-core/src/routing/'),
|
|
||||||
ValueObjects: path.join(__dirname, 'packages/netlify-cms-core/src/valueObjects/'),
|
|
||||||
localforage: 'localforage',
|
|
||||||
redux: 'redux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (isESM) {
|
if (isESM) {
|
||||||
return [
|
return [
|
||||||
...defaultPlugins,
|
...defaultPlugins,
|
||||||
|
[
|
||||||
|
'emotion',
|
||||||
|
{
|
||||||
|
sourceMap: true,
|
||||||
|
autoLabel: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'transform-define',
|
'transform-define',
|
||||||
{
|
{
|
||||||
@ -121,10 +122,29 @@ const plugins = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isProduction) {
|
if (!isProduction) {
|
||||||
defaultPlugins.push('react-hot-loader/babel');
|
return [
|
||||||
|
...defaultPlugins,
|
||||||
|
[
|
||||||
|
'emotion',
|
||||||
|
{
|
||||||
|
sourceMap: true,
|
||||||
|
autoLabel: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'react-hot-loader/babel',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultPlugins;
|
return [
|
||||||
|
...defaultPlugins,
|
||||||
|
[
|
||||||
|
'emotion',
|
||||||
|
{
|
||||||
|
sourceMap: true,
|
||||||
|
autoLabel: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user