@atomicsmash/compiler 2.0.0-beta.3 → 2.0.0-beta.4

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.
@@ -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;CA4JxB"}
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"}
@@ -90,11 +90,13 @@ export class BlocksPlugin {
90
90
  blocksManifest[blockName] = newBlockJson;
91
91
  });
92
92
  }
93
- const phpContent = `<?php
94
- // This file is generated. Do not modify it manually.
95
- return ${printer(blocksManifest)};
96
- `;
97
- await writeFile(`${compilation.outputOptions.path}${pathSeparator}blocks${pathSeparator}blocks-manifest.php`, phpContent);
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
- const compiler = webpack(await defaultConfig({ ...argv }));
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 | webpack.ProgressPlugin | WebpackAssetsManifest | BundleAnalyzerPlugin | webpack.DefinePlugin)[];
116
+ plugins: (BlocksPlugin | DependencyExtractionWebpackPlugin | CopyPlugin | SVGSpritemapPlugin | import("vue-loader").VueLoaderPlugin | WebpackAssetsManifest | BundleAnalyzerPlugin | webpack.DefinePlugin)[];
121
117
  optimization: {
122
118
  minimizer: EsbuildPlugin[];
123
119
  };
@@ -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,GAAG,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA8L6B,QAAQ;;;;;;;;;;;qCAeX,QAAQ;;;;;;;;;;sCA7PrB,CAAC;;;;;;;;;;;;;;;;;;;;;GA4bd"}
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,GAAG,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAyL0B,QAAQ;;;;;;;;;;;qCAaR,QAAQ;;;;;;;;;;sCAlPrB,CAAC;;;;;;;;;;;;;;;;;;;;;GA0ad"}
package/dist/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 (argv.experimentalBlocksSupport && file.includes("block.json")) {
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
- ...(argv.experimentalBlocksSupport
117
- ? [`${srcFolder}/blocks/**/block.json.ts`]
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.experimentalBlocksSupport
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 } = argv.experimentalBlocksSupport
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
- ...(argv.experimentalBlocksSupport
183
- ? [
184
- {
185
- test: /block\.json\.ts$/,
186
- type: "asset/resource",
187
- generator: {
188
- filename: (pathData) => relative(srcFolder, pathData.filename ?? "").slice(0, -3),
189
- },
190
- use: {
191
- loader: resolvePath(import.meta.dirname, "./BlocksLoader.js"),
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,
@@ -357,19 +347,12 @@ export async function config(options) {
357
347
  new DependencyExtractionWebpackPlugin({
358
348
  combineAssets: true,
359
349
  // Blocks plugin converts this to php, but it must be output as json here.
360
- ...(argv.experimentalBlocksSupport
361
- ? {
362
- outputFormat: "json",
363
- combinedOutputFile: "wordpress-assets-info.json",
364
- }
365
- : {
366
- outputFormat: "php",
367
- combinedOutputFile: "wordpress-assets-info.php",
368
- }),
350
+ outputFormat: "json",
351
+ combinedOutputFile: "wordpress-assets-info.json",
369
352
  }),
370
353
  // Support Vue files if vue-loader is present
371
354
  ...vueConfig.plugin,
372
- ...(argv.experimentalBlocksSupport ? [new BlocksPlugin(srcFolder)] : []),
355
+ new BlocksPlugin(srcFolder),
373
356
  new webpack.DefinePlugin({ ...vueConfig.globals }),
374
357
  ],
375
358
  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.3",
4
+ "version": "2.0.0-beta.4",
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.5"
84
+ "@atomicsmash/cli": "^9.0.0-beta.6"
85
85
  }
86
86
  }