@wordpress-flow/cli 1.0.23 → 1.0.25
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/build/block-build-worker.js +18 -3
- package/dist/index.js +5 -3
- package/package.json +1 -1
- package/webpack.config.cjs +58 -0
|
@@ -2002,6 +2002,9 @@ function parseBlockJsonFromSource(block) {
|
|
|
2002
2002
|
};
|
|
2003
2003
|
}
|
|
2004
2004
|
async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
|
|
2005
|
+
if (!fs.existsSync(webpackConfigPath)) {
|
|
2006
|
+
throw new Error(`Webpack config not found: ${webpackConfigPath}. Please check your wpblock.config.json settings.`);
|
|
2007
|
+
}
|
|
2005
2008
|
delete __require.cache[__require.resolve(webpackConfigPath)];
|
|
2006
2009
|
const configModule = __require(webpackConfigPath);
|
|
2007
2010
|
const configFactory = configModule.default || configModule;
|
|
@@ -2019,15 +2022,27 @@ async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
|
|
|
2019
2022
|
return new Promise((resolve2, reject) => {
|
|
2020
2023
|
webpack(config, (err, stats) => {
|
|
2021
2024
|
if (err) {
|
|
2022
|
-
reject(err
|
|
2025
|
+
reject(new Error(`Webpack error: ${err.message}
|
|
2026
|
+
Stack: ${err.stack}`));
|
|
2023
2027
|
return;
|
|
2024
2028
|
}
|
|
2025
2029
|
if (stats?.hasErrors()) {
|
|
2026
2030
|
const info = stats.toJson();
|
|
2027
|
-
|
|
2028
|
-
|
|
2031
|
+
const errorMessages = info.errors?.map((e) => {
|
|
2032
|
+
if (typeof e === "string")
|
|
2033
|
+
return e;
|
|
2034
|
+
return e.message || JSON.stringify(e);
|
|
2035
|
+
}).join(`
|
|
2036
|
+
`) || "Unknown webpack error";
|
|
2037
|
+
reject(new Error(`Webpack build errors:
|
|
2038
|
+
${errorMessages}`));
|
|
2029
2039
|
return;
|
|
2030
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
|
+
}
|
|
2031
2046
|
resolve2();
|
|
2032
2047
|
});
|
|
2033
2048
|
});
|
package/dist/index.js
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
115782
|
+
version: "1.0.25",
|
|
115781
115783
|
type: "module",
|
|
115782
115784
|
description: "TypeScript-based WordPress block creation system",
|
|
115783
115785
|
main: "dist/index.js",
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|