npm package diff

Package: @forge/bundler

Versions: 4.18.1-next.8-experimental-c7a7d36 - 4.19.0-next.11

File: package/out/config/common.js

Index: package/out/config/common.js
===================================================================
--- package/out/config/common.js
+++ package/out/config/common.js
@@ -1,12 +1,13 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.getCommonWebpackConfig = exports.getDevToolConfig = exports.resolveStubPath = exports.resolveModulePath = exports.getEntryPoints = void 0;
+exports.getCommonWebpackConfig = exports.geti18nRule = exports.getDevToolConfig = exports.resolveStubPath = exports.resolveModulePath = exports.getEntryPoints = void 0;
 const tslib_1 = require("tslib");
 const path_1 = require("path");
 const webpack_1 = tslib_1.__importDefault(require("webpack"));
 const text_1 = require("../text");
 const cli_shared_1 = require("@forge/cli-shared");
+const i18n_1 = require("@forge/i18n");
 const tsconfig_interactor_1 = require("../tsconfig-interactor");
 function getEntryPoints(handlers) {
     const entryPointMap = new Map();
     for (const { module, func } of handlers) {
@@ -37,8 +38,25 @@
     }
     return config.isDebugMode ? 'inline-source-map' : 'cheap-source-map';
 };
 exports.getDevToolConfig = getDevToolConfig;
+const geti18nRule = (i18nConfig) => {
+    const i18nResources = i18nConfig.resources || [];
+    const i18nResourcesMap = new Map(i18nResources.map(({ key, path }) => [(0, path_1.resolve)(path), key]));
+    const getFilename = ({ module: { resource: i18nResourcePath } }) => {
+        const i18nResourceKey = i18nResourcesMap.get(i18nResourcePath);
+        return (0, path_1.join)(i18n_1.I18N_BUNDLE_FOLDER_NAME, `${i18nResourceKey}.json`);
+    };
+    return {
+        test: /\.json$/i,
+        include: Array.from(i18nResourcesMap.keys()),
+        type: 'asset/resource',
+        generator: {
+            filename: getFilename
+        }
+    };
+};
+exports.geti18nRule = geti18nRule;
 const getCommonWebpackConfig = (entrypoints, config) => {
     if (!require.main) {
         throw new Error(text_1.Text.noExecutableFile);
     }