@forge/bundler 4.1.1-next.7 → 4.2.0-next.9
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 +26 -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 -181
- 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,122 +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
|
-
}
|
|
157
|
-
}
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
exports.getCommonWebpackConfig = getCommonWebpackConfig;
|
|
50
|
+
return { output, sourceMap };
|
|
51
|
+
}
|
|
52
|
+
exports.getInMemoryBundle = getInMemoryBundle;
|
|
165
53
|
const getCompiler = (webpackConfig, options) => {
|
|
166
54
|
const compiler = (0, webpack_1.default)(webpackConfig);
|
|
167
55
|
if (!(options === null || options === void 0 ? void 0 : options.writeToDisk)) {
|
|
@@ -222,7 +110,7 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
|
|
|
222
110
|
};
|
|
223
111
|
exports.runLinter = runLinter;
|
|
224
112
|
const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
225
|
-
const config = (0,
|
|
113
|
+
const config = (0, sandbox_1.getSandboxedRuntimeBuildConfig)(entryPoints, {
|
|
226
114
|
isWatchMode: true,
|
|
227
115
|
isDebugMode: debugMode,
|
|
228
116
|
appDirectory: process.cwd()
|
|
@@ -235,20 +123,8 @@ const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
|
235
123
|
}
|
|
236
124
|
const watcher = compiler.watch({ poll: 1000 }, (compilerError, stats) => {
|
|
237
125
|
try {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
entryPoints.forEach(({ name }) => {
|
|
241
|
-
output[name] = readMemoryFileSync(`/${name}.js`);
|
|
242
|
-
try {
|
|
243
|
-
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`);
|
|
244
|
-
}
|
|
245
|
-
catch (e) {
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
callback(null, {
|
|
249
|
-
output,
|
|
250
|
-
sourceMap
|
|
251
|
-
});
|
|
126
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
127
|
+
callback(null, getInMemoryBundle(config));
|
|
252
128
|
}
|
|
253
129
|
catch (fileReadError) {
|
|
254
130
|
callback(fileReadError);
|
|
@@ -257,33 +133,24 @@ const watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
|
257
133
|
return new Monitor(watcher);
|
|
258
134
|
};
|
|
259
135
|
exports.watch = watch;
|
|
260
|
-
|
|
136
|
+
function createBundler(getBuildConfig) {
|
|
261
137
|
return (appDirectory, endpoints) => {
|
|
262
138
|
const config = getBuildConfig(endpoints, { isWatchMode: false, appDirectory });
|
|
263
139
|
const compiler = (0, exports.getCompiler)(config);
|
|
264
140
|
return new Promise((resolve, reject) => {
|
|
265
141
|
compiler.run((compilerError, stats) => {
|
|
266
142
|
try {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
const output = {}, sourceMap = {};
|
|
271
|
-
endpoints.forEach(({ name }) => {
|
|
272
|
-
output[name] = readMemoryFileSync(`/${name}.js`).toString();
|
|
273
|
-
sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
|
|
274
|
-
});
|
|
143
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
144
|
+
const result = getInMemoryBundle(config);
|
|
275
145
|
compiler.close((closeError) => {
|
|
276
146
|
if (closeError) {
|
|
277
147
|
reject(closeError);
|
|
278
148
|
}
|
|
279
149
|
});
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
modules: getNodeModuleNames(stats)
|
|
285
|
-
}
|
|
286
|
-
});
|
|
150
|
+
result.metadata = {
|
|
151
|
+
modules: getNodeModuleNames(stats)
|
|
152
|
+
};
|
|
153
|
+
resolve(result);
|
|
287
154
|
}
|
|
288
155
|
catch (fileReadError) {
|
|
289
156
|
reject(fileReadError);
|
|
@@ -291,36 +158,17 @@ const createBundler = (getBuildConfig) => {
|
|
|
291
158
|
});
|
|
292
159
|
});
|
|
293
160
|
};
|
|
294
|
-
}
|
|
161
|
+
}
|
|
295
162
|
exports.createBundler = createBundler;
|
|
296
|
-
exports.sandboxBundle =
|
|
297
|
-
|
|
298
|
-
const bundler = (0, exports.createBundler)(node_webpack_config_1.getNodeRuntimeBuildConfig);
|
|
299
|
-
const { output: bundlerOutput, sourceMap: bundlerSourceMap, metadata } = await bundler(appDirectory, entryPoints);
|
|
300
|
-
const wrapper = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../out/wrapper.js')).toString();
|
|
301
|
-
const output = {};
|
|
302
|
-
const sourceMap = {};
|
|
303
|
-
entryPoints.forEach(({ name }) => {
|
|
304
|
-
const wrappedName = 'bundled/' + name;
|
|
305
|
-
output[wrappedName] = bundlerOutput[name];
|
|
306
|
-
const sourceMapValue = bundlerSourceMap === null || bundlerSourceMap === void 0 ? void 0 : bundlerSourceMap[name];
|
|
307
|
-
if (sourceMapValue) {
|
|
308
|
-
sourceMap[wrappedName] = sourceMapValue;
|
|
309
|
-
}
|
|
310
|
-
output[name] = wrapper.replace("'./__PLACEHOLDER_MODULE__'", JSON.stringify('./' + wrappedName));
|
|
311
|
-
});
|
|
312
|
-
return { output, sourceMap, metadata };
|
|
313
|
-
};
|
|
314
|
-
exports.nodeBundle = nodeBundle;
|
|
163
|
+
exports.sandboxBundle = createBundler(sandbox_1.getSandboxedRuntimeBuildConfig);
|
|
164
|
+
exports.nodeBundle = createBundler(node_1.getNodeRuntimeBuildConfig);
|
|
315
165
|
const nativeUiBundle = (entrypoints) => {
|
|
316
|
-
const config = (0,
|
|
166
|
+
const config = (0, nativeui_1.getNativeUiBuildConfig)(entrypoints);
|
|
317
167
|
const compiler = (0, exports.getCompiler)(config, { writeToDisk: true });
|
|
318
168
|
return new Promise((resolve, reject) => {
|
|
319
169
|
compiler.run((compilerError, stats) => {
|
|
320
170
|
try {
|
|
321
|
-
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
171
|
+
handleWebpackCompilationResult(compilerError, stats);
|
|
324
172
|
resolve({
|
|
325
173
|
outputDir: config.output.path
|
|
326
174
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-next.9",
|
|
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-next.
|
|
21
|
+
"@forge/api": "2.9.1-next.2",
|
|
22
22
|
"@forge/babel-plugin-transform-ui": "1.1.0",
|
|
23
|
-
"@forge/cli-shared": "3.
|
|
24
|
-
"@forge/lint": "3.2.12-next.
|
|
23
|
+
"@forge/cli-shared": "3.5.0-next.5",
|
|
24
|
+
"@forge/lint": "3.2.12-next.5",
|
|
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;
|