@atomicsmash/compiler 2.0.0-beta.3 → 2.0.0-beta.5
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/dist/BlocksPlugin.d.ts.map +1 -1
- package/dist/BlocksPlugin.js +7 -5
- package/dist/cli.js +4 -1
- package/dist/config.d.ts +1 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -39
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksPlugin.d.ts","sourceRoot":"","sources":["../src/BlocksPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAS/D,qBAAa,YAAa,YAAW,qBAAqB;IACzD,UAAU,SAAkB;IAC5B,SAAS,EAAE,MAAM,CAAC;gBAEN,SAAS,EAAE,MAAM;IAI7B,KAAK,CAAC,QAAQ,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"BlocksPlugin.d.ts","sourceRoot":"","sources":["../src/BlocksPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAS/D,qBAAa,YAAa,YAAW,qBAAqB;IACzD,UAAU,SAAkB;IAC5B,SAAS,EAAE,MAAM,CAAC;gBAEN,SAAS,EAAE,MAAM;IAI7B,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA8JxB"}
|
package/dist/BlocksPlugin.js
CHANGED
|
@@ -90,11 +90,13 @@ export class BlocksPlugin {
|
|
|
90
90
|
blocksManifest[blockName] = newBlockJson;
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
if (Object.keys(blocksManifest).length > 0) {
|
|
94
|
+
const phpContent = `<?php
|
|
95
|
+
// This file is generated. Do not modify it manually.
|
|
96
|
+
return ${printer(blocksManifest)};
|
|
97
|
+
`;
|
|
98
|
+
await writeFile(`${compilation.outputOptions.path}${pathSeparator}blocks${pathSeparator}blocks-manifest.php`, phpContent);
|
|
99
|
+
}
|
|
98
100
|
await writeFile(`${compilation.outputOptions.path}${pathSeparator}wordpress-assets-info.php`, `<?php return ${json2php(wordpressAssets)};\n`);
|
|
99
101
|
await deleteFile(wordpressAssetsFilePath);
|
|
100
102
|
});
|
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
29
29
|
boolean: true,
|
|
30
30
|
default: false,
|
|
31
31
|
describe: "Enable experimental support for WordPress blocks compilation.",
|
|
32
|
+
deprecate: "Blocks support is enabled by default now. You can remove this option from your command.",
|
|
32
33
|
},
|
|
33
34
|
excludeBlocks: {
|
|
34
35
|
array: true,
|
|
@@ -39,7 +40,9 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
39
40
|
})
|
|
40
41
|
.showHelpOnFail(false, "Specify --help for available options")
|
|
41
42
|
.parse();
|
|
42
|
-
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Experimental option.
|
|
44
|
+
const { experimentalBlocksSupport, ...compilerOptions } = argv;
|
|
45
|
+
const compiler = webpack(await defaultConfig({ ...compilerOptions }));
|
|
43
46
|
if (argv.watch) {
|
|
44
47
|
const watching = compiler.watch({
|
|
45
48
|
// Example
|
package/dist/config.d.ts
CHANGED
|
@@ -27,10 +27,6 @@ export declare function config(options: {
|
|
|
27
27
|
* See a report of the generated bundle once built.
|
|
28
28
|
*/
|
|
29
29
|
analyse?: boolean | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Enable experimental support for WordPress blocks compilation.
|
|
32
|
-
*/
|
|
33
|
-
experimentalBlocksSupport?: boolean | undefined;
|
|
34
30
|
/**
|
|
35
31
|
* A comma separated list of the folder names of blocks to exclude from compilation. Requires experimental blocks support.
|
|
36
32
|
*/
|
|
@@ -117,7 +113,7 @@ export declare function config(options: {
|
|
|
117
113
|
})[];
|
|
118
114
|
})[];
|
|
119
115
|
};
|
|
120
|
-
plugins: (BlocksPlugin | DependencyExtractionWebpackPlugin | CopyPlugin | SVGSpritemapPlugin | import("vue-loader").VueLoaderPlugin |
|
|
116
|
+
plugins: (BlocksPlugin | DependencyExtractionWebpackPlugin | CopyPlugin | SVGSpritemapPlugin | import("vue-loader").VueLoaderPlugin | WebpackAssetsManifest | BundleAnalyzerPlugin | webpack.DefinePlugin)[];
|
|
121
117
|
optimization: {
|
|
122
118
|
minimizer: EsbuildPlugin[];
|
|
123
119
|
};
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAe,MAAM,SAAS,CAAC;AAUpE,OAAO,iCAAiC,MAAM,iDAAiD,CAAC;AAEhG,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAsB,MAAM,CAAC,OAAO,EAAE;IACrC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,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/config.js
CHANGED
|
@@ -21,7 +21,6 @@ export async function config(options) {
|
|
|
21
21
|
const argv = {
|
|
22
22
|
watch: false,
|
|
23
23
|
analyse: false,
|
|
24
|
-
experimentalBlocksSupport: false,
|
|
25
24
|
excludeBlocks: ["__TEMPLATE__"],
|
|
26
25
|
...options,
|
|
27
26
|
};
|
|
@@ -88,7 +87,7 @@ export async function config(options) {
|
|
|
88
87
|
},
|
|
89
88
|
exclude: (file) => {
|
|
90
89
|
// Exclude all block.json.ts files (handled by a separate loader).
|
|
91
|
-
if (
|
|
90
|
+
if (file.includes("block.json")) {
|
|
92
91
|
return true;
|
|
93
92
|
}
|
|
94
93
|
// Exclude node_modules files from transpilation unless they are vue files and the vue-loader is present
|
|
@@ -113,9 +112,8 @@ export async function config(options) {
|
|
|
113
112
|
// Set the environment mode from NODE_ENV.
|
|
114
113
|
mode: MODE,
|
|
115
114
|
entry: await glob([
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
: []),
|
|
115
|
+
// Parse all block json typescript files in the blocks folder.
|
|
116
|
+
`${srcFolder}/blocks/**/block.json.ts`,
|
|
119
117
|
// Parse all direct children of the JS folder, as long as they are JS & TS files
|
|
120
118
|
`${srcFolder}/scripts/*.{js,ts,jsx,tsx}`,
|
|
121
119
|
// Parse all direct children of the CSS folder, as long as they are CSS files
|
|
@@ -123,13 +121,9 @@ export async function config(options) {
|
|
|
123
121
|
// Parse all nested children of the CSS folder, as long as they are non-partial SCSS files
|
|
124
122
|
`${srcFolder}/styles/**/[^_]*.s[ac]ss`,
|
|
125
123
|
], {
|
|
126
|
-
ignore: argv.
|
|
127
|
-
? argv.excludeBlocks.map((blockName) => `${srcFolder}/blocks/**/${blockName}/block.json.ts`)
|
|
128
|
-
: [],
|
|
124
|
+
ignore: argv.excludeBlocks.map((blockName) => `${srcFolder}/blocks/**/${blockName}/block.json.ts`),
|
|
129
125
|
}).then(async (paths) => {
|
|
130
|
-
const { restOfPaths, entryPoints } =
|
|
131
|
-
? await getBlocksAssetsEntryPoints(paths, {}, srcFolder)
|
|
132
|
-
: { restOfPaths: paths, entryPoints: {} };
|
|
126
|
+
const { restOfPaths, entryPoints } = await getBlocksAssetsEntryPoints(paths, {}, srcFolder);
|
|
133
127
|
restOfPaths.forEach((path) => {
|
|
134
128
|
const entryName = path.replace(srcFolder, "");
|
|
135
129
|
entryPoints[entryName] = {
|
|
@@ -179,20 +173,16 @@ export async function config(options) {
|
|
|
179
173
|
resourceQuery: (value) => !value.includes("vue"),
|
|
180
174
|
...getEsBuildLoaderSetup("default"),
|
|
181
175
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
]
|
|
195
|
-
: []),
|
|
176
|
+
{
|
|
177
|
+
test: /block\.json\.ts$/,
|
|
178
|
+
type: "asset/resource",
|
|
179
|
+
generator: {
|
|
180
|
+
filename: (pathData) => relative(srcFolder, pathData.filename ?? "").slice(0, -3),
|
|
181
|
+
},
|
|
182
|
+
use: {
|
|
183
|
+
loader: resolvePath(import.meta.dirname, "./BlocksLoader.js"),
|
|
184
|
+
},
|
|
185
|
+
},
|
|
196
186
|
// Transpile SCSS files and run the result through postcss
|
|
197
187
|
{
|
|
198
188
|
test: /\.s[ac]ss$/i,
|
|
@@ -292,7 +282,7 @@ export async function config(options) {
|
|
|
292
282
|
},
|
|
293
283
|
plugins: [
|
|
294
284
|
// Output progress information when compiling
|
|
295
|
-
new webpack.ProgressPlugin(),
|
|
285
|
+
// new webpack.ProgressPlugin(),
|
|
296
286
|
// Generate a manifest file of assets to make it possible to target fingerprinted files
|
|
297
287
|
new WebpackAssetsManifest({
|
|
298
288
|
writeToDisk: true,
|
|
@@ -305,10 +295,13 @@ export async function config(options) {
|
|
|
305
295
|
entry.key === "wordpress-assets-info.php" ||
|
|
306
296
|
entry.key.endsWith(".map") ||
|
|
307
297
|
entry.key.startsWith("fonts") ||
|
|
308
|
-
entry.key.startsWith("images")
|
|
309
|
-
entry.key === "spritemap.svg") {
|
|
298
|
+
entry.key.startsWith("images")) {
|
|
310
299
|
return false;
|
|
311
300
|
}
|
|
301
|
+
if (entry.key === "spritemap.svg") {
|
|
302
|
+
entry.key = "icons/sprite.svg";
|
|
303
|
+
return entry;
|
|
304
|
+
}
|
|
312
305
|
if (entry.key.startsWith("/")) {
|
|
313
306
|
entry.key = entry.key.slice(1);
|
|
314
307
|
}
|
|
@@ -325,7 +318,7 @@ export async function config(options) {
|
|
|
325
318
|
...((await glob(`${srcFolder}/icons/*.svg`)).length
|
|
326
319
|
? [
|
|
327
320
|
new SVGSpritemapPlugin(`${srcFolder}/icons/*.svg`, {
|
|
328
|
-
output: { filename: "icons/sprite.svg" },
|
|
321
|
+
output: { filename: "icons/sprite.[contenthash].svg" },
|
|
329
322
|
sprite: { prefix: "", generate: { title: false } },
|
|
330
323
|
}),
|
|
331
324
|
]
|
|
@@ -357,19 +350,12 @@ export async function config(options) {
|
|
|
357
350
|
new DependencyExtractionWebpackPlugin({
|
|
358
351
|
combineAssets: true,
|
|
359
352
|
// Blocks plugin converts this to php, but it must be output as json here.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
outputFormat: "json",
|
|
363
|
-
combinedOutputFile: "wordpress-assets-info.json",
|
|
364
|
-
}
|
|
365
|
-
: {
|
|
366
|
-
outputFormat: "php",
|
|
367
|
-
combinedOutputFile: "wordpress-assets-info.php",
|
|
368
|
-
}),
|
|
353
|
+
outputFormat: "json",
|
|
354
|
+
combinedOutputFile: "wordpress-assets-info.json",
|
|
369
355
|
}),
|
|
370
356
|
// Support Vue files if vue-loader is present
|
|
371
357
|
...vueConfig.plugin,
|
|
372
|
-
|
|
358
|
+
new BlocksPlugin(srcFolder),
|
|
373
359
|
new webpack.DefinePlugin({ ...vueConfig.globals }),
|
|
374
360
|
],
|
|
375
361
|
optimization: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicsmash/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.5",
|
|
5
5
|
"description": "A universal compiler for all Atomic Smash projects.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cli",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"node": "^20 || >=22"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@atomicsmash/cli": "^9.0.0-beta.
|
|
84
|
+
"@atomicsmash/cli": "^9.0.0-beta.6"
|
|
85
85
|
}
|
|
86
86
|
}
|