@wordpress-flow/cli 1.0.25 → 1.0.26

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.
@@ -2005,11 +2005,21 @@ async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2005
2005
  if (!fs.existsSync(webpackConfigPath)) {
2006
2006
  throw new Error(`Webpack config not found: ${webpackConfigPath}. Please check your wpblock.config.json settings.`);
2007
2007
  }
2008
- delete __require.cache[__require.resolve(webpackConfigPath)];
2009
- const configModule = __require(webpackConfigPath);
2008
+ let configModule;
2009
+ try {
2010
+ delete __require.cache[__require.resolve(webpackConfigPath)];
2011
+ configModule = __require(webpackConfigPath);
2012
+ } catch (loadError) {
2013
+ throw new Error(`Failed to load webpack config from ${webpackConfigPath}: ${loadError.message}`);
2014
+ }
2010
2015
  const configFactory = configModule.default || configModule;
2011
2016
  const env = { entry: entryPoint, output: outputDir };
2012
- const baseConfig = typeof configFactory === "function" ? configFactory(env) : configFactory;
2017
+ let baseConfig;
2018
+ try {
2019
+ baseConfig = typeof configFactory === "function" ? configFactory(env) : configFactory;
2020
+ } catch (configError) {
2021
+ throw new Error(`Failed to execute webpack config factory: ${configError.message}`);
2022
+ }
2013
2023
  const config = {
2014
2024
  ...baseConfig,
2015
2025
  mode: "production",
@@ -2020,31 +2030,41 @@ async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2020
2030
  }
2021
2031
  };
2022
2032
  return new Promise((resolve2, reject) => {
2023
- webpack(config, (err, stats) => {
2024
- if (err) {
2025
- reject(new Error(`Webpack error: ${err.message}
2033
+ try {
2034
+ const compiler = webpack(config);
2035
+ compiler.run((err, stats) => {
2036
+ compiler.close((closeErr) => {
2037
+ if (closeErr) {
2038
+ console.error(`Webpack compiler close error: ${closeErr.message}`);
2039
+ }
2040
+ });
2041
+ if (err) {
2042
+ reject(new Error(`Webpack compilation error: ${err.message}
2026
2043
  Stack: ${err.stack}`));
2027
- return;
2028
- }
2029
- if (stats?.hasErrors()) {
2030
- const info = stats.toJson();
2031
- const errorMessages = info.errors?.map((e) => {
2032
- if (typeof e === "string")
2033
- return e;
2034
- return e.message || JSON.stringify(e);
2035
- }).join(`
2044
+ return;
2045
+ }
2046
+ if (!stats) {
2047
+ reject(new Error(`Webpack returned no stats object`));
2048
+ return;
2049
+ }
2050
+ if (stats.hasErrors()) {
2051
+ const info = stats.toJson();
2052
+ const errorMessages = info.errors?.map((e) => {
2053
+ if (typeof e === "string")
2054
+ return e;
2055
+ return e.message || JSON.stringify(e);
2056
+ }).join(`
2036
2057
  `) || "Unknown webpack error";
2037
- reject(new Error(`Webpack build errors:
2058
+ reject(new Error(`Webpack build errors:
2038
2059
  ${errorMessages}`));
2039
- return;
2040
- }
2041
- if (stats?.hasWarnings()) {
2042
- const info = stats.toJson();
2043
- console.warn(`Webpack warnings for ${outputDir}:`, info.warnings?.map((w) => w.message || w).join(`
2044
- `));
2045
- }
2046
- resolve2();
2047
- });
2060
+ return;
2061
+ }
2062
+ resolve2();
2063
+ });
2064
+ } catch (webpackError) {
2065
+ reject(new Error(`Failed to start webpack: ${webpackError.message}
2066
+ Stack: ${webpackError.stack}`));
2067
+ }
2048
2068
  });
2049
2069
  }
2050
2070
  function verifyBuildOutput(outputDir) {
package/dist/index.js CHANGED
@@ -115779,7 +115779,7 @@ class BuildTemplatesCommand {
115779
115779
  // package.json
115780
115780
  var package_default = {
115781
115781
  name: "@wordpress-flow/cli",
115782
- version: "1.0.25",
115782
+ version: "1.0.26",
115783
115783
  type: "module",
115784
115784
  description: "TypeScript-based WordPress block creation system",
115785
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.25",
3
+ "version": "1.0.26",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",