@forge/bundler

6.1.23-next.56.1.23-next.6
out/webpack.js
~out/webpack.jsModified
+10−5
Index: package/out/webpack.js
===================================================================
--- package/out/webpack.js
+++ package/out/webpack.js
@@ -6,8 +6,9 @@
 const webpack_1 = tslib_1.__importDefault(require("webpack"));
 const cli_shared_1 = require("@forge/cli-shared");
 const metadata_1 = require("./metadata");
 const text_1 = require("./text");
+const types_1 = require("./types");
 function handleWebpackCompilationResult(logger, err, stats) {
     if (err) {
         throw err;
     }
@@ -119,14 +120,18 @@
             });
         });
     }
     async bundle(args) {
-        const config = await this.getConfig(args);
-        return await this.runCompiler(args, config);
+        const configs = await this.getConfigs(args);
+        const outputs = await Promise.all(configs.map((cfg) => this.runCompiler(args, cfg)));
+        const [primary, ...rest] = outputs;
+        const metadata = rest.reduce((acc, output) => (output.metadata ? (0, types_1.mergeMetadata)(acc, output.metadata) : acc), primary.metadata ?? (0, types_1.emptyMetadata)());
+        return { outputDir: primary.outputDir, metadata };
     }
     async watch(args, watch) {
-        const config = await this.getConfig(args);
-        const compiler = getCompiler(config);
+        const configs = await this.getConfigs(args);
+        const targetConfig = configs[configs.length - 1];
+        const compiler = getCompiler(targetConfig);
         let isFirstRun = true;
         compiler.hooks.watchRun.tapAsync('watchRun', async (_, watchRunCallback) => {
             if (!isFirstRun) {
                 await watch.onBuildWillStart();
@@ -137,9 +142,9 @@
             const watching = compiler.watch({ poll: 1000 }, async (compilerError, stats) => {
                 try {
                     handleWebpackCompilationResult(this.logger, compilerError, stats);
                     this.logger.info(cli_shared_1.LogColor.trace(args.successMessage));
-                    const result = await this.getOutput(args, config, stats);
+                    const result = await this.getOutput(args, targetConfig, stats);
                     if (isFirstRun) {
                         isFirstRun = false;
                         resolve({ result, stop: () => watching.close(() => void 0) });
                     }