chisel-scripts 2.0.0 → 2.1.1
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 +8 -0
- package/index.js +103 -55
- package/lib/commands/wp-scripts.mjs +26 -12
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- INSERT-NEW-ENTRIES-HERE -->
|
|
4
4
|
|
|
5
|
+
## <small>2.1.1 (2025-12-16)</small>
|
|
6
|
+
|
|
7
|
+
- add wp interactivity api support, optimize css build, refactor webpack config ([319d822](https://github.com/xfiveco/generator-chisel/commit/319d822))
|
|
8
|
+
|
|
9
|
+
## 2.1.0 (2025-12-15)
|
|
10
|
+
|
|
11
|
+
- 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))
|
|
12
|
+
|
|
5
13
|
## 2.0.0 (2025-12-04)
|
|
6
14
|
|
|
7
15
|
- 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,63 +59,112 @@ function adjustWebpackConfig(baseConfig, directory) {
|
|
|
60
59
|
})());
|
|
61
60
|
})();
|
|
62
61
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...baseConfig.resolve.alias,
|
|
70
|
-
'~design$': pathMod.join(src, 'design'),
|
|
62
|
+
const preparedConfig = (config, index = null) => {
|
|
63
|
+
return {
|
|
64
|
+
...config,
|
|
65
|
+
output: {
|
|
66
|
+
...config.output,
|
|
67
|
+
clean: isProduction,
|
|
71
68
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
resolve: {
|
|
70
|
+
...(config.resolve || {}),
|
|
71
|
+
alias: {
|
|
72
|
+
...((config.resolve && config.resolve.alias) || {}),
|
|
73
|
+
'~design$': pathMod.join(src, 'design'),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
performance: {
|
|
77
|
+
maxAssetSize: 512 * 1024,
|
|
78
|
+
maxEntrypointSize: 512 * 1024,
|
|
79
|
+
hints: isProduction ? 'warning' : false,
|
|
80
|
+
},
|
|
81
|
+
devServer: config.devServer && {
|
|
82
|
+
...config.devServer,
|
|
83
|
+
allowedHosts: [new URL(getUrl()).host],
|
|
84
|
+
...(process.env.CHISEL_PORT && {
|
|
85
|
+
host: '0.0.0.0',
|
|
86
|
+
port: Number(process.env.CHISEL_PORT) + 1,
|
|
87
|
+
client: {
|
|
88
|
+
...config.devServer.client,
|
|
89
|
+
overlay: {
|
|
90
|
+
errors: true,
|
|
91
|
+
warnings: false,
|
|
92
|
+
runtimeErrors: false,
|
|
93
|
+
},
|
|
94
|
+
webSocketURL: new URL(getUrl())
|
|
95
|
+
.toString()
|
|
96
|
+
.replace(process.env.CHISEL_PORT, Number(process.env.CHISEL_PORT) + 1),
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
setupMiddlewares: (middlewares, devServer) => {
|
|
100
|
+
if (!devServer) {
|
|
101
|
+
return middlewares;
|
|
87
102
|
}
|
|
88
103
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
console.log(`🌐 Dev server ready at: ${getUrl()}`);
|
|
105
|
+
|
|
106
|
+
return middlewares;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
optimization: {
|
|
110
|
+
...config.optimization,
|
|
111
|
+
...(!isProduction && { runtimeChunk: index === 0 ? 'single' : false }),
|
|
112
|
+
},
|
|
113
|
+
plugins: [
|
|
114
|
+
...config.plugins,
|
|
115
|
+
new CopyWebpackPlugin({
|
|
116
|
+
patterns: [
|
|
117
|
+
{
|
|
118
|
+
from: '**/*.twig',
|
|
119
|
+
context: 'src',
|
|
120
|
+
noErrorOnMissing: true,
|
|
98
121
|
},
|
|
99
|
-
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
plugins: [
|
|
108
|
-
...baseConfig.plugins,
|
|
109
|
-
new CopyWebpackPlugin({
|
|
110
|
-
patterns: [
|
|
122
|
+
],
|
|
123
|
+
}),
|
|
124
|
+
],
|
|
125
|
+
module: {
|
|
126
|
+
...(config.module || {}),
|
|
127
|
+
rules: [
|
|
128
|
+
...(config.module?.rules || []),
|
|
111
129
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
noErrorOnMissing: true,
|
|
130
|
+
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
131
|
+
type: 'asset/resource', // Load as file, not base64 in css - for smaller css file size.
|
|
115
132
|
},
|
|
116
133
|
],
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const isMultiConfig = Array.isArray(baseConfig);
|
|
139
|
+
|
|
140
|
+
const updatedConfig = isMultiConfig
|
|
141
|
+
? baseConfig.map((config, index) => {
|
|
142
|
+
let configEntry = {};
|
|
143
|
+
|
|
144
|
+
// Config 0: standard build - JS + styles
|
|
145
|
+
if (index === 0) {
|
|
146
|
+
configEntry = {
|
|
147
|
+
...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
|
|
148
|
+
...entriesFromFiles(scriptsFiles),
|
|
149
|
+
...entriesFromFiles(stylesFiles),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Config 1: ESM build - For blocks only
|
|
153
|
+
else if (index === 1) {
|
|
154
|
+
configEntry = {
|
|
155
|
+
...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
...preparedConfig(config, index),
|
|
161
|
+
entry: configEntry,
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
: {
|
|
165
|
+
...preparedConfig(baseConfig),
|
|
166
|
+
entry,
|
|
167
|
+
}
|
|
120
168
|
|
|
121
169
|
return updatedConfig;
|
|
122
170
|
}
|
|
@@ -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.1",
|
|
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": "eeef8803f7213be257ef9a48b02a1dc1790d2409"
|
|
43
43
|
}
|