chisel-scripts 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/index.js +102 -38
- package/lib/commands/wp-scripts.mjs +26 -12
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- INSERT-NEW-ENTRIES-HERE -->
|
|
4
4
|
|
|
5
|
+
## 2.1.0 (2025-12-15)
|
|
6
|
+
|
|
7
|
+
- add wp exp-modules support, update wp scripts, build file size limits, auto clear patterns cache, no ([728f566](https://github.com/xfiveco/generator-chisel/commit/728f566))
|
|
8
|
+
|
|
5
9
|
## 2.0.0 (2025-12-04)
|
|
6
10
|
|
|
7
11
|
- update chisel scripts peerDependencies ([7110a79](https://github.com/xfiveco/generator-chisel/commit/7110a79))
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const entry = {
|
|
35
|
-
...(blockMetadataFiles.length > 0 && baseConfig.entry()),
|
|
35
|
+
...(blockMetadataFiles.length > 0 && typeof baseConfig.entry === 'function' ? baseConfig.entry() : baseConfig.entry || {}),
|
|
36
36
|
...entriesFromFiles(scriptsFiles),
|
|
37
37
|
...entriesFromFiles(stylesFiles),
|
|
38
38
|
};
|
|
@@ -42,11 +42,10 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
42
42
|
|
|
43
43
|
return () =>
|
|
44
44
|
(url ||= (() => {
|
|
45
|
-
const {
|
|
45
|
+
const { execSync } = require('node:child_process');
|
|
46
46
|
try {
|
|
47
|
-
const stdout =
|
|
48
|
-
'npm',
|
|
49
|
-
['run', '--silent', 'wp', 'option', 'get', 'home'],
|
|
47
|
+
const stdout = execSync(
|
|
48
|
+
'npm run --silent wp option get home',
|
|
50
49
|
{
|
|
51
50
|
cwd: directory,
|
|
52
51
|
encoding: 'utf8',
|
|
@@ -60,44 +59,109 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
60
59
|
})());
|
|
61
60
|
})();
|
|
62
61
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
const performance = {
|
|
63
|
+
maxAssetSize: 512 * 1024,
|
|
64
|
+
maxEntrypointSize: 512 * 1024,
|
|
65
|
+
hints: isProduction ? 'warning' : false,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const isMultiConfig = Array.isArray(baseConfig);
|
|
69
|
+
|
|
70
|
+
const updatedConfig = isMultiConfig
|
|
71
|
+
? baseConfig.map((config, index) => {
|
|
72
|
+
let configEntry = {};
|
|
73
|
+
|
|
74
|
+
// Config 0: standard build - JS + styles
|
|
75
|
+
if (index === 0) {
|
|
76
|
+
configEntry = {
|
|
77
|
+
...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
|
|
78
|
+
...entriesFromFiles(scriptsFiles),
|
|
79
|
+
...entriesFromFiles(stylesFiles),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Config 1: ESM build - For block only
|
|
83
|
+
else if (index === 1) {
|
|
84
|
+
configEntry = {
|
|
85
|
+
...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
...config,
|
|
91
|
+
entry: configEntry,
|
|
92
|
+
resolve: {
|
|
93
|
+
...(config.resolve || {}),
|
|
94
|
+
alias: {
|
|
95
|
+
...((config.resolve && config.resolve.alias) || {}),
|
|
96
|
+
'~design$': pathMod.join(src, 'design'),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
performance: performance,
|
|
100
|
+
devServer: config.devServer && {
|
|
101
|
+
...config.devServer,
|
|
102
|
+
allowedHosts: [new URL(getUrl()).host],
|
|
103
|
+
...(process.env.CHISEL_PORT && {
|
|
104
|
+
host: '0.0.0.0',
|
|
105
|
+
port: Number(process.env.CHISEL_PORT) + 1,
|
|
106
|
+
client: {
|
|
107
|
+
...config.devServer.client,
|
|
108
|
+
overlay: {
|
|
109
|
+
errors: true,
|
|
110
|
+
warnings: false,
|
|
111
|
+
runtimeErrors: false,
|
|
112
|
+
},
|
|
113
|
+
webSocketURL: new URL(getUrl())
|
|
114
|
+
.toString()
|
|
115
|
+
.replace(process.env.CHISEL_PORT, Number(process.env.CHISEL_PORT) + 1),
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
71
118
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
119
|
+
optimization: {
|
|
120
|
+
...config.optimization,
|
|
121
|
+
...(!isProduction && { runtimeChunk: index === 0 ? 'single' : false }),
|
|
122
|
+
},
|
|
123
|
+
plugins: [
|
|
124
|
+
...config.plugins,
|
|
125
|
+
new CopyWebpackPlugin({
|
|
126
|
+
patterns: [
|
|
127
|
+
{
|
|
128
|
+
from: '**/*.twig',
|
|
129
|
+
context: 'src',
|
|
130
|
+
noErrorOnMissing: true,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
}),
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
})
|
|
137
|
+
: {
|
|
138
|
+
...baseConfig,
|
|
139
|
+
entry,
|
|
140
|
+
resolve: {
|
|
141
|
+
...(baseConfig.resolve || {}),
|
|
142
|
+
alias: {
|
|
143
|
+
...((baseConfig.resolve && baseConfig.resolve.alias) || {}),
|
|
144
|
+
'~design$': pathMod.join(src, 'design'),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
performance: performance,
|
|
148
|
+
devServer: baseConfig.devServer && {
|
|
149
|
+
...baseConfig.devServer,
|
|
75
150
|
allowedHosts: [new URL(getUrl()).host],
|
|
76
151
|
...(process.env.CHISEL_PORT && {
|
|
77
152
|
host: '0.0.0.0',
|
|
78
153
|
port: Number(process.env.CHISEL_PORT) + 1,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
client: {
|
|
91
|
-
...baseConfig.devServer.client,
|
|
92
|
-
webSocketURL: webSocketURL
|
|
93
|
-
.toString()
|
|
94
|
-
.replace(
|
|
95
|
-
process.env.CHISEL_PORT,
|
|
96
|
-
Number(process.env.CHISEL_PORT) + 1,
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
})(),
|
|
154
|
+
client: {
|
|
155
|
+
...baseConfig.devServer.client,
|
|
156
|
+
overlay: {
|
|
157
|
+
errors: true,
|
|
158
|
+
warnings: false,
|
|
159
|
+
runtimeErrors: false,
|
|
160
|
+
},
|
|
161
|
+
webSocketURL: new URL(getUrl())
|
|
162
|
+
.toString()
|
|
163
|
+
.replace(process.env.CHISEL_PORT, Number(process.env.CHISEL_PORT) + 1),
|
|
164
|
+
},
|
|
101
165
|
}),
|
|
102
166
|
},
|
|
103
167
|
optimization: {
|
|
@@ -20,14 +20,12 @@ function loadExtensions() {
|
|
|
20
20
|
export default function wpScripts(api) {
|
|
21
21
|
api.registerCommand(
|
|
22
22
|
'build',
|
|
23
|
-
(command) => command.description('build for production')
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// .option('--report', 'generate report to help analyze bundles content')
|
|
30
|
-
async () => {
|
|
23
|
+
(command) => command.description('build for production')
|
|
24
|
+
.option(
|
|
25
|
+
'--experimental-modules',
|
|
26
|
+
'do not enable experimental modules',
|
|
27
|
+
),
|
|
28
|
+
async (options) => {
|
|
31
29
|
process.env.NODE_ENV = 'production';
|
|
32
30
|
|
|
33
31
|
for (const extension of await loadExtensions()) {
|
|
@@ -36,7 +34,13 @@ export default function wpScripts(api) {
|
|
|
36
34
|
await extension.build(api);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
const args = ['wp-scripts', 'build'];
|
|
38
|
+
|
|
39
|
+
if (options.experimentalModules) { // Disabled by default. Enable with `--experimental-modules`.
|
|
40
|
+
args.push('--experimental-modules');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await runLocalWithExit(args, {
|
|
40
44
|
cwd: api.resolve(),
|
|
41
45
|
});
|
|
42
46
|
},
|
|
@@ -44,8 +48,12 @@ export default function wpScripts(api) {
|
|
|
44
48
|
|
|
45
49
|
api.registerCommand(
|
|
46
50
|
'start',
|
|
47
|
-
(command) => command.description('start development server')
|
|
48
|
-
|
|
51
|
+
(command) => command.description('start development server')
|
|
52
|
+
.option(
|
|
53
|
+
'--experimental-modules',
|
|
54
|
+
'do not enable experimental modules',
|
|
55
|
+
),
|
|
56
|
+
async (options) => {
|
|
49
57
|
process.env.NODE_ENV = 'development';
|
|
50
58
|
|
|
51
59
|
const extensions = await loadExtensions();
|
|
@@ -62,7 +70,13 @@ export default function wpScripts(api) {
|
|
|
62
70
|
await extension.start(api);
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
const args = ['wp-scripts', 'start', '--hot'];
|
|
74
|
+
|
|
75
|
+
if (options.experimentalModules) { // Disabled by default. Enable with `--experimental-modules`.
|
|
76
|
+
args.push('--experimental-modules');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
await runLocalWithExit(args, {
|
|
66
80
|
cwd: api.resolve(),
|
|
67
81
|
});
|
|
68
82
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chisel-scripts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Chisel scripts",
|
|
5
5
|
"bin": {
|
|
6
6
|
"chisel-scripts": "bin/chisel-scripts.js"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@wordpress/scripts": "^27.9.0 || ^31.0.0 || ^31.1.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "f5cb01894754a85b6842fa10412986bb745ea43a"
|
|
43
43
|
}
|