@forge/bundler 4.1.1-next.8 → 4.2.0
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/CHANGELOG.md +45 -0
- package/README.md +82 -16
- package/out/config/common.d.ts +25 -0
- package/out/config/common.d.ts.map +1 -0
- package/out/config/common.js +131 -0
- package/out/{bundler-config/nativeui-webpack-config.d.ts → config/nativeui.d.ts} +3 -3
- package/out/config/nativeui.d.ts.map +1 -0
- package/out/{bundler-config/nativeui-webpack-config.js → config/nativeui.js} +0 -0
- package/out/config/node.d.ts +4 -0
- package/out/config/node.d.ts.map +1 -0
- package/out/config/node.js +38 -0
- package/out/config/sandbox.d.ts +4 -0
- package/out/config/sandbox.d.ts.map +1 -0
- package/out/config/sandbox.js +106 -0
- package/out/index.d.ts +3 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -5
- package/out/{console.d.ts → stubs/console.d.ts} +0 -0
- package/out/stubs/console.d.ts.map +1 -0
- package/out/{console.js → stubs/console.js} +2 -1
- package/out/{http-impl.d.ts → stubs/http-impl.d.ts} +0 -0
- package/out/stubs/http-impl.d.ts.map +1 -0
- package/out/{http-impl.js → stubs/http-impl.js} +0 -0
- package/out/{http.d.ts → stubs/http.d.ts} +0 -0
- package/out/stubs/http.d.ts.map +1 -0
- package/out/{http.js → stubs/http.js} +0 -0
- package/out/{unsupported.d.ts → stubs/unsupported.d.ts} +0 -0
- package/out/{unsupported.d.ts.map → stubs/unsupported.d.ts.map} +1 -1
- package/out/{unsupported.js → stubs/unsupported.js} +1 -1
- package/out/stubs/wrapper.d.ts +2 -0
- package/out/stubs/wrapper.d.ts.map +1 -0
- package/out/{wrapper.js → stubs/wrapper.js} +28 -17
- package/out/types.d.ts +4 -4
- package/out/types.d.ts.map +1 -1
- package/out/webpack.d.ts +7 -24
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +29 -182
- package/package.json +5 -4
- package/out/__PLACEHOLDER_MODULE__.d.ts +0 -1
- package/out/__PLACEHOLDER_MODULE__.d.ts.map +0 -1
- package/out/__PLACEHOLDER_MODULE__.js +0 -1
- package/out/bundler-config/nativeui-webpack-config.d.ts.map +0 -1
- package/out/bundler-config/node-webpack-config.d.ts +0 -4
- package/out/bundler-config/node-webpack-config.d.ts.map +0 -1
- package/out/bundler-config/node-webpack-config.js +0 -21
- package/out/bundler-config/sandboxed-webpack-config.d.ts +0 -5
- package/out/bundler-config/sandboxed-webpack-config.d.ts.map +0 -1
- package/out/bundler-config/sandboxed-webpack-config.js +0 -107
- package/out/console.d.ts.map +0 -1
- package/out/http-impl.d.ts.map +0 -1
- package/out/http.d.ts.map +0 -1
- package/out/wrapper.d.ts +0 -80
- package/out/wrapper.d.ts.map +0 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const api_1 = require("@forge/api");
|
|
6
|
+
const ARI = tslib_1.__importStar(require("@forge/util/packages/cs-ari"));
|
|
3
7
|
function createInstallationContext({ contextAri }) {
|
|
4
|
-
const ari =
|
|
8
|
+
const ari = ARI.parse(contextAri);
|
|
5
9
|
if (ari.resourceType === 'project') {
|
|
6
10
|
return { projectId: ari.resourceId, installContext: contextAri };
|
|
7
11
|
}
|
|
@@ -120,31 +124,43 @@ function simpleBunyanLogEvent(eventType, eventLevel, invocationId, data) {
|
|
|
120
124
|
process.stdout.write(JSON.stringify(logEvent) + '\n');
|
|
121
125
|
}
|
|
122
126
|
function emitHeaderEvent(lambdaEvent) {
|
|
123
|
-
simpleBunyanLogEvent(BunyanCoreLogEventTypes.HEADER, BunyanCoreLogEventLevels.INFO,
|
|
127
|
+
simpleBunyanLogEvent(BunyanCoreLogEventTypes.HEADER, BunyanCoreLogEventLevels.INFO, (0, api_1.getRuntime)().lambdaContext.awsRequestId, invocationHeaderLogs(lambdaEvent));
|
|
124
128
|
}
|
|
125
129
|
function emitSuccessfulFooterEvent() {
|
|
126
|
-
simpleBunyanLogEvent(BunyanCoreLogEventTypes.FOOTER, BunyanCoreLogEventLevels.INFO,
|
|
130
|
+
simpleBunyanLogEvent(BunyanCoreLogEventTypes.FOOTER, BunyanCoreLogEventLevels.INFO, (0, api_1.getRuntime)().lambdaContext.awsRequestId, invocationFooterLogs(true));
|
|
127
131
|
}
|
|
128
132
|
function emitFailedFooterEvent() {
|
|
129
|
-
simpleBunyanLogEvent(BunyanCoreLogEventTypes.FOOTER, BunyanCoreLogEventLevels.INFO,
|
|
133
|
+
simpleBunyanLogEvent(BunyanCoreLogEventTypes.FOOTER, BunyanCoreLogEventLevels.INFO, (0, api_1.getRuntime)().lambdaContext.awsRequestId, invocationFooterLogs(false));
|
|
130
134
|
}
|
|
131
135
|
function emitErrorEvent(caughtObject) {
|
|
132
|
-
simpleBunyanLogEvent(BunyanCoreLogEventTypes.LOG, BunyanCoreLogEventLevels.ERROR,
|
|
136
|
+
simpleBunyanLogEvent(BunyanCoreLogEventTypes.LOG, BunyanCoreLogEventLevels.ERROR, (0, api_1.getRuntime)().lambdaContext.awsRequestId, caughtObject);
|
|
137
|
+
}
|
|
138
|
+
const wrappedFilename = __filename.replace(/\/[^/]+.js$/, (name) => '/bundled' + name);
|
|
139
|
+
const realRequire = eval('require');
|
|
140
|
+
if (!realRequire) {
|
|
141
|
+
throw new Error(`Unexpected require: ${realRequire}`);
|
|
142
|
+
}
|
|
143
|
+
const bundledExports = eval('__BUNDLED_EXPORTS__');
|
|
144
|
+
if (!bundledExports || bundledExports.length === 0) {
|
|
145
|
+
throw new Error('Expected to find __BUNDLED_EXPORTS__ replaced by Webpack configuration.');
|
|
133
146
|
}
|
|
134
147
|
const adapter = (name) => {
|
|
135
148
|
return async (lambdaEvent, lambdaContext) => {
|
|
136
149
|
var _a;
|
|
137
150
|
const event = lambdaEvent.body;
|
|
138
151
|
const context = setupRequestContext(lambdaEvent._meta);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
const runtime = {
|
|
153
|
+
proxy: lambdaEvent._meta.proxy,
|
|
154
|
+
allowedEgress: lambdaEvent._meta.fetchAllowList,
|
|
155
|
+
lambdaContext: lambdaContext
|
|
156
|
+
};
|
|
157
|
+
global.__forge_runtime__ = runtime;
|
|
142
158
|
for (const { key, value } of (_a = lambdaEvent.variables) !== null && _a !== void 0 ? _a : []) {
|
|
143
159
|
process.env[key] = value;
|
|
144
160
|
}
|
|
145
161
|
try {
|
|
146
162
|
emitHeaderEvent(lambdaEvent);
|
|
147
|
-
const bundled =
|
|
163
|
+
const bundled = realRequire(wrappedFilename);
|
|
148
164
|
const result = await bundled[name](event, context);
|
|
149
165
|
emitSuccessfulFooterEvent();
|
|
150
166
|
return {
|
|
@@ -167,11 +183,6 @@ const adapter = (name) => {
|
|
|
167
183
|
};
|
|
168
184
|
};
|
|
169
185
|
(_b = (_a = process).setSourceMapsEnabled) === null || _b === void 0 ? void 0 : _b.call(_a, true);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
return adapter(name);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
186
|
+
for (const ownExport of bundledExports) {
|
|
187
|
+
exports[ownExport] = adapter(ownExport);
|
|
188
|
+
}
|
package/out/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Compiler } from 'webpack';
|
|
2
|
-
import {
|
|
2
|
+
import { EntryPoint } from './webpack';
|
|
3
3
|
export declare type BundledFiles = {
|
|
4
4
|
[filename: string]: string;
|
|
5
5
|
};
|
|
@@ -13,8 +13,8 @@ export interface BundlerOutput {
|
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export declare type Bundler = (appDirectory: string, endpointPath:
|
|
17
|
-
export declare type InDiskBundler = (entrypoints:
|
|
16
|
+
export declare type Bundler<EP = EntryPoint> = (appDirectory: string, endpointPath: EP[]) => Promise<BundlerOutput>;
|
|
17
|
+
export declare type InDiskBundler = (entrypoints: EntryPoint[]) => Promise<{
|
|
18
18
|
outputDir: string;
|
|
19
19
|
}>;
|
|
20
20
|
export declare type WatcherCallback = (err: Error | null, output?: BundlerOutput) => void;
|
|
@@ -22,5 +22,5 @@ export interface WatcherMonitor {
|
|
|
22
22
|
stop(): void;
|
|
23
23
|
}
|
|
24
24
|
export declare type WatchRun = (compiler: Compiler, ...args: any[]) => void;
|
|
25
|
-
export declare type Watcher = (endpointPath:
|
|
25
|
+
export declare type Watcher = (endpointPath: EntryPoint[], isDebugMode: boolean, callback: WatcherCallback, watchRun?: WatchRun) => WatcherMonitor;
|
|
26
26
|
//# sourceMappingURL=types.d.ts.map
|
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,oBAAY,YAAY,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAC1D,oBAAY,gBAAgB,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,oBAAY,OAAO,CAAC,EAAE,GAAG,UAAU,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5G,oBAAY,aAAa,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE1F,oBAAY,eAAe,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAClF,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpE,oBAAY,OAAO,GAAG,CACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,QAAQ,KAChB,cAAc,CAAC"}
|
package/out/webpack.d.ts
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import webpack, { Compiler, Configuration as WebpackConfig
|
|
1
|
+
import webpack, { Compiler, Configuration as WebpackConfig } from 'webpack';
|
|
2
2
|
import { Bundler, Watcher, InDiskBundler, BundlerOutput } from './types';
|
|
3
3
|
import { FileSystemReader, FileSystemWriter } from '@forge/cli-shared';
|
|
4
4
|
import { LintLogger } from '@forge/lint';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare const resolveModulePath: (moduleName: string) => string;
|
|
10
|
-
export declare const handleWebpackCompilationResult: (err: Error | undefined, stats: webpack.Stats | undefined) => stats is webpack.Stats;
|
|
11
|
-
export declare const getInMemoryBundle: (entryPoints: {
|
|
12
|
-
name: string;
|
|
13
|
-
path: string;
|
|
14
|
-
}[]) => BundlerOutput;
|
|
15
|
-
export declare const getDevToolConfig: (config: ConfigBuilder) => string;
|
|
16
|
-
declare type RequiredFields<T, F extends keyof T> = T & Required<Pick<T, F>>;
|
|
17
|
-
declare type CommonModuleOptions = RequiredFields<ModuleOptions, 'rules'>;
|
|
18
|
-
declare type CommonWebpackConfig = RequiredFields<WebpackConfig, 'plugins' | 'module'> & Record<'module', CommonModuleOptions>;
|
|
19
|
-
export declare const getCommonWebpackConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => CommonWebpackConfig;
|
|
20
|
-
export interface ConfigBuilder {
|
|
21
|
-
isWatchMode: boolean;
|
|
22
|
-
isDebugMode?: boolean;
|
|
23
|
-
appDirectory: string;
|
|
24
|
-
}
|
|
5
|
+
import { CommonWebpackConfig, ConfigBuilder, EntryPoint, FunctionsEntryPoint } from './config/common';
|
|
6
|
+
export { EntryPoint };
|
|
7
|
+
export declare function handleWebpackCompilationResult(err: Error | undefined, stats: webpack.Stats | undefined): asserts stats is webpack.Stats;
|
|
8
|
+
export declare function getInMemoryBundle(config: CommonWebpackConfig): BundlerOutput;
|
|
25
9
|
interface CompilerOptions {
|
|
26
10
|
writeToDisk?: boolean;
|
|
27
11
|
}
|
|
28
12
|
export declare const getCompiler: (webpackConfig: WebpackConfig, options?: CompilerOptions) => Compiler;
|
|
29
13
|
export declare const runLinter: (logger?: LintLogger, fileSystemReader?: FileSystemReader, fileSystemWriter?: FileSystemWriter) => Promise<void>;
|
|
30
14
|
export declare const watch: Watcher;
|
|
31
|
-
export declare
|
|
15
|
+
export declare function createBundler<EP extends EntryPoint = EntryPoint>(getBuildConfig: (entrypoints: EP[], configBuilder: ConfigBuilder) => CommonWebpackConfig): Bundler<EP>;
|
|
32
16
|
export declare const sandboxBundle: Bundler;
|
|
33
|
-
export declare const nodeBundle: Bundler
|
|
17
|
+
export declare const nodeBundle: Bundler<FunctionsEntryPoint>;
|
|
34
18
|
export declare const nativeUiBundle: InDiskBundler;
|
|
35
|
-
export {};
|
|
36
19
|
//# sourceMappingURL=webpack.d.ts.map
|
package/out/webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,EACL,OAAO,EAGP,OAAO,EAEP,aAAa,EACb,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,gBAAgB,EAGhB,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtG,OAAO,EAAE,UAAU,EAAE,CAAC;AAQtB,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,KAAK,GAAG,SAAS,EACtB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,SAAS,GAC/B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAiChC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAU5E;AAED,UAAU,eAAe;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,WAAW,kBAAmB,aAAa,YAAY,eAAe,KAAG,QAOrF,CAAC;AA6BF,eAAO,MAAM,SAAS,YAEZ,UAAU,+EAGjB,QAAQ,IAAI,CAuBd,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,OAwBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,SAAS,UAAU,GAAG,UAAU,EAC9D,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,KAAK,mBAAmB,GACvF,OAAO,CAAC,EAAE,CAAC,CA8Bb;AAED,eAAO,MAAM,aAAa,EAAE,OAAuD,CAAC;AAEpF,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAA4C,CAAC;AAEjG,eAAO,MAAM,cAAc,EAAE,aAkB5B,CAAC"}
|
package/out/webpack.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nativeUiBundle = exports.nodeBundle = exports.sandboxBundle = exports.createBundler = exports.watch = exports.runLinter = exports.getCompiler = exports.
|
|
3
|
+
exports.nativeUiBundle = exports.nodeBundle = exports.sandboxBundle = exports.createBundler = exports.watch = exports.runLinter = exports.getCompiler = exports.getInMemoryBundle = exports.handleWebpackCompilationResult = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const memfs_1 = require("memfs");
|
|
7
|
-
const path_1 = require("path");
|
|
8
7
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
9
8
|
const text_1 = require("./text");
|
|
10
9
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
11
10
|
const lint_1 = require("@forge/lint");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const tsconfig_interactor_1 = require("./tsconfig-interactor");
|
|
16
|
-
const nativeui_webpack_config_1 = require("./bundler-config/nativeui-webpack-config");
|
|
11
|
+
const sandbox_1 = require("./config/sandbox");
|
|
12
|
+
const node_1 = require("./config/node");
|
|
13
|
+
const nativeui_1 = require("./config/nativeui");
|
|
17
14
|
const compilerOutputFileSystem = (0, memfs_1.createFsFromVolume)(new memfs_1.Volume());
|
|
18
15
|
const readMemoryFileSync = (filePath) => {
|
|
19
16
|
return compilerOutputFileSystem.readFileSync(filePath, { encoding: 'utf8' }).toString();
|
|
20
17
|
};
|
|
21
|
-
|
|
22
|
-
return require.resolve(moduleName);
|
|
23
|
-
};
|
|
24
|
-
exports.resolveModulePath = resolveModulePath;
|
|
25
|
-
const handleWebpackCompilationResult = (err, stats) => {
|
|
18
|
+
function handleWebpackCompilationResult(err, stats) {
|
|
26
19
|
if (err) {
|
|
27
20
|
throw err;
|
|
28
21
|
}
|
|
@@ -36,7 +29,7 @@ const handleWebpackCompilationResult = (err, stats) => {
|
|
|
36
29
|
const formattedErrors = info.errors.map((error) => {
|
|
37
30
|
return error.message.replace(/\.?.+.tsx?(?!\([0-9]\,[0-9]\))$/gm, '');
|
|
38
31
|
});
|
|
39
|
-
throw new
|
|
32
|
+
throw new cli_shared_1.BundlerTSError(text_1.Text.typescriptError(formattedErrors));
|
|
40
33
|
}
|
|
41
34
|
else {
|
|
42
35
|
throw new Error(text_1.Text.genericBundlingError(info.errors.map((e) => e.message)));
|
|
@@ -46,123 +39,17 @@ const handleWebpackCompilationResult = (err, stats) => {
|
|
|
46
39
|
const warnings = text_1.Text.warnings(info.warnings.map((e) => e.message));
|
|
47
40
|
console.warn(chalk_1.default.magenta(warnings));
|
|
48
41
|
}
|
|
49
|
-
|
|
50
|
-
};
|
|
42
|
+
}
|
|
51
43
|
exports.handleWebpackCompilationResult = handleWebpackCompilationResult;
|
|
52
|
-
|
|
44
|
+
function getInMemoryBundle(config) {
|
|
53
45
|
const output = {}, sourceMap = {};
|
|
54
|
-
|
|
55
|
-
output[name] = readMemoryFileSync(`/${name}.js`);
|
|
56
|
-
|
|
57
|
-
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`);
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
output,
|
|
64
|
-
sourceMap
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
exports.getInMemoryBundle = getInMemoryBundle;
|
|
68
|
-
const getDevToolConfig = (config) => {
|
|
69
|
-
if (!config.isWatchMode) {
|
|
70
|
-
return 'source-map';
|
|
71
|
-
}
|
|
72
|
-
return config.isDebugMode ? 'eval-cheap-module-source-map' : 'cheap-source-map';
|
|
73
|
-
};
|
|
74
|
-
exports.getDevToolConfig = getDevToolConfig;
|
|
75
|
-
const getCommonWebpackConfig = (entrypoints, config) => {
|
|
76
|
-
if (!require.main) {
|
|
77
|
-
throw new Error(text_1.Text.noExecutableFile);
|
|
46
|
+
for (const name in config.entry) {
|
|
47
|
+
output[name] = readMemoryFileSync(`/${name}.js`).toString();
|
|
48
|
+
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
|
|
78
49
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
entry: Object.assign({}, resolvedEntryPoints),
|
|
85
|
-
mode: 'production',
|
|
86
|
-
optimization: {
|
|
87
|
-
minimize: false
|
|
88
|
-
},
|
|
89
|
-
devtool: (0, exports.getDevToolConfig)(config),
|
|
90
|
-
output: {
|
|
91
|
-
libraryTarget: 'commonjs',
|
|
92
|
-
globalObject: 'this',
|
|
93
|
-
filename: '[name].js',
|
|
94
|
-
path: '/'
|
|
95
|
-
},
|
|
96
|
-
node: {
|
|
97
|
-
__dirname: true
|
|
98
|
-
},
|
|
99
|
-
performance: false,
|
|
100
|
-
resolve: {
|
|
101
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
102
|
-
},
|
|
103
|
-
resolveLoader: {
|
|
104
|
-
modules: require.resolve.paths('babel-loader') || undefined
|
|
105
|
-
},
|
|
106
|
-
plugins: [new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ })],
|
|
107
|
-
module: {
|
|
108
|
-
rules: [
|
|
109
|
-
{
|
|
110
|
-
test: /\.jsx?$/,
|
|
111
|
-
exclude: /node_modules/,
|
|
112
|
-
use: [
|
|
113
|
-
{
|
|
114
|
-
loader: 'babel-loader',
|
|
115
|
-
options: {
|
|
116
|
-
presets: [
|
|
117
|
-
[
|
|
118
|
-
(0, exports.resolveModulePath)('@babel/preset-typescript'),
|
|
119
|
-
{
|
|
120
|
-
isTSX: true,
|
|
121
|
-
jsxPragma: 'ForgeUI',
|
|
122
|
-
allExtensions: true
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
],
|
|
126
|
-
plugins: [
|
|
127
|
-
[
|
|
128
|
-
(0, exports.resolveModulePath)('@babel/plugin-transform-react-jsx'),
|
|
129
|
-
{
|
|
130
|
-
pragma: 'ForgeUI.createElement'
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
(0, exports.resolveModulePath)('@forge/babel-plugin-transform-ui'),
|
|
134
|
-
(0, exports.resolveModulePath)('@babel/plugin-proposal-numeric-separator'),
|
|
135
|
-
(0, exports.resolveModulePath)('@babel/plugin-proposal-class-properties'),
|
|
136
|
-
(0, exports.resolveModulePath)('@babel/plugin-proposal-optional-chaining')
|
|
137
|
-
],
|
|
138
|
-
cacheDirectory: true
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
test: /\.tsx?$/,
|
|
145
|
-
exclude: /node_modules/,
|
|
146
|
-
use: [
|
|
147
|
-
{
|
|
148
|
-
loader: 'ts-loader',
|
|
149
|
-
options: {
|
|
150
|
-
compilerOptions: {
|
|
151
|
-
jsx: 'react',
|
|
152
|
-
jsxFactory: 'ForgeUI.createElement'
|
|
153
|
-
},
|
|
154
|
-
configFile: new tsconfig_interactor_1.TSConfigInteractor(new cli_shared_1.FileSystemReader(), config.appDirectory).getTSConfigPath(),
|
|
155
|
-
context: config.appDirectory,
|
|
156
|
-
onlyCompileBundledFiles: true
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
exports.getCommonWebpackConfig = getCommonWebpackConfig;
|
|
50
|
+
return { output, sourceMap };
|
|
51
|
+
}
|
|
52
|
+
exports.getInMemoryBundle = getInMemoryBundle;
|
|
166
53
|
const getCompiler = (webpackConfig, options) => {
|
|
167
54
|
const compiler = (0, webpack_1.default)(webpackConfig);
|
|
168
55
|
if (!(options === null || options === void 0 ? void 0 : options.writeToDisk)) {
|
|
@@ -223,7 +110,7 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
|
|
|
223
110
|
};
|
|
224
111
|
exports.runLinter = runLinter;
|
|
225
112
|
const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
226
|
-
const config = (0,
|
|
113
|
+
const config = (0, sandbox_1.getSandboxedRuntimeBuildConfig)(entryPoints, {
|
|
227
114
|
isWatchMode: true,
|
|
228
115
|
isDebugMode: debugMode,
|
|
229
116
|
appDirectory: process.cwd()
|
|
@@ -236,20 +123,8 @@ const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
|
236
123
|
}
|
|
237
124
|
const watcher = compiler.watch({ poll: 1000 }, (compilerError, stats) => {
|
|
238
125
|
try {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
entryPoints.forEach(({ name }) => {
|
|
242
|
-
output[name] = readMemoryFileSync(`/${name}.js`);
|
|
243
|
-
try {
|
|
244
|
-
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`);
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
callback(null, {
|
|
250
|
-
output,
|
|
251
|
-
sourceMap
|
|
252
|
-
});
|
|
126
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
127
|
+
callback(null, getInMemoryBundle(config));
|
|
253
128
|
}
|
|
254
129
|
catch (fileReadError) {
|
|
255
130
|
callback(fileReadError);
|
|
@@ -258,33 +133,24 @@ const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
|
258
133
|
return new Monitor(watcher);
|
|
259
134
|
};
|
|
260
135
|
exports.watch = watch;
|
|
261
|
-
|
|
136
|
+
function createBundler(getBuildConfig) {
|
|
262
137
|
return (appDirectory, endpoints) => {
|
|
263
138
|
const config = getBuildConfig(endpoints, { isWatchMode: false, appDirectory });
|
|
264
139
|
const compiler = (0, exports.getCompiler)(config);
|
|
265
140
|
return new Promise((resolve, reject) => {
|
|
266
141
|
compiler.run((compilerError, stats) => {
|
|
267
142
|
try {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
const output = {}, sourceMap = {};
|
|
272
|
-
endpoints.forEach(({ name }) => {
|
|
273
|
-
output[name] = readMemoryFileSync(`/${name}.js`).toString();
|
|
274
|
-
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
|
|
275
|
-
});
|
|
143
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
144
|
+
const result = getInMemoryBundle(config);
|
|
276
145
|
compiler.close((closeError) => {
|
|
277
146
|
if (closeError) {
|
|
278
147
|
reject(closeError);
|
|
279
148
|
}
|
|
280
149
|
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
modules: getNodeModuleNames(stats)
|
|
286
|
-
}
|
|
287
|
-
});
|
|
150
|
+
result.metadata = {
|
|
151
|
+
modules: getNodeModuleNames(stats)
|
|
152
|
+
};
|
|
153
|
+
resolve(result);
|
|
288
154
|
}
|
|
289
155
|
catch (fileReadError) {
|
|
290
156
|
reject(fileReadError);
|
|
@@ -292,36 +158,17 @@ const createBundler = (getBuildConfig) => {
|
|
|
292
158
|
});
|
|
293
159
|
});
|
|
294
160
|
};
|
|
295
|
-
}
|
|
161
|
+
}
|
|
296
162
|
exports.createBundler = createBundler;
|
|
297
|
-
exports.sandboxBundle =
|
|
298
|
-
|
|
299
|
-
const bundler = (0, exports.createBundler)(node_webpack_config_1.getNodeRuntimeBuildConfig);
|
|
300
|
-
const { output: bundlerOutput, sourceMap: bundlerSourceMap, metadata } = await bundler(appDirectory, entryPoints);
|
|
301
|
-
const wrapper = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../out/wrapper.js')).toString();
|
|
302
|
-
const output = {};
|
|
303
|
-
const sourceMap = {};
|
|
304
|
-
entryPoints.forEach(({ name }) => {
|
|
305
|
-
const wrappedName = 'bundled/' + name;
|
|
306
|
-
output[wrappedName] = bundlerOutput[name];
|
|
307
|
-
const sourceMapValue = bundlerSourceMap === null || bundlerSourceMap === void 0 ? void 0 : bundlerSourceMap[name];
|
|
308
|
-
if (sourceMapValue) {
|
|
309
|
-
sourceMap[wrappedName] = sourceMapValue;
|
|
310
|
-
}
|
|
311
|
-
output[name] = wrapper.replace("'./__PLACEHOLDER_MODULE__'", JSON.stringify('./' + wrappedName));
|
|
312
|
-
});
|
|
313
|
-
return { output, sourceMap, metadata };
|
|
314
|
-
};
|
|
315
|
-
exports.nodeBundle = nodeBundle;
|
|
163
|
+
exports.sandboxBundle = createBundler(sandbox_1.getSandboxedRuntimeBuildConfig);
|
|
164
|
+
exports.nodeBundle = createBundler(node_1.getNodeRuntimeBuildConfig);
|
|
316
165
|
const nativeUiBundle = (entrypoints) => {
|
|
317
|
-
const config = (0,
|
|
166
|
+
const config = (0, nativeui_1.getNativeUiBuildConfig)(entrypoints);
|
|
318
167
|
const compiler = (0, exports.getCompiler)(config, { writeToDisk: true });
|
|
319
168
|
return new Promise((resolve, reject) => {
|
|
320
169
|
compiler.run((compilerError, stats) => {
|
|
321
170
|
try {
|
|
322
|
-
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
171
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
325
172
|
resolve({
|
|
326
173
|
outputDir: config.output.path
|
|
327
174
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
19
19
|
"@babel/plugin-transform-react-jsx": "^7.16.7",
|
|
20
20
|
"@babel/preset-typescript": "^7.16.7",
|
|
21
|
-
"@forge/api": "2.9.1
|
|
21
|
+
"@forge/api": "2.9.1",
|
|
22
22
|
"@forge/babel-plugin-transform-ui": "1.1.0",
|
|
23
|
-
"@forge/cli-shared": "3.
|
|
24
|
-
"@forge/lint": "3.2.12
|
|
23
|
+
"@forge/cli-shared": "3.5.0",
|
|
24
|
+
"@forge/lint": "3.2.12",
|
|
25
|
+
"@forge/util": "1.2.0",
|
|
25
26
|
"assert": "^1.1.1",
|
|
26
27
|
"babel-loader": "^8.2.3",
|
|
27
28
|
"browserify-zlib": "^0.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=__PLACEHOLDER_MODULE__.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__PLACEHOLDER_MODULE__.d.ts","sourceRoot":"","sources":["../src/__PLACEHOLDER_MODULE__.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nativeui-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/nativeui-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMzC,eAAO,MAAM,sBAAsB,gCAA+B,aAwEjE,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Configuration as WebpackConfig } from 'webpack';
|
|
2
|
-
import { ConfigBuilder, EntryPoints } from '../webpack';
|
|
3
|
-
export declare const getNodeRuntimeBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
|
|
4
|
-
//# sourceMappingURL=node-webpack-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/node-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,WAAW,EAA0B,MAAM,YAAY,CAAC;AAMhF,eAAO,MAAM,yBAAyB,qCAAsC,aAAa,KAAG,aAY3F,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNodeRuntimeBuildConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const webpack_2 = require("../webpack");
|
|
8
|
-
function bundleStubPath(filePath) {
|
|
9
|
-
return (0, path_1.resolve)(__dirname, '..', `${filePath}${(0, path_1.extname)(__filename)}`);
|
|
10
|
-
}
|
|
11
|
-
const getNodeRuntimeBuildConfig = (entrypoints, config) => {
|
|
12
|
-
const webpackConfig = (0, webpack_2.getCommonWebpackConfig)(entrypoints, config);
|
|
13
|
-
const nodeConfigPlugin = new webpack_1.default.ProvidePlugin({
|
|
14
|
-
console: bundleStubPath('console'),
|
|
15
|
-
'global.console': bundleStubPath('console')
|
|
16
|
-
});
|
|
17
|
-
webpackConfig.plugins.push(nodeConfigPlugin);
|
|
18
|
-
webpackConfig.target = 'node14';
|
|
19
|
-
return webpackConfig;
|
|
20
|
-
};
|
|
21
|
-
exports.getNodeRuntimeBuildConfig = getNodeRuntimeBuildConfig;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Configuration as WebpackConfig } from 'webpack';
|
|
2
|
-
import { ConfigBuilder, EntryPoints } from '../webpack';
|
|
3
|
-
export declare const SANDBOXED_WEBPACK_CONFIG_NAME = "sandboxed-runtime";
|
|
4
|
-
export declare const getSandboxedRuntimeBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
|
|
5
|
-
//# sourceMappingURL=sandboxed-webpack-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxed-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/sandboxed-webpack-config.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,WAAW,EAA6C,MAAM,YAAY,CAAC;AAEnG,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAyDjE,eAAO,MAAM,8BAA8B,qCAAsC,aAAa,KAAG,aAwEhG,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSandboxedRuntimeBuildConfig = exports.SANDBOXED_WEBPACK_CONFIG_NAME = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
7
|
-
const stub_plugin_1 = require("../stub-plugin");
|
|
8
|
-
const webpack_2 = require("../webpack");
|
|
9
|
-
exports.SANDBOXED_WEBPACK_CONFIG_NAME = 'sandboxed-runtime';
|
|
10
|
-
const getCustomModulesAliases = () => {
|
|
11
|
-
return {
|
|
12
|
-
'browserify-cipher': (0, webpack_2.resolveModulePath)('browserify-cipher/browser.js'),
|
|
13
|
-
'browserify-sign/algos': (0, webpack_2.resolveModulePath)('browserify-sign/algos.js'),
|
|
14
|
-
'browserify-sign': (0, webpack_2.resolveModulePath)('browserify-sign/browser/index.js'),
|
|
15
|
-
'create-ecdh': (0, webpack_2.resolveModulePath)('create-ecdh/browser.js'),
|
|
16
|
-
'create-hash/md5': (0, webpack_2.resolveModulePath)('create-hash/md5.js'),
|
|
17
|
-
'create-hash': (0, webpack_2.resolveModulePath)('create-hash/browser.js'),
|
|
18
|
-
'create-hmac': (0, webpack_2.resolveModulePath)('create-hmac/browser.js'),
|
|
19
|
-
'diffie-hellman': (0, webpack_2.resolveModulePath)('diffie-hellman/browser.js'),
|
|
20
|
-
pbkdf2: (0, webpack_2.resolveModulePath)('pbkdf2/browser.js'),
|
|
21
|
-
'public-encrypt': (0, webpack_2.resolveModulePath)('public-encrypt/browser.js'),
|
|
22
|
-
randombytes: (0, webpack_2.resolveModulePath)('randombytes/browser.js'),
|
|
23
|
-
randomfill: (0, webpack_2.resolveModulePath)('randomfill/browser.js'),
|
|
24
|
-
assert: (0, webpack_2.resolveModulePath)('assert/'),
|
|
25
|
-
buffer: (0, webpack_2.resolveModulePath)('buffer/'),
|
|
26
|
-
console: (0, webpack_2.resolveModulePath)('console-browserify'),
|
|
27
|
-
crypto: (0, webpack_2.resolveModulePath)('crypto-browserify'),
|
|
28
|
-
events: (0, webpack_2.resolveModulePath)('events/'),
|
|
29
|
-
os: (0, webpack_2.resolveModulePath)('os-browserify/browser'),
|
|
30
|
-
punycode: (0, webpack_2.resolveModulePath)('punycode/'),
|
|
31
|
-
process: (0, webpack_2.resolveModulePath)('process/browser.js'),
|
|
32
|
-
string_decoder: (0, webpack_2.resolveModulePath)('string_decoder/'),
|
|
33
|
-
timers: (0, webpack_2.resolveModulePath)('timers-browserify'),
|
|
34
|
-
url: (0, webpack_2.resolveModulePath)('url/'),
|
|
35
|
-
util: (0, webpack_2.resolveModulePath)('util/'),
|
|
36
|
-
zlib: (0, webpack_2.resolveModulePath)('browserify-zlib'),
|
|
37
|
-
fs: (0, webpack_2.resolveModulePath)('memfs'),
|
|
38
|
-
http: (0, webpack_2.resolveModulePath)('./http'),
|
|
39
|
-
https: (0, webpack_2.resolveModulePath)('./http'),
|
|
40
|
-
path: (0, webpack_2.resolveModulePath)('path-browserify'),
|
|
41
|
-
querystring: (0, webpack_2.resolveModulePath)('querystring-browser'),
|
|
42
|
-
stream: (0, webpack_2.resolveModulePath)('readable-stream'),
|
|
43
|
-
'supports-color': (0, webpack_2.resolveModulePath)('supports-color/index.js')
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
47
|
-
const webpackConfig = (0, webpack_2.getCommonWebpackConfig)(entrypoints, config);
|
|
48
|
-
const sandboxedConfigPlugins = [
|
|
49
|
-
new webpack_1.default.ProvidePlugin({
|
|
50
|
-
Buffer: [(0, webpack_2.resolveModulePath)('buffer/'), 'Buffer'],
|
|
51
|
-
path: (0, webpack_2.resolveModulePath)('path-browserify'),
|
|
52
|
-
querystring: (0, webpack_2.resolveModulePath)('querystring-browser'),
|
|
53
|
-
stream: (0, webpack_2.resolveModulePath)('readable-stream'),
|
|
54
|
-
TextDecoder: [(0, webpack_2.resolveModulePath)('text-encoder-lite'), 'TextDecoderLite'],
|
|
55
|
-
TextEncoder: [(0, webpack_2.resolveModulePath)('text-encoder-lite'), 'TextEncoderLite'],
|
|
56
|
-
URL: [(0, webpack_2.resolveModulePath)('whatwg-url'), 'URL'],
|
|
57
|
-
URLSearchParams: [(0, webpack_2.resolveModulePath)('whatwg-url'), 'URLSearchParams']
|
|
58
|
-
}),
|
|
59
|
-
new stub_plugin_1.StubPlugin({
|
|
60
|
-
modules: [
|
|
61
|
-
'async_hooks',
|
|
62
|
-
'child_process',
|
|
63
|
-
'cluster',
|
|
64
|
-
'constants',
|
|
65
|
-
'dgram',
|
|
66
|
-
'dns',
|
|
67
|
-
'domain',
|
|
68
|
-
'http2',
|
|
69
|
-
'module',
|
|
70
|
-
'net',
|
|
71
|
-
'perf_hooks',
|
|
72
|
-
'readline',
|
|
73
|
-
'repl',
|
|
74
|
-
'sys',
|
|
75
|
-
'tls',
|
|
76
|
-
'trace_events',
|
|
77
|
-
'tty',
|
|
78
|
-
'v8',
|
|
79
|
-
'vm',
|
|
80
|
-
'worker_threads'
|
|
81
|
-
],
|
|
82
|
-
placeholder: 'requestedModule',
|
|
83
|
-
stub: (0, path_1.resolve)(__dirname, '..', 'unsupported')
|
|
84
|
-
})
|
|
85
|
-
];
|
|
86
|
-
sandboxedConfigPlugins.forEach((plugin) => webpackConfig.plugins.push(plugin));
|
|
87
|
-
const moduleRuls = [
|
|
88
|
-
{
|
|
89
|
-
test: /(readable-stream|pbkdf2|util)\//,
|
|
90
|
-
resolve: {
|
|
91
|
-
aliasFields: ['browser']
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
test: /axios\//,
|
|
96
|
-
resolve: {
|
|
97
|
-
aliasFields: []
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
moduleRuls.forEach((rule) => webpackConfig.module.rules.push(rule));
|
|
102
|
-
webpackConfig.target = 'webworker';
|
|
103
|
-
webpackConfig.resolve = Object.assign(Object.assign({}, webpackConfig.resolve), { mainFields: ['main', 'module'], exportsFields: [], alias: getCustomModulesAliases() });
|
|
104
|
-
webpackConfig.name = exports.SANDBOXED_WEBPACK_CONFIG_NAME;
|
|
105
|
-
return webpackConfig;
|
|
106
|
-
};
|
|
107
|
-
exports.getSandboxedRuntimeBuildConfig = getSandboxedRuntimeBuildConfig;
|