@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bbca9be: Forge CLI error handling and analytics changes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f392eff: Support variables on Node runtime
|
|
12
|
+
- a36488f: Bundle Node runtime wrapper using Webpack
|
|
13
|
+
- 1ad9503: Add onlyCompileBundledFiles option to ts-loader to only compile files included in the webpack bundle
|
|
14
|
+
- 8d0dc10: Use a single global to pass information from the runtime
|
|
15
|
+
- 7a4fa35: Support internet egress calls in the new runtime
|
|
16
|
+
- 06be4ae: Enable source maps on Node runtime
|
|
17
|
+
- Updated dependencies [bae4bce]
|
|
18
|
+
- Updated dependencies [b7428f7]
|
|
19
|
+
- Updated dependencies [a36488f]
|
|
20
|
+
- Updated dependencies [6cda566]
|
|
21
|
+
- Updated dependencies [73b929a]
|
|
22
|
+
- Updated dependencies [8d0dc10]
|
|
23
|
+
- Updated dependencies [7a4fa35]
|
|
24
|
+
- Updated dependencies [bbca9be]
|
|
25
|
+
- Updated dependencies [fed846f]
|
|
26
|
+
- @forge/cli-shared@3.5.0
|
|
27
|
+
- @forge/api@2.9.1
|
|
28
|
+
- @forge/lint@3.2.12
|
|
29
|
+
|
|
30
|
+
## 4.2.0-next.9
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- bbca9bed: Forge CLI error handling and analytics changes
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- a36488fc: Bundle Node runtime wrapper using Webpack
|
|
39
|
+
- 8d0dc104: Use a single global to pass information from the runtime
|
|
40
|
+
- Updated dependencies [b7428f75]
|
|
41
|
+
- Updated dependencies [a36488fc]
|
|
42
|
+
- Updated dependencies [8d0dc104]
|
|
43
|
+
- Updated dependencies [bbca9bed]
|
|
44
|
+
- @forge/cli-shared@3.5.0-next.5
|
|
45
|
+
- @forge/api@2.9.1-next.2
|
|
46
|
+
- @forge/lint@3.2.12-next.5
|
|
47
|
+
|
|
3
48
|
## 4.1.1-next.8
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,21 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Forge bundler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The bundler package is responsible for compiling the user code, including
|
|
4
|
+
dependencies (NPM packages), into files that get uploaded to AWS Lambda.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
import { bundle, watch } from '@atlassian/forge-bundler';
|
|
6
|
+
This is required for two reasons:
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* Forge only runs JavaScript functions (on either sandbox or Node runtime),
|
|
9
|
+
so TypeScript has to be compiled to JavaScript.
|
|
10
|
+
* All files that the user code imports need to be available when the Forge
|
|
11
|
+
function runs.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
const monitor = watch(endpoint, (err, output) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
log(err);
|
|
15
|
-
} else {
|
|
16
|
-
// ...
|
|
17
|
-
}
|
|
18
|
-
});
|
|
13
|
+
The bundler is used:
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
* When deploying a Forge app (`forge deploy`)
|
|
16
|
+
* When running an app locally (`forge tunnel`)
|
|
17
|
+
|
|
18
|
+
## Implementation
|
|
19
|
+
|
|
20
|
+
Bundler uses [webpack](https://webpack.js.org/) to compile user code.
|
|
21
|
+
|
|
22
|
+
Every entry point from the manifest (referenced in `modules.function.handler`)
|
|
23
|
+
and resource for Native UI is compiled into a single JavaScript file
|
|
24
|
+
containing all of its dependencies.
|
|
25
|
+
|
|
26
|
+
### Sandbox runtime
|
|
27
|
+
|
|
28
|
+
Some built-in Node modules and globals are not exposed in the
|
|
29
|
+
[sandbox JavaScript environment](https://developer.atlassian.com/platform/forge/runtime-reference/#javascript-environment).
|
|
30
|
+
Accessing those at runtime would throw an error.
|
|
31
|
+
|
|
32
|
+
Where possible, the unavailable modules and globals are replaced with
|
|
33
|
+
compatible implementations using
|
|
34
|
+
[ProvidePlugin](https://webpack.js.org/plugins/provide-plugin/) and
|
|
35
|
+
[`alias`](https://webpack.js.org/configuration/resolve/#resolvealias). If
|
|
36
|
+
there is no point in providing an implementation altogether (e.g. `dns`
|
|
37
|
+
module), it is replaced with a stub showing an "unsupported" message.
|
|
38
|
+
|
|
39
|
+
Some NPM modules provide different implementations for "browser" and "node"
|
|
40
|
+
environments, based on
|
|
41
|
+
[package-browser-field-spec](https://github.com/defunctzombie/package-browser-field-spec).
|
|
42
|
+
Even though Forge functions run in Node.js, our environment is more compatible
|
|
43
|
+
with "browser" implementations. The sandbox Webpack configuration sets the
|
|
44
|
+
`resolve` options to prefer those.
|
|
45
|
+
|
|
46
|
+
### Node runtime
|
|
47
|
+
|
|
48
|
+
The interface for the Forge functions is different from the XIS interface, see
|
|
49
|
+
[Node runtime: Technical Details](https://hello.atlassian.net/wiki/spaces/ECO/pages/1767953090/Node+runtime+Technical+details).
|
|
50
|
+
Therefore, a layer of wrapper code is required to convert the calls and
|
|
51
|
+
responses.
|
|
52
|
+
|
|
53
|
+
To maintain the correspondence between AWS Lambda handler and the handler in
|
|
54
|
+
the Forge manifest, the bundled user code is put into a new location, with the
|
|
55
|
+
wrapper code left in the original place. For example, if the manifest
|
|
56
|
+
specifies `index.run` as the handler, AWS Lambda function will have:
|
|
57
|
+
|
|
58
|
+
* `index.js` - wrapper code
|
|
59
|
+
* `bundled/index.js` - bundled user code from `src/index.js`
|
|
60
|
+
|
|
61
|
+
The wrapper code, when invoked:
|
|
62
|
+
|
|
63
|
+
* Parses the invocation request from XIS
|
|
64
|
+
* Sets up the environment (e.g. user variables) for the Forge function run
|
|
65
|
+
* Loads the user code
|
|
66
|
+
* Invokes the user code
|
|
67
|
+
* Converts the result or error to the XIS response format and returns it
|
|
68
|
+
|
|
69
|
+
The wrapper cannot load the user code before the environment is set up, as any
|
|
70
|
+
actions that the user code does upon initialization might fail (e.g. because
|
|
71
|
+
the proxy token is not yet set up).
|
|
72
|
+
|
|
73
|
+
However, wrapper needs to know which exports to make available. This
|
|
74
|
+
information is passed to the bundler from the manifest: if it contains
|
|
75
|
+
`index.run` and `index.another` as handlers, then the wrapper for `index.js`
|
|
76
|
+
will need to export `run` and `another`. Bundler uses
|
|
77
|
+
[BannerPlugin](https://webpack.js.org/plugins/banner-plugin/) to add this as a
|
|
78
|
+
constant to each wrapper.
|
|
79
|
+
|
|
80
|
+
To redirect console calls from the user code to Xen Logs Ingestor that backs
|
|
81
|
+
`forge logs` and the Forge Developer console, occurrences `console` are
|
|
82
|
+
replaced with a custom implementation via
|
|
83
|
+
[ProvidePlugin](https://webpack.js.org/plugins/provide-plugin/).
|
|
84
|
+
|
|
85
|
+
### Native UI
|
|
86
|
+
|
|
87
|
+
TODO: Not documented
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
|
|
2
|
+
import { Handler } from '@forge/cli-shared';
|
|
3
|
+
export interface ConfigBuilder {
|
|
4
|
+
isWatchMode: boolean;
|
|
5
|
+
isDebugMode?: boolean;
|
|
6
|
+
appDirectory: string;
|
|
7
|
+
}
|
|
8
|
+
export declare type EntryPoint = {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type FunctionsEntryPoint = EntryPoint & {
|
|
13
|
+
functions: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function getEntryPoints(handlers: Handler[]): FunctionsEntryPoint[];
|
|
16
|
+
export declare const resolveModulePath: (moduleName: string) => string;
|
|
17
|
+
export declare function resolveStubPath(stubName: string): string;
|
|
18
|
+
export declare const getDevToolConfig: (config: ConfigBuilder) => string;
|
|
19
|
+
declare type RequiredFields<T, F extends keyof T> = T & Required<Pick<T, F>>;
|
|
20
|
+
declare type CommonModuleOptions = RequiredFields<ModuleOptions, 'rules'>;
|
|
21
|
+
export declare type WebpackEntries = Record<string, string>;
|
|
22
|
+
export declare type CommonWebpackConfig = RequiredFields<WebpackConfig, 'plugins' | 'module'> & Record<'module', CommonModuleOptions> & Record<'entry', WebpackEntries>;
|
|
23
|
+
export declare const getCommonWebpackConfig: (entrypoints: EntryPoint[], config: ConfigBuilder) => CommonWebpackConfig;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/config/common.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAG9D,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,mBAAmB,GAAG,UAAU,GAAG;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAiBzE;AAED,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,MAEtD,CAAC;AAEF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,gBAAgB,WAAY,aAAa,KAAG,MASxD,CAAC;AAEF,aAAK,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,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,SAAS,GAAG,QAAQ,CAAC,GACnF,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GACrC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAElC,eAAO,MAAM,sBAAsB,gBAAiB,UAAU,EAAE,UAAU,aAAa,KAAG,mBA8FzF,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCommonWebpackConfig = exports.getDevToolConfig = exports.resolveStubPath = exports.resolveModulePath = exports.getEntryPoints = 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 text_1 = require("../text");
|
|
8
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
9
|
+
const tsconfig_interactor_1 = require("../tsconfig-interactor");
|
|
10
|
+
function getEntryPoints(handlers) {
|
|
11
|
+
const entryPointMap = new Map();
|
|
12
|
+
for (const { module, func } of handlers) {
|
|
13
|
+
if (!entryPointMap.has(module)) {
|
|
14
|
+
entryPointMap.set(module, []);
|
|
15
|
+
}
|
|
16
|
+
entryPointMap.get(module).push(func);
|
|
17
|
+
}
|
|
18
|
+
const currentDirectory = process.cwd();
|
|
19
|
+
return Array.from(entryPointMap.entries()).map(([module, functions]) => ({
|
|
20
|
+
name: module,
|
|
21
|
+
path: (0, path_1.join)(currentDirectory, 'src', module),
|
|
22
|
+
functions
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
exports.getEntryPoints = getEntryPoints;
|
|
26
|
+
const resolveModulePath = (moduleName) => {
|
|
27
|
+
return require.resolve(moduleName);
|
|
28
|
+
};
|
|
29
|
+
exports.resolveModulePath = resolveModulePath;
|
|
30
|
+
function resolveStubPath(stubName) {
|
|
31
|
+
return (0, exports.resolveModulePath)(`../stubs/${stubName}`);
|
|
32
|
+
}
|
|
33
|
+
exports.resolveStubPath = resolveStubPath;
|
|
34
|
+
const getDevToolConfig = (config) => {
|
|
35
|
+
if (!config.isWatchMode) {
|
|
36
|
+
return 'source-map';
|
|
37
|
+
}
|
|
38
|
+
return config.isDebugMode ? 'eval-cheap-module-source-map' : 'cheap-source-map';
|
|
39
|
+
};
|
|
40
|
+
exports.getDevToolConfig = getDevToolConfig;
|
|
41
|
+
const getCommonWebpackConfig = (entrypoints, config) => {
|
|
42
|
+
if (!require.main) {
|
|
43
|
+
throw new Error(text_1.Text.noExecutableFile);
|
|
44
|
+
}
|
|
45
|
+
const resolvedEntryPoints = {};
|
|
46
|
+
for (const entrypoint of entrypoints) {
|
|
47
|
+
resolvedEntryPoints[entrypoint.name] = (0, path_1.resolve)(entrypoint.path);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
entry: resolvedEntryPoints,
|
|
51
|
+
mode: 'production',
|
|
52
|
+
optimization: {
|
|
53
|
+
minimize: false
|
|
54
|
+
},
|
|
55
|
+
devtool: (0, exports.getDevToolConfig)(config),
|
|
56
|
+
output: {
|
|
57
|
+
libraryTarget: 'commonjs',
|
|
58
|
+
globalObject: 'this',
|
|
59
|
+
filename: '[name].js',
|
|
60
|
+
path: '/'
|
|
61
|
+
},
|
|
62
|
+
node: {
|
|
63
|
+
__dirname: true
|
|
64
|
+
},
|
|
65
|
+
performance: false,
|
|
66
|
+
resolve: {
|
|
67
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
68
|
+
},
|
|
69
|
+
resolveLoader: {
|
|
70
|
+
modules: require.resolve.paths('babel-loader') || undefined
|
|
71
|
+
},
|
|
72
|
+
plugins: [new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ })],
|
|
73
|
+
module: {
|
|
74
|
+
rules: [
|
|
75
|
+
{
|
|
76
|
+
test: /\.jsx?$/,
|
|
77
|
+
exclude: /node_modules/,
|
|
78
|
+
use: [
|
|
79
|
+
{
|
|
80
|
+
loader: 'babel-loader',
|
|
81
|
+
options: {
|
|
82
|
+
presets: [
|
|
83
|
+
[
|
|
84
|
+
(0, exports.resolveModulePath)('@babel/preset-typescript'),
|
|
85
|
+
{
|
|
86
|
+
isTSX: true,
|
|
87
|
+
jsxPragma: 'ForgeUI',
|
|
88
|
+
allExtensions: true
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
],
|
|
92
|
+
plugins: [
|
|
93
|
+
[
|
|
94
|
+
(0, exports.resolveModulePath)('@babel/plugin-transform-react-jsx'),
|
|
95
|
+
{
|
|
96
|
+
pragma: 'ForgeUI.createElement'
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
(0, exports.resolveModulePath)('@forge/babel-plugin-transform-ui'),
|
|
100
|
+
(0, exports.resolveModulePath)('@babel/plugin-proposal-numeric-separator'),
|
|
101
|
+
(0, exports.resolveModulePath)('@babel/plugin-proposal-class-properties'),
|
|
102
|
+
(0, exports.resolveModulePath)('@babel/plugin-proposal-optional-chaining')
|
|
103
|
+
],
|
|
104
|
+
cacheDirectory: true
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
test: /\.tsx?$/,
|
|
111
|
+
exclude: /node_modules/,
|
|
112
|
+
use: [
|
|
113
|
+
{
|
|
114
|
+
loader: 'ts-loader',
|
|
115
|
+
options: {
|
|
116
|
+
compilerOptions: {
|
|
117
|
+
jsx: 'react',
|
|
118
|
+
jsxFactory: 'ForgeUI.createElement'
|
|
119
|
+
},
|
|
120
|
+
configFile: new tsconfig_interactor_1.TSConfigInteractor(new cli_shared_1.FileSystemReader(), config.appDirectory).getTSConfigPath(),
|
|
121
|
+
context: config.appDirectory,
|
|
122
|
+
onlyCompileBundledFiles: true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
exports.getCommonWebpackConfig = getCommonWebpackConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Configuration as WebpackConfig } from 'webpack';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getNativeUiBuildConfig: (entrypoints:
|
|
4
|
-
//# sourceMappingURL=nativeui
|
|
2
|
+
import { EntryPoint } from './common';
|
|
3
|
+
export declare const getNativeUiBuildConfig: (entrypoints: EntryPoint[]) => WebpackConfig;
|
|
4
|
+
//# sourceMappingURL=nativeui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../../src/config/nativeui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC,eAAO,MAAM,sBAAsB,gBAAiB,UAAU,EAAE,KAAG,aAwElE,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CommonWebpackConfig, ConfigBuilder, FunctionsEntryPoint } from './common';
|
|
2
|
+
export declare const NODE_WEBPACK_CONFIG_NAME = "node-runtime";
|
|
3
|
+
export declare const getNodeRuntimeBuildConfig: (entrypoints: FunctionsEntryPoint[], config: ConfigBuilder) => CommonWebpackConfig;
|
|
4
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/config/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EAIpB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAEvD,eAAO,MAAM,yBAAyB,gBACvB,mBAAmB,EAAE,UAC1B,aAAa,KACpB,mBA8CF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNodeRuntimeBuildConfig = exports.NODE_WEBPACK_CONFIG_NAME = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const webpack_1 = tslib_1.__importStar(require("webpack"));
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
exports.NODE_WEBPACK_CONFIG_NAME = 'node-runtime';
|
|
8
|
+
const getNodeRuntimeBuildConfig = (entrypoints, config) => {
|
|
9
|
+
const webpackConfig = (0, common_1.getCommonWebpackConfig)(entrypoints, config);
|
|
10
|
+
const wrapperPath = (0, common_1.resolveStubPath)('wrapper');
|
|
11
|
+
const newEntries = {};
|
|
12
|
+
for (const [entryKey, entryPath] of Object.entries(webpackConfig.entry)) {
|
|
13
|
+
newEntries[`bundled/${entryKey}`] = entryPath;
|
|
14
|
+
newEntries[entryKey] = wrapperPath;
|
|
15
|
+
}
|
|
16
|
+
webpackConfig.entry = newEntries;
|
|
17
|
+
const nodeConfigPlugin = new webpack_1.default.ProvidePlugin({
|
|
18
|
+
console: (0, common_1.resolveStubPath)('console'),
|
|
19
|
+
'global.console': (0, common_1.resolveStubPath)('console')
|
|
20
|
+
});
|
|
21
|
+
webpackConfig.plugins.push(nodeConfigPlugin);
|
|
22
|
+
webpackConfig.target = 'node14';
|
|
23
|
+
const defineExports = ({ filename }) => {
|
|
24
|
+
const entryName = filename.replace(/\.js$/, '');
|
|
25
|
+
const entrypoint = entrypoints.find((e) => e.name === entryName);
|
|
26
|
+
if (entrypoint) {
|
|
27
|
+
return `__BUNDLED_EXPORTS__ = ${JSON.stringify(entrypoint.functions)};`;
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
};
|
|
31
|
+
webpackConfig.plugins.push(new webpack_1.BannerPlugin({
|
|
32
|
+
banner: defineExports,
|
|
33
|
+
raw: true
|
|
34
|
+
}));
|
|
35
|
+
webpackConfig.name = exports.NODE_WEBPACK_CONFIG_NAME;
|
|
36
|
+
return webpackConfig;
|
|
37
|
+
};
|
|
38
|
+
exports.getNodeRuntimeBuildConfig = getNodeRuntimeBuildConfig;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CommonWebpackConfig, ConfigBuilder, EntryPoint } from './common';
|
|
2
|
+
export declare const SANDBOXED_WEBPACK_CONFIG_NAME = "sandboxed-runtime";
|
|
3
|
+
export declare const getSandboxedRuntimeBuildConfig: (entrypoints: EntryPoint[], config: ConfigBuilder) => CommonWebpackConfig;
|
|
4
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/config/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EAIX,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAyDjE,eAAO,MAAM,8BAA8B,gBAC5B,UAAU,EAAE,UACjB,aAAa,KACpB,mBAwEF,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
6
|
+
const stub_plugin_1 = require("../stub-plugin");
|
|
7
|
+
const common_1 = require("./common");
|
|
8
|
+
exports.SANDBOXED_WEBPACK_CONFIG_NAME = 'sandboxed-runtime';
|
|
9
|
+
const getCustomModulesAliases = () => {
|
|
10
|
+
return {
|
|
11
|
+
'browserify-cipher': (0, common_1.resolveModulePath)('browserify-cipher/browser.js'),
|
|
12
|
+
'browserify-sign/algos': (0, common_1.resolveModulePath)('browserify-sign/algos.js'),
|
|
13
|
+
'browserify-sign': (0, common_1.resolveModulePath)('browserify-sign/browser/index.js'),
|
|
14
|
+
'create-ecdh': (0, common_1.resolveModulePath)('create-ecdh/browser.js'),
|
|
15
|
+
'create-hash/md5': (0, common_1.resolveModulePath)('create-hash/md5.js'),
|
|
16
|
+
'create-hash': (0, common_1.resolveModulePath)('create-hash/browser.js'),
|
|
17
|
+
'create-hmac': (0, common_1.resolveModulePath)('create-hmac/browser.js'),
|
|
18
|
+
'diffie-hellman': (0, common_1.resolveModulePath)('diffie-hellman/browser.js'),
|
|
19
|
+
pbkdf2: (0, common_1.resolveModulePath)('pbkdf2/browser.js'),
|
|
20
|
+
'public-encrypt': (0, common_1.resolveModulePath)('public-encrypt/browser.js'),
|
|
21
|
+
randombytes: (0, common_1.resolveModulePath)('randombytes/browser.js'),
|
|
22
|
+
randomfill: (0, common_1.resolveModulePath)('randomfill/browser.js'),
|
|
23
|
+
assert: (0, common_1.resolveModulePath)('assert/'),
|
|
24
|
+
buffer: (0, common_1.resolveModulePath)('buffer/'),
|
|
25
|
+
console: (0, common_1.resolveModulePath)('console-browserify'),
|
|
26
|
+
crypto: (0, common_1.resolveModulePath)('crypto-browserify'),
|
|
27
|
+
events: (0, common_1.resolveModulePath)('events/'),
|
|
28
|
+
os: (0, common_1.resolveModulePath)('os-browserify/browser'),
|
|
29
|
+
punycode: (0, common_1.resolveModulePath)('punycode/'),
|
|
30
|
+
process: (0, common_1.resolveModulePath)('process/browser.js'),
|
|
31
|
+
string_decoder: (0, common_1.resolveModulePath)('string_decoder/'),
|
|
32
|
+
timers: (0, common_1.resolveModulePath)('timers-browserify'),
|
|
33
|
+
url: (0, common_1.resolveModulePath)('url/'),
|
|
34
|
+
util: (0, common_1.resolveModulePath)('util/'),
|
|
35
|
+
zlib: (0, common_1.resolveModulePath)('browserify-zlib'),
|
|
36
|
+
fs: (0, common_1.resolveModulePath)('memfs'),
|
|
37
|
+
http: (0, common_1.resolveStubPath)('http'),
|
|
38
|
+
https: (0, common_1.resolveStubPath)('http'),
|
|
39
|
+
path: (0, common_1.resolveModulePath)('path-browserify'),
|
|
40
|
+
querystring: (0, common_1.resolveModulePath)('querystring-browser'),
|
|
41
|
+
stream: (0, common_1.resolveModulePath)('readable-stream'),
|
|
42
|
+
'supports-color': (0, common_1.resolveModulePath)('supports-color/index.js')
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
46
|
+
const webpackConfig = (0, common_1.getCommonWebpackConfig)(entrypoints, config);
|
|
47
|
+
const sandboxedConfigPlugins = [
|
|
48
|
+
new webpack_1.default.ProvidePlugin({
|
|
49
|
+
Buffer: [(0, common_1.resolveModulePath)('buffer/'), 'Buffer'],
|
|
50
|
+
path: (0, common_1.resolveModulePath)('path-browserify'),
|
|
51
|
+
querystring: (0, common_1.resolveModulePath)('querystring-browser'),
|
|
52
|
+
stream: (0, common_1.resolveModulePath)('readable-stream'),
|
|
53
|
+
TextDecoder: [(0, common_1.resolveModulePath)('text-encoder-lite'), 'TextDecoderLite'],
|
|
54
|
+
TextEncoder: [(0, common_1.resolveModulePath)('text-encoder-lite'), 'TextEncoderLite'],
|
|
55
|
+
URL: [(0, common_1.resolveModulePath)('whatwg-url'), 'URL'],
|
|
56
|
+
URLSearchParams: [(0, common_1.resolveModulePath)('whatwg-url'), 'URLSearchParams']
|
|
57
|
+
}),
|
|
58
|
+
new stub_plugin_1.StubPlugin({
|
|
59
|
+
modules: [
|
|
60
|
+
'async_hooks',
|
|
61
|
+
'child_process',
|
|
62
|
+
'cluster',
|
|
63
|
+
'constants',
|
|
64
|
+
'dgram',
|
|
65
|
+
'dns',
|
|
66
|
+
'domain',
|
|
67
|
+
'http2',
|
|
68
|
+
'module',
|
|
69
|
+
'net',
|
|
70
|
+
'perf_hooks',
|
|
71
|
+
'readline',
|
|
72
|
+
'repl',
|
|
73
|
+
'sys',
|
|
74
|
+
'tls',
|
|
75
|
+
'trace_events',
|
|
76
|
+
'tty',
|
|
77
|
+
'v8',
|
|
78
|
+
'vm',
|
|
79
|
+
'worker_threads'
|
|
80
|
+
],
|
|
81
|
+
placeholder: 'requestedModule',
|
|
82
|
+
stub: (0, common_1.resolveStubPath)('unsupported')
|
|
83
|
+
})
|
|
84
|
+
];
|
|
85
|
+
sandboxedConfigPlugins.forEach((plugin) => webpackConfig.plugins.push(plugin));
|
|
86
|
+
const moduleRuls = [
|
|
87
|
+
{
|
|
88
|
+
test: /(readable-stream|pbkdf2|util)\//,
|
|
89
|
+
resolve: {
|
|
90
|
+
aliasFields: ['browser']
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
test: /axios\//,
|
|
95
|
+
resolve: {
|
|
96
|
+
aliasFields: []
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
moduleRuls.forEach((rule) => webpackConfig.module.rules.push(rule));
|
|
101
|
+
webpackConfig.target = 'webworker';
|
|
102
|
+
webpackConfig.resolve = Object.assign(Object.assign({}, webpackConfig.resolve), { mainFields: ['main', 'module'], exportsFields: [], alias: getCustomModulesAliases() });
|
|
103
|
+
webpackConfig.name = exports.SANDBOXED_WEBPACK_CONFIG_NAME;
|
|
104
|
+
return webpackConfig;
|
|
105
|
+
};
|
|
106
|
+
exports.getSandboxedRuntimeBuildConfig = getSandboxedRuntimeBuildConfig;
|
package/out/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Bundler, InDiskBundler, Watcher, WatcherMonitor, BundlerOutput } from './types';
|
|
2
2
|
export { sandboxBundle, nodeBundle, nativeUiBundle, watch, getCompiler, getInMemoryBundle, handleWebpackCompilationResult, runLinter } from './webpack';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { EntryPoint, FunctionsEntryPoint, getEntryPoints } from './config/common';
|
|
4
|
+
export { getNativeUiBuildConfig } from './config/nativeui';
|
|
5
|
+
export { getSandboxedRuntimeBuildConfig } from './config/sandbox';
|
|
5
6
|
//# 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,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,8BAA8B,EAC9B,SAAS,EACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,8BAA8B,EAC9B,SAAS,EACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSandboxedRuntimeBuildConfig = exports.getNativeUiBuildConfig = exports.runLinter = exports.handleWebpackCompilationResult = exports.getInMemoryBundle = exports.getCompiler = exports.watch = exports.nativeUiBundle = exports.nodeBundle = exports.sandboxBundle = void 0;
|
|
3
|
+
exports.getSandboxedRuntimeBuildConfig = exports.getNativeUiBuildConfig = exports.getEntryPoints = exports.runLinter = exports.handleWebpackCompilationResult = exports.getInMemoryBundle = exports.getCompiler = exports.watch = exports.nativeUiBundle = exports.nodeBundle = exports.sandboxBundle = void 0;
|
|
4
4
|
var webpack_1 = require("./webpack");
|
|
5
5
|
Object.defineProperty(exports, "sandboxBundle", { enumerable: true, get: function () { return webpack_1.sandboxBundle; } });
|
|
6
6
|
Object.defineProperty(exports, "nodeBundle", { enumerable: true, get: function () { return webpack_1.nodeBundle; } });
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "getCompiler", { enumerable: true, get: function
|
|
|
10
10
|
Object.defineProperty(exports, "getInMemoryBundle", { enumerable: true, get: function () { return webpack_1.getInMemoryBundle; } });
|
|
11
11
|
Object.defineProperty(exports, "handleWebpackCompilationResult", { enumerable: true, get: function () { return webpack_1.handleWebpackCompilationResult; } });
|
|
12
12
|
Object.defineProperty(exports, "runLinter", { enumerable: true, get: function () { return webpack_1.runLinter; } });
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "
|
|
13
|
+
var common_1 = require("./config/common");
|
|
14
|
+
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
|
|
15
|
+
var nativeui_1 = require("./config/nativeui");
|
|
16
|
+
Object.defineProperty(exports, "getNativeUiBuildConfig", { enumerable: true, get: function () { return nativeui_1.getNativeUiBuildConfig; } });
|
|
17
|
+
var sandbox_1 = require("./config/sandbox");
|
|
18
|
+
Object.defineProperty(exports, "getSandboxedRuntimeBuildConfig", { enumerable: true, get: function () { return sandbox_1.getSandboxedRuntimeBuildConfig; } });
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/stubs/console.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAM,cAAc,QAAS,GAAG,KAAG,GAsBzC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.starSerializer = void 0;
|
|
4
4
|
const bunyan_1 = require("bunyan");
|
|
5
|
+
const api_1 = require("@forge/api");
|
|
5
6
|
const isNonEmptyArray = (arr) => arr.length > 0;
|
|
6
7
|
function transformSandBoxLogMessage(message) {
|
|
7
8
|
let msg = '', starval = [];
|
|
@@ -69,7 +70,7 @@ const logger = (0, bunyan_1.createLogger)({
|
|
|
69
70
|
});
|
|
70
71
|
function customConsole(logMethod) {
|
|
71
72
|
return (...rawData) => {
|
|
72
|
-
const context =
|
|
73
|
+
const context = (0, api_1.getRuntime)().lambdaContext;
|
|
73
74
|
if (isNonEmptyArray(rawData)) {
|
|
74
75
|
const logEventData = {
|
|
75
76
|
invocationId: context === null || context === void 0 ? void 0 : context.awsRequestId,
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-impl.ts"],"names":[],"mappings":";;;AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC1D,OAAO,EAAe,YAAY,EAAS,MAAM,YAAY,CAAC;AAsB9D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAMD,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI;IAatF,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM/C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAQhE,OAAO,CAAC,KAAK;IAsBN,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAe3F,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;IAmCjD,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EACtC,gBAAgB,EAAE,gBAAgB,GACjC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE;CA8BvC;AAID,qBAAa,KAAK;gBACJ,OAAO,EAAE,YAAY;CAOlC"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/stubs/http.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"unsupported.d.ts","sourceRoot":"","sources":["../../src/stubs/unsupported.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/stubs/wrapper.ts"],"names":[],"mappings":""}
|