-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
50 lines (48 loc) · 1.18 KB
/
Copy pathwebpack.config.js
File metadata and controls
50 lines (48 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* External dependencies
*/
const path = require( 'path' );
/**
* WordPress dependencies
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
/**
* Polyfill for the `react-jsx-runtime` script handle added in WordPress 6.6.
* Modern @wordpress/scripts builds declare this dependency; without it, editor
* scripts never load on WordPress 6.4–6.5 and blocks stay unregistered.
*
* Compiled after the main blocks config (`dependencies`) so `output.clean` from
* `@wordpress/scripts` cannot delete the polyfill asset in a parallel race.
*
* @see https://make.wordpress.org/core/2024/06/06/jsx-in-wordpress-6-6/
*/
const reactJSXRuntimePolyfill = {
name: 'react-jsx-runtime',
dependencies: [ 'blocks' ],
mode: defaultConfig.mode,
target: defaultConfig.target,
devtool: defaultConfig.devtool,
entry: {
'react-jsx-runtime': {
import: 'react/jsx-runtime',
},
},
output: {
filename: 'react-jsx-runtime.js',
path: path.resolve( __dirname, 'build' ),
library: {
name: 'ReactJSXRuntime',
type: 'window',
},
},
externals: {
react: 'React',
},
};
module.exports = [
{
...defaultConfig,
name: 'blocks',
},
reactJSXRuntimePolyfill,
];