npm package diff
Package: @forge/bundler
Versions: 4.21.1-next.13 - 4.21.1-next.14
File: package/out/runtime.js
Index: package/out/runtime.js
===================================================================
--- package/out/runtime.js
+++ package/out/runtime.js
@@ -1,17 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.getNodeBundler = exports.SandboxBundler = void 0;
+exports.getNodeBundler = exports.userCodePath = exports.SandboxBundler = void 0;
const tslib_1 = require("tslib");
+const path_1 = tslib_1.__importDefault(require("path"));
+const promises_1 = tslib_1.__importDefault(require("fs/promises"));
const webpack_1 = tslib_1.__importDefault(require("webpack"));
var RawSource = webpack_1.default.sources.RawSource;
const cli_shared_1 = require("@forge/cli-shared");
-const path_1 = require("path");
const common_1 = require("./config/common");
const sandbox_1 = require("./config/sandbox");
const webpack_2 = require("./webpack");
const i18n_1 = require("@forge/i18n");
-const fs_1 = require("fs");
class SandboxBundler extends webpack_2.WebpackBundler {
constructor(logger) {
super(logger);
}
@@ -23,8 +23,12 @@
const NODE_RUNTIME_CODE_FILE = '__forge__.js';
const NODE_RUNTIME_BACKUP_WRAPPER_FILE = '__forge_wrapper__.cjs';
const NODE_RUNTIME_VERSION_FILE = 'runtime.json';
const NODE_WEBPACK_USER_CODE_DIR = 'bundled';
+function userCodePath(entryKey) {
+ return path_1.default.join(path_1.default.dirname(entryKey), NODE_WEBPACK_USER_CODE_DIR, path_1.default.basename(entryKey));
+}
+exports.userCodePath = userCodePath;
async function emitWrapperFiles(provider, entrypoints, emit, useSingleWrapper) {
const wrapper = await provider.getNodeRuntimeWrapper();
const loader = await provider.getNodeRuntimeLoader();
let entrypointScript;
@@ -46,10 +50,10 @@
await emit(NODE_RUNTIME_VERSION_FILE, JSON.stringify({ version: entrypointScript.version }, null, 2));
}
async function emitI18nFiles(i18nResourceBundle, emit) {
await Promise.all((0, cli_shared_1.listFilesInI18nResourceBundle)(i18nResourceBundle).map(async ([fileName, filePath]) => {
- const fileContent = await fs_1.promises.readFile(filePath);
- await emit((0, path_1.join)(i18n_1.I18N_BUNDLE_FOLDER_NAME, fileName), fileContent.toString());
+ const fileContent = await promises_1.default.readFile(filePath);
+ await emit(path_1.default.join(i18n_1.I18N_BUNDLE_FOLDER_NAME, fileName), fileContent.toString());
}));
}
class NodeBundler extends webpack_2.WebpackBundler {
wrapperProvider;
@@ -61,13 +65,9 @@
}
async getConfig(args) {
const webpackConfig = (0, common_1.getCommonWebpackConfig)(args);
if (!(await this.statsigReader.packageSingleWrapper())) {
- const newEntries = {};
- for (const [entryKey, entryPath] of Object.entries(webpackConfig.entry)) {
- newEntries[`${NODE_WEBPACK_USER_CODE_DIR}/${entryKey}`] = entryPath;
- }
- webpackConfig.entry = newEntries;
+ webpackConfig.entry = Object.fromEntries(Object.entries(webpackConfig.entry).map(([entryKey, entryPath]) => [userCodePath(entryKey), entryPath]));
}
webpackConfig.target = 'node18';
webpackConfig.output.filename = '[name].cjs';
webpackConfig.name = 'node-runtime';