Skip to content

Commit 3e3781b

Browse files
committed
build: cleaned up babel presets
1 parent 3e4957c commit 3e3781b

File tree

5 files changed

+260
-127
lines changed

5 files changed

+260
-127
lines changed

.config/externals.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ const externals = [
5050
lodash: 'lodash', // WP loads lodash already.
5151
stackable: 'stackable', // Our localized JS variable.
5252
fetch: 'fetch', // Used in our debugger sidebar.
53+
// react: 'wp.element', // Use the bundled React in Gutenberg. (not working see https://github.com/WordPress/gutenberg/issues/33674)
54+
'react-dom': 'wp.element', // Use the bundled ReactDom in Gutenberg.
5355
} );
5456

5557
module.exports = externals;

.config/rules.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,9 @@ module.exports = [
55
use: {
66
loader: 'babel-loader',
77
options: {
8-
// presets: ['es2015'],
98
presets: [ '@wordpress/babel-preset-default' ],
109
// Cache compilation results in ./node_modules/.cache/babel-loader/
1110
cacheDirectory: true,
12-
plugins: [
13-
'@babel/plugin-proposal-class-properties',
14-
'@babel/plugin-transform-destructuring',
15-
'@babel/plugin-proposal-object-rest-spread',
16-
'@babel/plugin-proposal-optional-chaining',
17-
[
18-
'@babel/plugin-transform-react-jsx',
19-
{
20-
pragma: 'wp.element.createElement',
21-
},
22-
]
23-
]
2411
}
2512
},
2613
resolve: {
@@ -36,7 +23,20 @@ module.exports = [
3623
},
3724
{
3825
test: /\.svg$/,
39-
use: ['@svgr/webpack'], // Settings are in .svgrrc
26+
// Settings are in .svgrrc
27+
use: [
28+
{
29+
loader: 'babel-loader', // Use our own babel-loader instead of the included one.
30+
options: {
31+
presets: [ '@wordpress/babel-preset-default' ],
32+
cacheDirectory: true,
33+
},
34+
},
35+
{
36+
loader: '@svgr/webpack',
37+
options: { babel: false },
38+
}
39+
],
4040
},
4141
{
4242
test: /\.(png|jpg|gif)$/,

babel.config.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@ module.exports = api => {
33

44
return {
55
presets: [
6-
[ '@babel/preset-env', { modules: false } ],
7-
'@babel/preset-react',
86
'@wordpress/babel-preset-default', // @see https://github.com/WordPress/gutenberg/tree/trunk/packages/babel-preset-default
97
],
10-
env: {
11-
test: {
12-
plugins: [
13-
'@babel/plugin-transform-modules-commonjs',
14-
'@babel/plugin-proposal-class-properties',
15-
'@babel/plugin-proposal-optional-chaining',
16-
],
17-
},
18-
},
198
}
209
}

0 commit comments

Comments
 (0)