@wordpress-flow/cli 1.0.22 → 1.0.24

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.
@@ -2002,7 +2002,11 @@ function parseBlockJsonFromSource(block) {
2002
2002
  };
2003
2003
  }
2004
2004
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2005
- const configModule = await import(webpackConfigPath);
2005
+ if (!fs.existsSync(webpackConfigPath)) {
2006
+ throw new Error(`Webpack config not found: ${webpackConfigPath}. Please check your wpblock.config.json settings.`);
2007
+ }
2008
+ delete __require.cache[__require.resolve(webpackConfigPath)];
2009
+ const configModule = __require(webpackConfigPath);
2006
2010
  const configFactory = configModule.default || configModule;
2007
2011
  const env = { entry: entryPoint, output: outputDir };
2008
2012
  const baseConfig = typeof configFactory === "function" ? configFactory(env) : configFactory;
package/dist/index.js CHANGED
@@ -114264,7 +114264,6 @@ import * as path9 from "path";
114264
114264
  import * as fs8 from "fs";
114265
114265
  import webpack from "webpack";
114266
114266
  var import_chalk3 = __toESM(require_source(), 1);
114267
-
114268
114267
  class WebpackRunner {
114269
114268
  async runBuild(entryPoint, outputDir, webpackConfigPath) {
114270
114269
  logger.debug(`Running webpack build for: ${entryPoint}`);
@@ -114284,7 +114283,8 @@ class WebpackRunner {
114284
114283
  }
114285
114284
  fs8.mkdirSync(outputDir, { recursive: true });
114286
114285
  try {
114287
- const configModule = await import(webpackConfigPath);
114286
+ delete __require.cache[__require.resolve(webpackConfigPath)];
114287
+ const configModule = __require(webpackConfigPath);
114288
114288
  const configFactory = configModule.default || configModule;
114289
114289
  const env2 = { entry: entryPoint, output: outputDir };
114290
114290
  const baseConfig = typeof configFactory === "function" ? configFactory(env2) : configFactory;
@@ -115173,7 +115173,8 @@ class BuildCommand {
115173
115173
  const config2 = this.configManager.getConfig();
115174
115174
  const blocksDir = this.configManager.resolvePath(options.blocksDir || config2.build?.blocksDir || "./theme/blocks");
115175
115175
  const outputDir = this.configManager.resolvePath(options.outputDir || config2.build?.outputDir || "./theme/dist");
115176
- const webpackConfig = this.configManager.resolvePath(options.webpackConfig || config2.build?.webpackConfig || "../packages/block/webpack.config.cjs");
115176
+ const defaultWebpackConfig = path14.join(path14.dirname(import.meta.dirname), "webpack.config.cjs");
115177
+ const webpackConfig = options.webpackConfig ? this.configManager.resolvePath(options.webpackConfig) : config2.build?.webpackConfig ? this.configManager.resolvePath(config2.build.webpackConfig) : defaultWebpackConfig;
115177
115178
  const scriptsPath = config2.build?.scriptsPath ? this.configManager.resolvePath(config2.build.scriptsPath) : undefined;
115178
115179
  logger.info(`Scanning blocks in: ${blocksDir}`);
115179
115180
  logger.info(`Output directory: ${outputDir}`);
@@ -115547,7 +115548,8 @@ class DevCommand {
115547
115548
  return;
115548
115549
  }
115549
115550
  const outputDir = this.configManager.resolvePath(config2.build?.outputDir || "./theme/dist");
115550
- const webpackConfig = this.configManager.resolvePath(config2.build?.webpackConfig || "../packages/block/webpack.config.cjs");
115551
+ const defaultWebpackConfig = path15.join(path15.dirname(import.meta.dirname), "webpack.config.cjs");
115552
+ const webpackConfig = config2.build?.webpackConfig ? this.configManager.resolvePath(config2.build.webpackConfig) : defaultWebpackConfig;
115551
115553
  for (let i2 = 0;i2 < blocksToBuild.length; i2++) {
115552
115554
  const block = blocksToBuild[i2];
115553
115555
  logger.step(i2 + 1, blocksToBuild.length, `Building block: ${block.name}`);
@@ -115777,7 +115779,7 @@ class BuildTemplatesCommand {
115777
115779
  // package.json
115778
115780
  var package_default = {
115779
115781
  name: "@wordpress-flow/cli",
115780
- version: "1.0.22",
115782
+ version: "1.0.24",
115781
115783
  type: "module",
115782
115784
  description: "TypeScript-based WordPress block creation system",
115783
115785
  main: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,58 @@
1
+ const defaultConfig = require("@wordpress/scripts/config/webpack.config");
2
+ const path = require("path");
3
+ const webpack = require("webpack");
4
+
5
+ module.exports = (env, argv) => {
6
+ const { entry, output } = env || {};
7
+
8
+ return {
9
+ ...defaultConfig,
10
+ entry: entry || "./src/index.js",
11
+ output: {
12
+ path: output || path.resolve(process.cwd(), "dist"),
13
+ filename: "index.js",
14
+ clean: false, // Don't clean the output directory
15
+ },
16
+ resolve: {
17
+ ...defaultConfig.resolve,
18
+ extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
19
+ },
20
+ module: {
21
+ ...defaultConfig.module,
22
+ rules: [
23
+ ...defaultConfig.module.rules,
24
+ {
25
+ test: /\.(ts|tsx)$/,
26
+ include: [
27
+ // Include TypeScript files from @wordpress-flow packages
28
+ /node_modules\/@wordpress-flow/,
29
+ // Include local TypeScript files
30
+ path.resolve(process.cwd()),
31
+ ],
32
+ use: [
33
+ {
34
+ loader: require.resolve("babel-loader"),
35
+ options: {
36
+ presets: [
37
+ require.resolve("@babel/preset-typescript"),
38
+ require.resolve("@babel/preset-react"),
39
+ ],
40
+ },
41
+ },
42
+ ],
43
+ },
44
+ ],
45
+ },
46
+ // Ensure WordPress externals are properly handled
47
+ externals: {
48
+ ...defaultConfig.externals,
49
+ },
50
+ plugins: [
51
+ ...defaultConfig.plugins,
52
+ // Define global variables for browser builds
53
+ new webpack.DefinePlugin({
54
+ SSR: false, // SSR is false for browser builds
55
+ }),
56
+ ],
57
+ };
58
+ };