@forge/bundler 4.20.1-next.6 → 4.20.1-next.7
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 +6 -0
- package/out/config/common.d.ts +3 -12
- package/out/config/common.d.ts.map +1 -1
- package/out/config/common.js +11 -9
- package/out/config/nativeui.d.ts +2 -1
- package/out/config/nativeui.d.ts.map +1 -1
- package/out/config/sandbox.d.ts +3 -2
- package/out/config/sandbox.d.ts.map +1 -1
- package/out/config/sandbox.js +2 -2
- package/out/index.d.ts +6 -5
- package/out/index.d.ts.map +1 -1
- package/out/index.js +14 -12
- package/out/nativeui.d.ts +12 -0
- package/out/nativeui.d.ts.map +1 -0
- package/out/nativeui.js +38 -0
- package/out/runtime.d.ts +17 -0
- package/out/runtime.d.ts.map +1 -0
- package/out/runtime.js +82 -0
- package/out/types.d.ts +29 -4
- package/out/types.d.ts.map +1 -1
- package/out/types.js +5 -0
- package/out/webpack.d.ts +15 -9
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +54 -43
- package/out/{config/node.d.ts → wrapper-provider.d.ts} +1 -6
- package/out/wrapper-provider.d.ts.map +1 -0
- package/out/{config/node.js → wrapper-provider.js} +2 -51
- package/package.json +1 -1
- package/out/config/node.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
package/out/config/common.d.ts
CHANGED
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
|
|
3
3
|
import { Handler } from '@forge/cli-shared';
|
|
4
4
|
import { Translations } from '@forge/manifest';
|
|
5
|
-
|
|
6
|
-
isWatchMode: boolean;
|
|
7
|
-
isDebugMode?: boolean;
|
|
8
|
-
appDirectory: string;
|
|
9
|
-
outputDir: string;
|
|
10
|
-
}
|
|
11
|
-
export declare type EntryPoint = {
|
|
12
|
-
name: string;
|
|
13
|
-
path: string;
|
|
14
|
-
};
|
|
5
|
+
import { BundlerArgs, EntryPoint } from '../types';
|
|
15
6
|
export declare function getEntryPoints(handlers: Handler[]): EntryPoint[];
|
|
16
7
|
export declare const resolveModulePath: (moduleName: string) => string;
|
|
17
8
|
export declare function resolveStubPath(stubName: string): string;
|
|
18
|
-
export declare const getDevToolConfig: (
|
|
9
|
+
export declare const getDevToolConfig: ({ watchMode }: Pick<BundlerArgs, 'watchMode'>) => string;
|
|
19
10
|
export declare type RequiredFields<T, F extends keyof T> = T & Required<Pick<T, F>>;
|
|
20
11
|
export declare type CommonOutputOptions = RequiredFields<Required<WebpackConfig>['output'], 'path'>;
|
|
21
12
|
declare type CommonModuleOptions = RequiredFields<ModuleOptions, 'rules'>;
|
|
@@ -33,6 +24,6 @@ export declare const geti18nRule: (i18nConfig: Translations) => {
|
|
|
33
24
|
}) => string;
|
|
34
25
|
};
|
|
35
26
|
};
|
|
36
|
-
export declare const getCommonWebpackConfig: (
|
|
27
|
+
export declare const getCommonWebpackConfig: (args: BundlerArgs) => CommonWebpackConfig;
|
|
37
28
|
export {};
|
|
38
29
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/config/common.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/config/common.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,OAAO,EAAqD,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAOhE;AAED,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,MAEtD,CAAC;AAEF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,gBAAgB,kBAAmB,KAAK,WAAW,EAAE,WAAW,CAAC,KAAG,MAShF,CAAC;AAEF,oBAAY,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5E,oBAAY,mBAAmB,GAAG,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5F,aAAK,mBAAmB,GAAG,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAClE,oBAAY,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpD,oBAAY,mBAAmB,GAAG,cAAc,CAAC,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAC,GACnF,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GACrC,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GACrC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAElC,eAAO,MAAM,WAAW,eAAgB,YAAY;;;;;+DAIe;YAAE,QAAQ;gBAAE,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE;;CAalG,CAAC;AAEF,eAAO,MAAM,sBAAsB,SAAU,WAAW,KAAG,mBA8G1D,CAAC"}
|
package/out/config/common.js
CHANGED
|
@@ -24,11 +24,11 @@ function resolveStubPath(stubName) {
|
|
|
24
24
|
return (0, exports.resolveModulePath)(`../stubs/${stubName}`);
|
|
25
25
|
}
|
|
26
26
|
exports.resolveStubPath = resolveStubPath;
|
|
27
|
-
const getDevToolConfig = (
|
|
28
|
-
if (!
|
|
27
|
+
const getDevToolConfig = ({ watchMode }) => {
|
|
28
|
+
if (!watchMode) {
|
|
29
29
|
return 'source-map';
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return watchMode === 'debug' ? 'inline-source-map' : 'cheap-source-map';
|
|
32
32
|
};
|
|
33
33
|
exports.getDevToolConfig = getDevToolConfig;
|
|
34
34
|
const geti18nRule = (i18nConfig) => {
|
|
@@ -48,26 +48,28 @@ const geti18nRule = (i18nConfig) => {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
exports.geti18nRule = geti18nRule;
|
|
51
|
-
const getCommonWebpackConfig = (
|
|
51
|
+
const getCommonWebpackConfig = (args) => {
|
|
52
52
|
if (!require.main) {
|
|
53
53
|
throw new Error(text_1.Text.noExecutableFile);
|
|
54
54
|
}
|
|
55
|
+
const { entryPoints, appDirectory } = args;
|
|
55
56
|
const resolvedEntryPoints = {};
|
|
56
|
-
for (const entrypoint of
|
|
57
|
+
for (const entrypoint of entryPoints) {
|
|
57
58
|
resolvedEntryPoints[entrypoint.name] = path_1.default.resolve(entrypoint.path);
|
|
58
59
|
}
|
|
60
|
+
const outputDir = args.watchMode === 'debug' ? path_1.default.resolve(cli_shared_1.TUNNEL_BUNDLE_DIRECTORY) : (0, cli_shared_1.tmpDir)('dist');
|
|
59
61
|
return {
|
|
60
62
|
entry: resolvedEntryPoints,
|
|
61
63
|
mode: 'production',
|
|
62
64
|
optimization: {
|
|
63
65
|
minimize: false
|
|
64
66
|
},
|
|
65
|
-
devtool: (0, exports.getDevToolConfig)(
|
|
67
|
+
devtool: (0, exports.getDevToolConfig)(args),
|
|
66
68
|
output: {
|
|
67
69
|
libraryTarget: 'commonjs',
|
|
68
70
|
globalObject: 'this',
|
|
69
71
|
filename: '[name].js',
|
|
70
|
-
path:
|
|
72
|
+
path: outputDir
|
|
71
73
|
},
|
|
72
74
|
node: {
|
|
73
75
|
__dirname: true
|
|
@@ -133,8 +135,8 @@ const getCommonWebpackConfig = (entrypoints, config) => {
|
|
|
133
135
|
jsxFactory: 'ForgeUI.createElement',
|
|
134
136
|
sourceMap: true
|
|
135
137
|
},
|
|
136
|
-
configFile: new tsconfig_interactor_1.TSConfigInteractor(new cli_shared_1.FileSystemReader(),
|
|
137
|
-
context:
|
|
138
|
+
configFile: new tsconfig_interactor_1.TSConfigInteractor(new cli_shared_1.FileSystemReader(), appDirectory).getTSConfigPath(),
|
|
139
|
+
context: appDirectory,
|
|
138
140
|
onlyCompileBundledFiles: true
|
|
139
141
|
}
|
|
140
142
|
}
|
package/out/config/nativeui.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Configuration as WebpackConfig } from 'webpack';
|
|
2
2
|
import { Translations } from '@forge/manifest';
|
|
3
|
-
import {
|
|
3
|
+
import { EntryPoint } from '../types';
|
|
4
|
+
import { CommonOutputOptions } from './common';
|
|
4
5
|
declare type NativeUIConfig = WebpackConfig & Record<'output', CommonOutputOptions>;
|
|
5
6
|
export declare const getNativeUiBuildConfig: (entrypoints: EntryPoint[], i18nConfig?: Translations) => NativeUIConfig;
|
|
6
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../../src/config/nativeui.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../../src/config/nativeui.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAE5D,aAAK,cAAc,GAAG,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AAE5E,eAAO,MAAM,sBAAsB,gBAAiB,UAAU,EAAE,eAAe,YAAY,KAAG,cAyE7F,CAAC"}
|
package/out/config/sandbox.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CommonWebpackConfig
|
|
1
|
+
import { CommonWebpackConfig } from './common';
|
|
2
|
+
import { BundlerArgs } from '../types';
|
|
2
3
|
export declare const SANDBOXED_WEBPACK_CONFIG_NAME = "sandboxed-runtime";
|
|
3
|
-
export declare const getSandboxedRuntimeBuildConfig: (
|
|
4
|
+
export declare const getSandboxedRuntimeBuildConfig: (args: BundlerArgs) => CommonWebpackConfig;
|
|
4
5
|
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/config/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/config/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA8D,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AA0DjE,eAAO,MAAM,8BAA8B,SAAU,WAAW,KAAG,mBAwElE,CAAC"}
|
package/out/config/sandbox.js
CHANGED
|
@@ -43,8 +43,8 @@ const getCustomModulesAliases = () => {
|
|
|
43
43
|
'supports-color': (0, common_1.resolveModulePath)('supports-color/index.js')
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
const getSandboxedRuntimeBuildConfig = (
|
|
47
|
-
const webpackConfig = (0, common_1.getCommonWebpackConfig)(
|
|
46
|
+
const getSandboxedRuntimeBuildConfig = (args) => {
|
|
47
|
+
const webpackConfig = (0, common_1.getCommonWebpackConfig)(args);
|
|
48
48
|
const sandboxedConfigPlugins = [
|
|
49
49
|
new webpack_1.default.ProvidePlugin({
|
|
50
50
|
Buffer: [(0, common_1.resolveModulePath)('buffer/'), 'Buffer'],
|
package/out/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { EntryPoint,
|
|
1
|
+
export { NativeUIBundler, NativeUIBundleResult } from './nativeui';
|
|
2
|
+
export { SandboxBundler, NodeBundler, NODE_RUNTIME_VERSION_FILE } from './runtime';
|
|
3
|
+
export { Bundler, BundlerError, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
4
|
+
export { getCompiler, handleWebpackCompilationResult, runLinter } from './webpack';
|
|
5
|
+
export { getEntryPoints } from './config/common';
|
|
4
6
|
export { getNativeUiBuildConfig } from './config/nativeui';
|
|
5
|
-
export {
|
|
6
|
-
export { getSandboxedRuntimeBuildConfig } from './config/sandbox';
|
|
7
|
+
export { getWrapperProvider, LocalWrapperProvider } from './wrapper-provider';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.getEntryPoints = exports.runLinter = exports.handleWebpackCompilationResult = exports.getCompiler = exports.BundlerError = exports.NODE_RUNTIME_VERSION_FILE = exports.NodeBundler = exports.SandboxBundler = exports.NativeUIBundler = void 0;
|
|
4
|
+
var nativeui_1 = require("./nativeui");
|
|
5
|
+
Object.defineProperty(exports, "NativeUIBundler", { enumerable: true, get: function () { return nativeui_1.NativeUIBundler; } });
|
|
6
|
+
var runtime_1 = require("./runtime");
|
|
7
|
+
Object.defineProperty(exports, "SandboxBundler", { enumerable: true, get: function () { return runtime_1.SandboxBundler; } });
|
|
8
|
+
Object.defineProperty(exports, "NodeBundler", { enumerable: true, get: function () { return runtime_1.NodeBundler; } });
|
|
9
|
+
Object.defineProperty(exports, "NODE_RUNTIME_VERSION_FILE", { enumerable: true, get: function () { return runtime_1.NODE_RUNTIME_VERSION_FILE; } });
|
|
10
|
+
var types_1 = require("./types");
|
|
11
|
+
Object.defineProperty(exports, "BundlerError", { enumerable: true, get: function () { return types_1.BundlerError; } });
|
|
4
12
|
var webpack_1 = require("./webpack");
|
|
5
|
-
Object.defineProperty(exports, "getSandboxBundler", { enumerable: true, get: function () { return webpack_1.getSandboxBundler; } });
|
|
6
|
-
Object.defineProperty(exports, "getNodeBundler", { enumerable: true, get: function () { return webpack_1.getNodeBundler; } });
|
|
7
|
-
Object.defineProperty(exports, "nativeUiBundle", { enumerable: true, get: function () { return webpack_1.nativeUiBundle; } });
|
|
8
13
|
Object.defineProperty(exports, "getCompiler", { enumerable: true, get: function () { return webpack_1.getCompiler; } });
|
|
9
14
|
Object.defineProperty(exports, "handleWebpackCompilationResult", { enumerable: true, get: function () { return webpack_1.handleWebpackCompilationResult; } });
|
|
10
15
|
Object.defineProperty(exports, "runLinter", { enumerable: true, get: function () { return webpack_1.runLinter; } });
|
|
11
16
|
var common_1 = require("./config/common");
|
|
12
17
|
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "getNativeUiBuildConfig", { enumerable: true, get: function () { return
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
Object.defineProperty(exports, "LocalWrapperProvider", { enumerable: true, get: function () { return node_1.LocalWrapperProvider; } });
|
|
19
|
-
var sandbox_1 = require("./config/sandbox");
|
|
20
|
-
Object.defineProperty(exports, "getSandboxedRuntimeBuildConfig", { enumerable: true, get: function () { return sandbox_1.getSandboxedRuntimeBuildConfig; } });
|
|
18
|
+
var nativeui_2 = require("./config/nativeui");
|
|
19
|
+
Object.defineProperty(exports, "getNativeUiBuildConfig", { enumerable: true, get: function () { return nativeui_2.getNativeUiBuildConfig; } });
|
|
20
|
+
var wrapper_provider_1 = require("./wrapper-provider");
|
|
21
|
+
Object.defineProperty(exports, "getWrapperProvider", { enumerable: true, get: function () { return wrapper_provider_1.getWrapperProvider; } });
|
|
22
|
+
Object.defineProperty(exports, "LocalWrapperProvider", { enumerable: true, get: function () { return wrapper_provider_1.LocalWrapperProvider; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResourceDetails } from '@forge/cli-shared';
|
|
2
|
+
import { Translations } from '@forge/manifest';
|
|
3
|
+
import { BundlerArgs } from './types';
|
|
4
|
+
import { ConfigWithOutput, WebpackBundler } from './webpack';
|
|
5
|
+
export interface NativeUIBundleResult {
|
|
6
|
+
nativeUiBundlesDetails: ResourceDetails[];
|
|
7
|
+
}
|
|
8
|
+
export declare class NativeUIBundler extends WebpackBundler {
|
|
9
|
+
getConfig({ entryPoints, i18nConfig }: BundlerArgs): ConfigWithOutput;
|
|
10
|
+
bundleResources(resources: ResourceDetails[], i18nConfig?: Translations): Promise<NativeUIBundleResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=nativeui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../src/nativeui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAA4B,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,sBAAsB,EAAE,eAAe,EAAE,CAAC;CAC3C;AAED,qBAAa,eAAgB,SAAQ,cAAc;IACjD,SAAS,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,WAAW,GAAG,gBAAgB;IAIxD,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAgCrH"}
|
package/out/nativeui.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeUIBundler = void 0;
|
|
4
|
+
const nativeui_1 = require("./config/nativeui");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const webpack_1 = require("./webpack");
|
|
7
|
+
class NativeUIBundler extends webpack_1.WebpackBundler {
|
|
8
|
+
getConfig({ entryPoints, i18nConfig }) {
|
|
9
|
+
return (0, nativeui_1.getNativeUiBuildConfig)(entryPoints, i18nConfig);
|
|
10
|
+
}
|
|
11
|
+
async bundleResources(resources, i18nConfig) {
|
|
12
|
+
const entryPoints = resources.map(({ key, path }) => ({
|
|
13
|
+
name: key,
|
|
14
|
+
path
|
|
15
|
+
}));
|
|
16
|
+
const nativeUiBundlesDetails = [];
|
|
17
|
+
if (entryPoints.length > 0) {
|
|
18
|
+
let bundlerOutputs;
|
|
19
|
+
try {
|
|
20
|
+
bundlerOutputs = await Promise.all(entryPoints.map((entrypoint) => this.bundle({ appDirectory: '', entryPoints: [entrypoint], i18nConfig })));
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new types_1.BundlerError(e.message);
|
|
24
|
+
}
|
|
25
|
+
bundlerOutputs.forEach(({ outputDir }, index) => {
|
|
26
|
+
this.logger.debug(`NativeUI bundle created: ${outputDir}`);
|
|
27
|
+
nativeUiBundlesDetails.push({
|
|
28
|
+
...resources[index],
|
|
29
|
+
path: outputDir
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
nativeUiBundlesDetails
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.NativeUIBundler = NativeUIBundler;
|
package/out/runtime.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import { BundleLogger, BundlerOutput, BundlerArgs } from './types';
|
|
3
|
+
import { ConfigWithOutput, WebpackBundler } from './webpack';
|
|
4
|
+
import { WrapperProvider } from './wrapper-provider';
|
|
5
|
+
export declare class SandboxBundler extends WebpackBundler {
|
|
6
|
+
constructor(logger: BundleLogger);
|
|
7
|
+
getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
8
|
+
}
|
|
9
|
+
export declare const NODE_RUNTIME_VERSION_FILE = "runtime.json";
|
|
10
|
+
export declare class NodeBundler extends WebpackBundler {
|
|
11
|
+
private readonly wrapperProvider;
|
|
12
|
+
constructor(logger: BundleLogger, wrapperProvider: WrapperProvider);
|
|
13
|
+
protected getOutput(config: ConfigWithOutput, stats: webpack.Stats): BundlerOutput;
|
|
14
|
+
getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
15
|
+
private insertWrapperBundle;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,SAAS,CAAC;AAK9B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,cAAe,SAAQ,cAAc;gBACpC,MAAM,EAAE,YAAY;IAIhC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB;CAG/C;AAED,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAIxD,qBAAa,WAAY,SAAQ,cAAc;IAG3C,OAAO,CAAC,QAAQ,CAAC,eAAe;gBADhC,MAAM,EAAE,YAAY,EACH,eAAe,EAAE,eAAe;IAInD,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,aAAa;IAWlF,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB;IAyC9C,OAAO,CAAC,mBAAmB;CAkC5B"}
|
package/out/runtime.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeBundler = exports.NODE_RUNTIME_VERSION_FILE = exports.SandboxBundler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
8
|
+
var RawSource = webpack_1.default.sources.RawSource;
|
|
9
|
+
const common_1 = require("./config/common");
|
|
10
|
+
const sandbox_1 = require("./config/sandbox");
|
|
11
|
+
const webpack_2 = require("./webpack");
|
|
12
|
+
class SandboxBundler extends webpack_2.WebpackBundler {
|
|
13
|
+
constructor(logger) {
|
|
14
|
+
super(logger);
|
|
15
|
+
}
|
|
16
|
+
getConfig(args) {
|
|
17
|
+
return (0, sandbox_1.getSandboxedRuntimeBuildConfig)(args);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.SandboxBundler = SandboxBundler;
|
|
21
|
+
exports.NODE_RUNTIME_VERSION_FILE = 'runtime.json';
|
|
22
|
+
const NODE_WEBPACK_USER_CODE_DIR = 'bundled';
|
|
23
|
+
class NodeBundler extends webpack_2.WebpackBundler {
|
|
24
|
+
wrapperProvider;
|
|
25
|
+
constructor(logger, wrapperProvider) {
|
|
26
|
+
super(logger);
|
|
27
|
+
this.wrapperProvider = wrapperProvider;
|
|
28
|
+
}
|
|
29
|
+
getOutput(config, stats) {
|
|
30
|
+
const result = super.getOutput(config, stats);
|
|
31
|
+
result.metadata ||= {};
|
|
32
|
+
result.metadata.nodeRuntimeVersion = (0, fs_1.readFileSync)(path_1.default.join(result.outputDir, exports.NODE_RUNTIME_VERSION_FILE)).toString();
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
getConfig(args) {
|
|
36
|
+
const webpackConfig = (0, common_1.getCommonWebpackConfig)(args);
|
|
37
|
+
const newEntries = {};
|
|
38
|
+
for (const [entryKey, entryPath] of Object.entries(webpackConfig.entry)) {
|
|
39
|
+
newEntries[`${NODE_WEBPACK_USER_CODE_DIR}/${entryKey}`] = entryPath;
|
|
40
|
+
}
|
|
41
|
+
webpackConfig.entry = newEntries;
|
|
42
|
+
webpackConfig.target = 'node18';
|
|
43
|
+
webpackConfig.output.filename = '[name].cjs';
|
|
44
|
+
webpackConfig.name = 'node-runtime';
|
|
45
|
+
webpackConfig.module.rules.push({
|
|
46
|
+
test: /\.m?js$/,
|
|
47
|
+
resolve: {
|
|
48
|
+
fullySpecified: false
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
webpackConfig.plugins.push({
|
|
52
|
+
apply: (compiler) => {
|
|
53
|
+
compiler.hooks.make.tapPromise('AfterEmitPlugin', this.insertWrapperBundle(args.entryPoints));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return webpackConfig;
|
|
57
|
+
}
|
|
58
|
+
insertWrapperBundle(entrypoints) {
|
|
59
|
+
return async (compilation) => {
|
|
60
|
+
const wrapper = await this.wrapperProvider.getNodeRuntimeWrapper();
|
|
61
|
+
const loader = await this.wrapperProvider.getNodeRuntimeLoader();
|
|
62
|
+
if (loader) {
|
|
63
|
+
const loaderSource = new RawSource(loader.script);
|
|
64
|
+
for (const entrypoint of entrypoints) {
|
|
65
|
+
compilation.emitAsset(`${entrypoint.name}.cjs`, loaderSource);
|
|
66
|
+
}
|
|
67
|
+
const wrapperSource = new RawSource(wrapper.script);
|
|
68
|
+
compilation.emitAsset('__forge_wrapper__.cjs', wrapperSource);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const source = new RawSource(wrapper.script);
|
|
72
|
+
for (const entrypoint of entrypoints) {
|
|
73
|
+
compilation.emitAsset(`${entrypoint.name}.cjs`, source);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
compilation.emitAsset(exports.NODE_RUNTIME_VERSION_FILE, new RawSource(JSON.stringify({
|
|
77
|
+
version: loader ? loader.version : wrapper.version
|
|
78
|
+
}, null, 2)));
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.NodeBundler = NodeBundler;
|
package/out/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@forge/cli-shared';
|
|
1
|
+
import { Logger, UserError } from '@forge/cli-shared';
|
|
2
2
|
import { Translations } from '@forge/manifest';
|
|
3
|
-
import { EntryPoint } from './config/common';
|
|
4
3
|
export declare type BundlerMetadata = {
|
|
5
4
|
modules?: string[];
|
|
6
5
|
nodeRuntimeVersion?: string;
|
|
@@ -9,9 +8,35 @@ export interface BundlerOutput {
|
|
|
9
8
|
outputDir: string;
|
|
10
9
|
metadata?: BundlerMetadata;
|
|
11
10
|
}
|
|
12
|
-
export declare type BundleLogger = Pick<Logger, 'info' | 'warn'>;
|
|
13
|
-
export declare type
|
|
11
|
+
export declare type BundleLogger = Pick<Logger, 'trace' | 'debug' | 'info' | 'warn'>;
|
|
12
|
+
export declare type BundlerWatchMode = 'watch' | 'debug';
|
|
13
|
+
export declare type EntryPoint = {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type BundlerArgs = {
|
|
18
|
+
appDirectory: string;
|
|
19
|
+
entryPoints: EntryPoint[];
|
|
20
|
+
i18nConfig?: Translations;
|
|
21
|
+
watchMode?: BundlerWatchMode;
|
|
22
|
+
};
|
|
23
|
+
export declare type BundlerWatchArgs = BundlerArgs & {
|
|
24
|
+
successMessage: string;
|
|
25
|
+
};
|
|
26
|
+
export declare type BundlerWatch = {
|
|
27
|
+
onBuildWillStart: () => Promise<void>;
|
|
28
|
+
onBuildFinished: ((err: null, result: BundlerOutput) => Promise<void>) & ((err: Error) => Promise<void>);
|
|
29
|
+
};
|
|
14
30
|
export interface WatcherMonitor {
|
|
15
31
|
stop(): void;
|
|
16
32
|
}
|
|
33
|
+
export declare type BundlerWatchOutput = WatcherMonitor & {
|
|
34
|
+
result: BundlerOutput;
|
|
35
|
+
};
|
|
36
|
+
export declare type Bundler = {
|
|
37
|
+
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
|
38
|
+
watch(args: BundlerWatchArgs, watch: BundlerWatch): Promise<BundlerWatchOutput>;
|
|
39
|
+
};
|
|
40
|
+
export declare class BundlerError extends UserError {
|
|
41
|
+
}
|
|
17
42
|
//# 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,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,oBAAY,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,oBAAY,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;AAE7E,oBAAY,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B,CAAC;AAEF,oBAAY,gBAAgB,GAAG,WAAW,GAAG;IAC3C,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,eAAe,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAC1G,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,kBAAkB,GAAG,cAAc,GAAG;IAChD,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjF,CAAC;AAEF,qBAAa,YAAa,SAAQ,SAAS;CAAG"}
|
package/out/types.js
CHANGED
package/out/webpack.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
2
|
import { FileSystemReader, FileSystemWriter } from '@forge/cli-shared';
|
|
3
3
|
import { LintLogger } from '@forge/lint';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export declare function handleWebpackCompilationResult(logger: BundleLogger, err: Error | null | undefined, stats: webpack.Stats | undefined): asserts stats is webpack.Stats;
|
|
4
|
+
import { CommonOutputOptions } from './config/common';
|
|
5
|
+
import { Bundler, BundleLogger, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
6
|
+
export declare function handleWebpackCompilationResult(logger: BundleLogger, err: Error | null | undefined, stats: Pick<webpack.Stats, 'hasErrors' | 'hasWarnings' | 'toJson'> | undefined): asserts stats is webpack.Stats;
|
|
8
7
|
export declare function getCompiler(config: webpack.Configuration): webpack.Compiler;
|
|
9
|
-
export declare function getMetadata(config: CommonWebpackConfig, stats?: webpack.Stats): BundlerMetadata;
|
|
10
8
|
export declare const runLinter: (logger?: LintLogger, fileSystemReader?: FileSystemReader, fileSystemWriter?: FileSystemWriter) => Promise<void>;
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare
|
|
9
|
+
export declare type ConfigWithOutput = webpack.Configuration & {
|
|
10
|
+
output: CommonOutputOptions;
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class WebpackBundler implements Bundler {
|
|
13
|
+
protected readonly logger: BundleLogger;
|
|
14
|
+
constructor(logger: BundleLogger);
|
|
15
|
+
protected getOutput(config: ConfigWithOutput, stats: webpack.Stats): BundlerOutput;
|
|
16
|
+
protected runCompiler(config: ConfigWithOutput): Promise<BundlerOutput>;
|
|
17
|
+
abstract getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
18
|
+
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
|
19
|
+
watch(args: BundlerWatchArgs, watch: BundlerWatch): Promise<BundlerWatchOutput>;
|
|
20
|
+
}
|
|
15
21
|
//# 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,MAAM,SAAS,CAAC;AAC9B,OAAO,EAEL,gBAAgB,EAGhB,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,YAAY,EAEZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC,GAAG,SAAS,GAC7E,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAkChC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,QAAQ,CAE3E;AAqBD,eAAO,MAAM,SAAS,YAEZ,UAAU,+EAGjB,QAAQ,IAAI,CA+Bd,CAAC;AAEF,oBAAY,gBAAgB,GAAG,OAAO,CAAC,aAAa,GAAG;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEvF,8BAAsB,cAAe,YAAW,OAAO;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAEnD,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,aAAa;cAWlE,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAsB7E,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB;IAEjD,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAKjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsCtF"}
|
package/out/webpack.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebpackBundler = exports.runLinter = exports.getCompiler = exports.handleWebpackCompilationResult = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
6
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
8
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
9
8
|
const lint_1 = require("@forge/lint");
|
|
10
|
-
const nativeui_1 = require("./config/nativeui");
|
|
11
|
-
const node_1 = require("./config/node");
|
|
12
|
-
const sandbox_1 = require("./config/sandbox");
|
|
13
9
|
const text_1 = require("./text");
|
|
14
10
|
function handleWebpackCompilationResult(logger, err, stats) {
|
|
15
11
|
if (err) {
|
|
@@ -61,17 +57,6 @@ function getNodeModuleNames(stats) {
|
|
|
61
57
|
return Array.from(filteredModuleNames);
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
function getMetadata(config, stats) {
|
|
65
|
-
const metadata = {};
|
|
66
|
-
if (stats) {
|
|
67
|
-
metadata.modules = getNodeModuleNames(stats);
|
|
68
|
-
}
|
|
69
|
-
if (config.name === node_1.NODE_WEBPACK_CONFIG_NAME && config.output?.path) {
|
|
70
|
-
metadata.nodeRuntimeVersion = (0, fs_1.readFileSync)(path_1.default.join(config.output.path, node_1.NODE_RUNTIME_VERSION_FILE)).toString();
|
|
71
|
-
}
|
|
72
|
-
return metadata;
|
|
73
|
-
}
|
|
74
|
-
exports.getMetadata = getMetadata;
|
|
75
60
|
const runLinter = async (logger = { info: console.log }, fileSystemReader = new cli_shared_1.FileSystemReader(), fileSystemWriter = new cli_shared_1.FileSystemWriter()) => {
|
|
76
61
|
logger.info(`\n${cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.lint.running)}`);
|
|
77
62
|
const exclude = [...(await (0, cli_shared_1.listGitIgnoreFiles)(fileSystemReader)), '.git', 'node_modules'];
|
|
@@ -99,47 +84,73 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
|
|
|
99
84
|
}
|
|
100
85
|
};
|
|
101
86
|
exports.runLinter = runLinter;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
class WebpackBundler {
|
|
88
|
+
logger;
|
|
89
|
+
constructor(logger) {
|
|
90
|
+
this.logger = logger;
|
|
91
|
+
}
|
|
92
|
+
getOutput(config, stats) {
|
|
93
|
+
const outputDir = config.output.path;
|
|
94
|
+
const metadata = {};
|
|
95
|
+
if (stats) {
|
|
96
|
+
metadata.modules = getNodeModuleNames(stats);
|
|
97
|
+
}
|
|
98
|
+
return { outputDir, metadata };
|
|
99
|
+
}
|
|
100
|
+
async runCompiler(config) {
|
|
106
101
|
const compiler = getCompiler(config);
|
|
107
102
|
return new Promise((resolve, reject) => {
|
|
108
103
|
compiler.run((compilerError, stats) => {
|
|
109
104
|
try {
|
|
110
|
-
handleWebpackCompilationResult(logger, compilerError, stats);
|
|
105
|
+
handleWebpackCompilationResult(this.logger, compilerError, stats);
|
|
111
106
|
compiler.close((closeError) => {
|
|
112
107
|
if (closeError) {
|
|
113
108
|
reject(closeError);
|
|
114
109
|
}
|
|
115
110
|
});
|
|
116
|
-
resolve(
|
|
111
|
+
resolve(this.getOutput(config, stats));
|
|
117
112
|
}
|
|
118
113
|
catch (err) {
|
|
119
114
|
reject(err);
|
|
120
115
|
}
|
|
121
116
|
});
|
|
122
117
|
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
handleWebpackCompilationResult(logger, compilerError, stats);
|
|
137
|
-
resolve({ outputDir: config.output.path });
|
|
138
|
-
}
|
|
139
|
-
catch (err) {
|
|
140
|
-
reject(err);
|
|
118
|
+
}
|
|
119
|
+
async bundle(args) {
|
|
120
|
+
const config = this.getConfig(args);
|
|
121
|
+
return await this.runCompiler(config);
|
|
122
|
+
}
|
|
123
|
+
async watch(args, watch) {
|
|
124
|
+
const config = this.getConfig(args);
|
|
125
|
+
const compiler = getCompiler(config);
|
|
126
|
+
let isFirstRun = true;
|
|
127
|
+
compiler.hooks.watchRun.tapAsync('watchRun', async (_, watchRunCallback) => {
|
|
128
|
+
if (!isFirstRun) {
|
|
129
|
+
await watch.onBuildWillStart();
|
|
141
130
|
}
|
|
131
|
+
watchRunCallback();
|
|
142
132
|
});
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
const watching = compiler.watch({ poll: 1000 }, async (compilerError, stats) => {
|
|
135
|
+
try {
|
|
136
|
+
handleWebpackCompilationResult(this.logger, compilerError, stats);
|
|
137
|
+
this.logger.info(cli_shared_1.LogColor.trace(args.successMessage));
|
|
138
|
+
const result = this.getOutput(config, stats);
|
|
139
|
+
if (isFirstRun) {
|
|
140
|
+
isFirstRun = false;
|
|
141
|
+
resolve({ result, stop: () => watching.close(() => void 0) });
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
await watch.onBuildFinished(null, result);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
await watch.onBuildFinished(err);
|
|
149
|
+
isFirstRun = false;
|
|
150
|
+
reject(err);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.WebpackBundler = WebpackBundler;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { BaseError, FileSystemReader, UserError, StatsigService } from '@forge/cli-shared';
|
|
2
|
-
import { CommonWebpackConfig, ConfigBuilder, EntryPoint } from './common';
|
|
3
|
-
export declare const NODE_WEBPACK_CONFIG_NAME = "node-runtime";
|
|
4
|
-
export declare const NODE_WEBPACK_USER_CODE_DIR = "bundled";
|
|
5
|
-
export declare const NODE_RUNTIME_VERSION_FILE = "runtime.json";
|
|
6
2
|
export declare class LocalWrapperNotFoundError extends UserError {
|
|
7
3
|
constructor();
|
|
8
4
|
}
|
|
@@ -42,5 +38,4 @@ export declare const getWrapperProvider: ({ fileSystemReader, statsigService }:
|
|
|
42
38
|
fileSystemReader: FileSystemReader;
|
|
43
39
|
statsigService: StatsigService;
|
|
44
40
|
}) => LocalWrapperProvider | NetworkWrapperProvider;
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=node.d.ts.map
|
|
41
|
+
//# sourceMappingURL=wrapper-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper-provider.d.ts","sourceRoot":"","sources":["../src/wrapper-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,SAAS,EAGT,cAAc,EACf,MAAM,mBAAmB,CAAC;AAW3B,qBAAa,yBAA0B,SAAQ,SAAS;;CAIvD;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAGhD;AAED,qBAAa,yBAA0B,SAAQ,SAAS;gBAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS;CAG3D;AAED,oBAAY,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;CAC5D;AAOD,qBAAa,oBAAqB,YAAW,eAAe;IAExD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM;IAEhC,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC;IAW/C,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAUjE;AAED,qBAAa,sBAAuB,YAAW,eAAe;IAKhD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc;IAJ7D,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAA4B;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEM,cAAc,EAAE,cAAc;YAI/C,sBAAsB;IAgBpC,OAAO,CAAC,cAAc,CAmCpB;IAEI,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC;IAO/C,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAQjE;AAED,eAAO,MAAM,kBAAkB;sBAIX,gBAAgB;oBAClB,cAAc;mDAS/B,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getWrapperProvider = exports.NetworkWrapperProvider = exports.LocalWrapperProvider = exports.ParseWrapperCDNIndexError = exports.WrapperNetworkError = exports.LocalWrapperNotFoundError = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
6
|
const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
|
|
6
7
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
7
8
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
|
-
exports.NODE_WEBPACK_CONFIG_NAME = 'node-runtime';
|
|
11
|
-
exports.NODE_WEBPACK_USER_CODE_DIR = 'bundled';
|
|
12
|
-
exports.NODE_RUNTIME_VERSION_FILE = 'runtime.json';
|
|
13
9
|
var RuntimeCDN;
|
|
14
10
|
(function (RuntimeCDN) {
|
|
15
11
|
RuntimeCDN["DEV"] = "https://forge-node-runtime.stg-east.frontend.public.atl-paas.net/";
|
|
@@ -136,48 +132,3 @@ const getWrapperProvider = ({ fileSystemReader, statsigService }) => {
|
|
|
136
132
|
return new NetworkWrapperProvider(statsigService);
|
|
137
133
|
};
|
|
138
134
|
exports.getWrapperProvider = getWrapperProvider;
|
|
139
|
-
const getNodeRuntimeBuildConfig = (wrapperProvider) => (entrypoints, config) => {
|
|
140
|
-
const webpackConfig = (0, common_1.getCommonWebpackConfig)(entrypoints, config);
|
|
141
|
-
const newEntries = {};
|
|
142
|
-
for (const [entryKey, entryPath] of Object.entries(webpackConfig.entry)) {
|
|
143
|
-
newEntries[`${exports.NODE_WEBPACK_USER_CODE_DIR}/${entryKey}`] = entryPath;
|
|
144
|
-
}
|
|
145
|
-
webpackConfig.entry = newEntries;
|
|
146
|
-
webpackConfig.target = 'node18';
|
|
147
|
-
webpackConfig.output.filename = '[name].cjs';
|
|
148
|
-
webpackConfig.name = exports.NODE_WEBPACK_CONFIG_NAME;
|
|
149
|
-
webpackConfig.module.rules.push({
|
|
150
|
-
test: /\.m?js$/,
|
|
151
|
-
resolve: {
|
|
152
|
-
fullySpecified: false
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
webpackConfig.plugins.push({
|
|
156
|
-
apply: (compiler) => {
|
|
157
|
-
compiler.hooks.make.tapPromise('AfterEmitPlugin', async (compilation) => {
|
|
158
|
-
const { RawSource } = compiler.webpack.sources;
|
|
159
|
-
const wrapper = await wrapperProvider.getNodeRuntimeWrapper();
|
|
160
|
-
const loader = await wrapperProvider.getNodeRuntimeLoader();
|
|
161
|
-
if (loader) {
|
|
162
|
-
const loaderSource = new RawSource(loader.script);
|
|
163
|
-
for (const entrypoint of entrypoints) {
|
|
164
|
-
compilation.emitAsset(`${entrypoint.name}.cjs`, loaderSource);
|
|
165
|
-
}
|
|
166
|
-
const wrapperSource = new RawSource(wrapper.script);
|
|
167
|
-
compilation.emitAsset('__forge_wrapper__.cjs', wrapperSource);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
const source = new RawSource(wrapper.script);
|
|
171
|
-
for (const entrypoint of entrypoints) {
|
|
172
|
-
compilation.emitAsset(`${entrypoint.name}.cjs`, source);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
compilation.emitAsset(exports.NODE_RUNTIME_VERSION_FILE, new RawSource(JSON.stringify({
|
|
176
|
-
version: loader ? loader.version : wrapper.version
|
|
177
|
-
}, null, 2)));
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
return webpackConfig;
|
|
182
|
-
};
|
|
183
|
-
exports.getNodeRuntimeBuildConfig = getNodeRuntimeBuildConfig;
|
package/package.json
CHANGED
package/out/config/node.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/config/node.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,SAAS,EAGT,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAA0C,MAAM,UAAU,CAAC;AAIlH,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,0BAA0B,YAAY,CAAC;AACpD,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAWxD,qBAAa,yBAA0B,SAAQ,SAAS;;CAIvD;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAGhD;AAED,qBAAa,yBAA0B,SAAQ,SAAS;gBAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS;CAG3D;AAED,oBAAY,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;CAC5D;AAOD,qBAAa,oBAAqB,YAAW,eAAe;IAExD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM;IAEhC,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC;IAW/C,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAUjE;AAED,qBAAa,sBAAuB,YAAW,eAAe;IAKhD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc;IAJ7D,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAA4B;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEM,cAAc,EAAE,cAAc;YAI/C,sBAAsB;IAgBpC,OAAO,CAAC,cAAc,CAmCpB;IAEI,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC;IAO/C,oBAAoB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAQjE;AAED,eAAO,MAAM,kBAAkB;sBAIX,gBAAgB;oBAClB,cAAc;mDAS/B,CAAC;AAEF,eAAO,MAAM,yBAAyB,oBAClB,eAAe,mBACnB,UAAU,EAAE,UAAU,aAAa,KAAG,mBAuEnD,CAAC"}
|