@forge/bundler 3.0.9 → 3.0.10-next.2
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 +22 -0
- package/out/bundler-config/node-webpack-config.d.ts +4 -0
- package/out/bundler-config/node-webpack-config.d.ts.map +1 -0
- package/out/bundler-config/node-webpack-config.js +17 -0
- package/out/bundler-config/sandboxed-webpack-config.d.ts +4 -0
- package/out/bundler-config/sandboxed-webpack-config.d.ts.map +1 -0
- package/out/bundler-config/sandboxed-webpack-config.js +104 -0
- package/out/forge-api.d.ts +7 -0
- package/out/forge-api.d.ts.map +1 -0
- package/out/forge-api.js +15 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/webpack.d.ts +10 -4
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +43 -114
- package/out/wrapper.d.ts +2 -0
- package/out/wrapper.d.ts.map +1 -0
- package/out/wrapper.js +49 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 3.0.10-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 13f2ae81: Created a new bundler for the node runtime
|
|
8
|
+
- @forge/cli-shared@2.6.1-next.2
|
|
9
|
+
- @forge/lint@3.2.1-next.2
|
|
10
|
+
|
|
11
|
+
## 3.0.10-next.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @forge/cli-shared@2.6.1-next.1
|
|
16
|
+
- @forge/lint@3.2.1-next.1
|
|
17
|
+
|
|
18
|
+
## 3.0.10-next.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @forge/cli-shared@2.6.1-next.0
|
|
23
|
+
- @forge/lint@3.2.1-next.0
|
|
24
|
+
|
|
3
25
|
## 3.0.9
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;AAEhF,eAAO,MAAM,yBAAyB,qCAAsC,aAAa,KAAG,aAY3F,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
exports.getNodeRuntimeBuildConfig = (entrypoints, config) => {
|
|
9
|
+
const webpackConfig = webpack_2.getCommonWebpackConfig(entrypoints, config);
|
|
10
|
+
const nodeConfigPlugin = new webpack_1.default.ProvidePlugin({
|
|
11
|
+
api: path_1.resolve(path_1.join(__dirname, '..', 'forge-api')),
|
|
12
|
+
'global.api': path_1.resolve(path_1.join(__dirname, '..', 'forge-api'))
|
|
13
|
+
});
|
|
14
|
+
webpackConfig.plugins.push(nodeConfigPlugin);
|
|
15
|
+
webpackConfig.target = 'node14';
|
|
16
|
+
return webpackConfig;
|
|
17
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Configuration as WebpackConfig } from 'webpack';
|
|
2
|
+
import { ConfigBuilder, EntryPoints } from '../webpack';
|
|
3
|
+
export declare const getSandboxedRuntimeBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
|
|
4
|
+
//# sourceMappingURL=sandboxed-webpack-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AA0DnG,eAAO,MAAM,8BAA8B,qCAAsC,aAAa,KAAG,aAsEhG,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSandboxedRuntimeBuildConfig = 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
|
+
const getCustomModulesAliases = () => {
|
|
10
|
+
return {
|
|
11
|
+
'browserify-cipher': webpack_2.resolveModulePath('browserify-cipher/browser.js'),
|
|
12
|
+
'browserify-sign/algos': webpack_2.resolveModulePath('browserify-sign/algos.js'),
|
|
13
|
+
'browserify-sign': webpack_2.resolveModulePath('browserify-sign/browser/index.js'),
|
|
14
|
+
'create-ecdh': webpack_2.resolveModulePath('create-ecdh/browser.js'),
|
|
15
|
+
'create-hash/md5': webpack_2.resolveModulePath('create-hash/md5.js'),
|
|
16
|
+
'create-hash': webpack_2.resolveModulePath('create-hash/browser.js'),
|
|
17
|
+
'create-hmac': webpack_2.resolveModulePath('create-hmac/browser.js'),
|
|
18
|
+
'diffie-hellman': webpack_2.resolveModulePath('diffie-hellman/browser.js'),
|
|
19
|
+
pbkdf2: webpack_2.resolveModulePath('pbkdf2/browser.js'),
|
|
20
|
+
'public-encrypt': webpack_2.resolveModulePath('public-encrypt/browser.js'),
|
|
21
|
+
randombytes: webpack_2.resolveModulePath('randombytes/browser.js'),
|
|
22
|
+
randomfill: webpack_2.resolveModulePath('randomfill/browser.js'),
|
|
23
|
+
assert: webpack_2.resolveModulePath('assert/'),
|
|
24
|
+
buffer: webpack_2.resolveModulePath('buffer/'),
|
|
25
|
+
console: webpack_2.resolveModulePath('console-browserify'),
|
|
26
|
+
crypto: webpack_2.resolveModulePath('crypto-browserify'),
|
|
27
|
+
events: webpack_2.resolveModulePath('events/'),
|
|
28
|
+
os: webpack_2.resolveModulePath('os-browserify/browser'),
|
|
29
|
+
punycode: webpack_2.resolveModulePath('punycode/'),
|
|
30
|
+
process: webpack_2.resolveModulePath('process/browser.js'),
|
|
31
|
+
string_decoder: webpack_2.resolveModulePath('string_decoder/'),
|
|
32
|
+
timers: webpack_2.resolveModulePath('timers-browserify'),
|
|
33
|
+
url: webpack_2.resolveModulePath('url/'),
|
|
34
|
+
util: webpack_2.resolveModulePath('util/'),
|
|
35
|
+
zlib: webpack_2.resolveModulePath('browserify-zlib'),
|
|
36
|
+
fs: webpack_2.resolveModulePath('memfs'),
|
|
37
|
+
http: webpack_2.resolveModulePath('./http'),
|
|
38
|
+
https: webpack_2.resolveModulePath('./http'),
|
|
39
|
+
path: webpack_2.resolveModulePath('path-browserify'),
|
|
40
|
+
querystring: webpack_2.resolveModulePath('querystring-browser'),
|
|
41
|
+
stream: webpack_2.resolveModulePath('readable-stream'),
|
|
42
|
+
'supports-color': webpack_2.resolveModulePath('supports-color/index.js')
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
46
|
+
const webpackConfig = webpack_2.getCommonWebpackConfig(entrypoints, config);
|
|
47
|
+
const sandboxedConfigPlugins = [
|
|
48
|
+
new webpack_1.default.ProvidePlugin({
|
|
49
|
+
Buffer: [webpack_2.resolveModulePath('buffer/'), 'Buffer'],
|
|
50
|
+
path: webpack_2.resolveModulePath('path-browserify'),
|
|
51
|
+
querystring: webpack_2.resolveModulePath('querystring-browser'),
|
|
52
|
+
stream: webpack_2.resolveModulePath('readable-stream'),
|
|
53
|
+
TextDecoder: [webpack_2.resolveModulePath('text-encoder-lite'), 'TextDecoderLite'],
|
|
54
|
+
TextEncoder: [webpack_2.resolveModulePath('text-encoder-lite'), 'TextEncoderLite'],
|
|
55
|
+
URL: [webpack_2.resolveModulePath('whatwg-url'), 'URL'],
|
|
56
|
+
URLSearchParams: [webpack_2.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: path_1.resolve(__dirname, '..', '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
|
+
return webpackConfig;
|
|
104
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestInfo, RequestInit, Response } from 'node-fetch';
|
|
2
|
+
export declare function fetch(url: RequestInfo, init: RequestInit): Promise<Response>;
|
|
3
|
+
export declare const requestJira: undefined;
|
|
4
|
+
export declare function asApp(): {
|
|
5
|
+
__requestAtlassian: () => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=forge-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forge-api.d.ts","sourceRoot":"","sources":["../src/forge-api.ts"],"names":[],"mappings":"AAIA,OAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3E,wBAAsB,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgBlF;AACD,eAAO,MAAM,WAAW,WAAS,CAAC;AAClC,wBAAgB,KAAK,IAAI;IAAE,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAAE,CAE1D"}
|
package/out/forge-api.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asApp = exports.requestJira = exports.fetch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
6
|
+
async function fetch(url, init) {
|
|
7
|
+
const result = await node_fetch_1.default(url, init);
|
|
8
|
+
return Object.assign(Object.assign({}, result), { json: () => result.json(), clone: () => result.clone(), arrayBuffer: () => result.arrayBuffer(), blob: () => result.blob(), buffer: () => result.buffer(), text: () => result.text(), textConverted: () => result.textConverted() });
|
|
9
|
+
}
|
|
10
|
+
exports.fetch = fetch;
|
|
11
|
+
exports.requestJira = void 0;
|
|
12
|
+
function asApp() {
|
|
13
|
+
return { __requestAtlassian: () => void 0 };
|
|
14
|
+
}
|
|
15
|
+
exports.asApp = asApp;
|
package/out/index.d.ts
CHANGED
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,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var webpack_1 = require("./webpack");
|
|
4
|
-
Object.defineProperty(exports, "
|
|
4
|
+
Object.defineProperty(exports, "sandboxBundle", { enumerable: true, get: function () { return webpack_1.sandboxBundle; } });
|
|
5
|
+
Object.defineProperty(exports, "nodeBundle", { enumerable: true, get: function () { return webpack_1.nodeBundle; } });
|
|
5
6
|
Object.defineProperty(exports, "watch", { enumerable: true, get: function () { return webpack_1.watch; } });
|
package/out/webpack.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { Configuration as WebpackConfig } from 'webpack';
|
|
1
|
+
import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
|
|
2
2
|
import { Bundler, Watcher } from './types';
|
|
3
3
|
export declare type EntryPoints = Array<{
|
|
4
4
|
name: string;
|
|
5
5
|
path: string;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
7
|
+
export declare const resolveModulePath: (moduleName: string) => string;
|
|
8
|
+
export declare const getDevToolConfig: (config: ConfigBuilder) => string;
|
|
9
|
+
declare type RequiredFields<T, F extends keyof T> = T & Required<Pick<T, F>>;
|
|
10
|
+
declare type CommonModuleOptions = RequiredFields<ModuleOptions, 'rules'>;
|
|
11
|
+
declare type CommonWebpackConfig = RequiredFields<WebpackConfig, 'plugins' | 'module'> & Record<'module', CommonModuleOptions>;
|
|
12
|
+
export declare const getCommonWebpackConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => CommonWebpackConfig;
|
|
13
|
+
export interface ConfigBuilder {
|
|
8
14
|
isWatchMode: boolean;
|
|
9
15
|
isDebugMode?: boolean;
|
|
10
16
|
appDirectory: string;
|
|
11
17
|
}
|
|
12
|
-
export declare const getDevToolConfig: (config: ConfigBuilder) => string;
|
|
13
18
|
export declare const watch: Watcher;
|
|
14
19
|
export declare const createBundler: (getBuildConfig: (entrypoints: EntryPoints, configBuilder: ConfigBuilder) => WebpackConfig) => Bundler;
|
|
15
|
-
export declare const
|
|
20
|
+
export declare const sandboxBundle: Bundler;
|
|
21
|
+
export declare const nodeBundle: Bundler;
|
|
16
22
|
export {};
|
|
17
23
|
//# 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":"AAGA,OAAgB,EAAY,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAY,aAAa,IAAI,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAkC,OAAO,EAAkB,MAAM,SAAS,CAAC;AAe3F,oBAAY,WAAW,GAAG,KAAK,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAQH,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,MAEtD,CAAC;AAsCF,eAAO,MAAM,gBAAgB,WAAY,aAAa,KAAG,MASxD,CAAC;AACF,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,aAAK,mBAAmB,GAAG,cAAc,CAAC,aAAa,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AACvH,eAAO,MAAM,sBAAsB,qCAAsC,aAAa,KAAG,mBA8FxF,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAiED,eAAO,MAAM,KAAK,EAAE,OAwCnB,CAAC;AAEF,eAAO,MAAM,aAAa,6DACkC,aAAa,KAAK,aAAa,KACxF,OAyCF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAAuD,CAAC;AAEpF,eAAO,MAAM,UAAU,EAAE,OAwBxB,CAAC"}
|
package/out/webpack.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.nodeBundle = exports.sandboxBundle = exports.createBundler = exports.watch = exports.getCommonWebpackConfig = exports.getDevToolConfig = exports.resolveModulePath = 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
7
|
const path_1 = require("path");
|
|
8
8
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
9
|
-
const stub_plugin_1 = require("./stub-plugin");
|
|
10
9
|
const text_1 = require("./text");
|
|
11
10
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
12
11
|
const lint_1 = require("@forge/lint");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const sandboxed_webpack_config_1 = require("./bundler-config/sandboxed-webpack-config");
|
|
14
|
+
const node_webpack_config_1 = require("./bundler-config/node-webpack-config");
|
|
13
15
|
const tsconfig_interactor_1 = require("./tsconfig-interactor");
|
|
14
16
|
const compilerOutputFileSystem = memfs_1.createFsFromVolume(new memfs_1.Volume());
|
|
15
17
|
const readMemoryFileSync = (filePath) => {
|
|
16
18
|
return compilerOutputFileSystem.readFileSync(filePath, { encoding: 'utf8' }).toString();
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
exports.resolveModulePath = (moduleName) => {
|
|
19
21
|
return require.resolve(moduleName);
|
|
20
22
|
};
|
|
21
23
|
const handleCallback = (err, stats) => {
|
|
@@ -50,43 +52,7 @@ exports.getDevToolConfig = (config) => {
|
|
|
50
52
|
}
|
|
51
53
|
return config.isDebugMode ? 'eval-cheap-module-source-map' : 'cheap-source-map';
|
|
52
54
|
};
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
'browserify-cipher': resolveModulePath('browserify-cipher/browser.js'),
|
|
56
|
-
'browserify-sign/algos': resolveModulePath('browserify-sign/algos.js'),
|
|
57
|
-
'browserify-sign': resolveModulePath('browserify-sign/browser/index.js'),
|
|
58
|
-
'create-ecdh': resolveModulePath('create-ecdh/browser.js'),
|
|
59
|
-
'create-hash/md5': resolveModulePath('create-hash/md5.js'),
|
|
60
|
-
'create-hash': resolveModulePath('create-hash/browser.js'),
|
|
61
|
-
'create-hmac': resolveModulePath('create-hmac/browser.js'),
|
|
62
|
-
'diffie-hellman': resolveModulePath('diffie-hellman/browser.js'),
|
|
63
|
-
pbkdf2: resolveModulePath('pbkdf2/browser.js'),
|
|
64
|
-
'public-encrypt': resolveModulePath('public-encrypt/browser.js'),
|
|
65
|
-
randombytes: resolveModulePath('randombytes/browser.js'),
|
|
66
|
-
randomfill: resolveModulePath('randomfill/browser.js'),
|
|
67
|
-
assert: resolveModulePath('assert/'),
|
|
68
|
-
buffer: resolveModulePath('buffer/'),
|
|
69
|
-
console: resolveModulePath('console-browserify'),
|
|
70
|
-
crypto: resolveModulePath('crypto-browserify'),
|
|
71
|
-
events: resolveModulePath('events/'),
|
|
72
|
-
os: resolveModulePath('os-browserify/browser'),
|
|
73
|
-
punycode: resolveModulePath('punycode/'),
|
|
74
|
-
process: resolveModulePath('process/browser.js'),
|
|
75
|
-
string_decoder: resolveModulePath('string_decoder/'),
|
|
76
|
-
timers: resolveModulePath('timers-browserify'),
|
|
77
|
-
url: resolveModulePath('url/'),
|
|
78
|
-
util: resolveModulePath('util/'),
|
|
79
|
-
zlib: resolveModulePath('browserify-zlib'),
|
|
80
|
-
fs: resolveModulePath('memfs'),
|
|
81
|
-
http: resolveModulePath('./http'),
|
|
82
|
-
https: resolveModulePath('./http'),
|
|
83
|
-
path: resolveModulePath('path-browserify'),
|
|
84
|
-
querystring: resolveModulePath('querystring-browser'),
|
|
85
|
-
stream: resolveModulePath('readable-stream'),
|
|
86
|
-
'supports-color': resolveModulePath('supports-color/index.js')
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
55
|
+
exports.getCommonWebpackConfig = (entrypoints, config) => {
|
|
90
56
|
if (!require.main) {
|
|
91
57
|
throw new Error(text_1.Text.noExecutableFile);
|
|
92
58
|
}
|
|
@@ -97,7 +63,6 @@ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
97
63
|
return {
|
|
98
64
|
entry: Object.assign({}, resolvedEntryPoints),
|
|
99
65
|
mode: 'production',
|
|
100
|
-
target: 'webworker',
|
|
101
66
|
optimization: {
|
|
102
67
|
minimize: false
|
|
103
68
|
},
|
|
@@ -108,20 +73,19 @@ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
108
73
|
filename: '[name].js',
|
|
109
74
|
path: '/'
|
|
110
75
|
},
|
|
76
|
+
node: {
|
|
77
|
+
__dirname: true
|
|
78
|
+
},
|
|
79
|
+
performance: false,
|
|
80
|
+
resolve: {
|
|
81
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
82
|
+
},
|
|
83
|
+
resolveLoader: {
|
|
84
|
+
modules: require.resolve.paths('babel-loader') || undefined
|
|
85
|
+
},
|
|
86
|
+
plugins: [new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ })],
|
|
111
87
|
module: {
|
|
112
88
|
rules: [
|
|
113
|
-
{
|
|
114
|
-
test: /(readable-stream|pbkdf2|util)\//,
|
|
115
|
-
resolve: {
|
|
116
|
-
aliasFields: ['browser']
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
test: /axios\//,
|
|
121
|
-
resolve: {
|
|
122
|
-
aliasFields: []
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
89
|
{
|
|
126
90
|
test: /\.jsx?$/,
|
|
127
91
|
exclude: /node_modules/,
|
|
@@ -131,7 +95,7 @@ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
131
95
|
options: {
|
|
132
96
|
presets: [
|
|
133
97
|
[
|
|
134
|
-
resolveModulePath('@babel/preset-typescript'),
|
|
98
|
+
exports.resolveModulePath('@babel/preset-typescript'),
|
|
135
99
|
{
|
|
136
100
|
isTSX: true,
|
|
137
101
|
jsxPragma: 'ForgeUI',
|
|
@@ -141,15 +105,15 @@ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
141
105
|
],
|
|
142
106
|
plugins: [
|
|
143
107
|
[
|
|
144
|
-
resolveModulePath('@babel/plugin-transform-react-jsx'),
|
|
108
|
+
exports.resolveModulePath('@babel/plugin-transform-react-jsx'),
|
|
145
109
|
{
|
|
146
110
|
pragma: 'ForgeUI.createElement'
|
|
147
111
|
}
|
|
148
112
|
],
|
|
149
|
-
resolveModulePath('@forge/babel-plugin-transform-ui'),
|
|
150
|
-
resolveModulePath('@babel/plugin-proposal-numeric-separator'),
|
|
151
|
-
resolveModulePath('@babel/plugin-proposal-class-properties'),
|
|
152
|
-
resolveModulePath('@babel/plugin-proposal-optional-chaining')
|
|
113
|
+
exports.resolveModulePath('@forge/babel-plugin-transform-ui'),
|
|
114
|
+
exports.resolveModulePath('@babel/plugin-proposal-numeric-separator'),
|
|
115
|
+
exports.resolveModulePath('@babel/plugin-proposal-class-properties'),
|
|
116
|
+
exports.resolveModulePath('@babel/plugin-proposal-optional-chaining')
|
|
153
117
|
],
|
|
154
118
|
cacheDirectory: true
|
|
155
119
|
}
|
|
@@ -174,59 +138,7 @@ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
174
138
|
]
|
|
175
139
|
}
|
|
176
140
|
]
|
|
177
|
-
}
|
|
178
|
-
node: {
|
|
179
|
-
__dirname: true
|
|
180
|
-
},
|
|
181
|
-
performance: false,
|
|
182
|
-
resolve: {
|
|
183
|
-
mainFields: ['main', 'module'],
|
|
184
|
-
exportsFields: [],
|
|
185
|
-
alias: getCustomModulesAliases(),
|
|
186
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
187
|
-
},
|
|
188
|
-
resolveLoader: {
|
|
189
|
-
modules: require.resolve.paths('babel-loader') || undefined
|
|
190
|
-
},
|
|
191
|
-
plugins: [
|
|
192
|
-
new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ }),
|
|
193
|
-
new webpack_1.default.ProvidePlugin({
|
|
194
|
-
Buffer: [resolveModulePath('buffer/'), 'Buffer'],
|
|
195
|
-
path: resolveModulePath('path-browserify'),
|
|
196
|
-
querystring: resolveModulePath('querystring-browser'),
|
|
197
|
-
stream: resolveModulePath('readable-stream'),
|
|
198
|
-
TextDecoder: [resolveModulePath('text-encoder-lite'), 'TextDecoderLite'],
|
|
199
|
-
TextEncoder: [resolveModulePath('text-encoder-lite'), 'TextEncoderLite'],
|
|
200
|
-
URL: [resolveModulePath('whatwg-url'), 'URL'],
|
|
201
|
-
URLSearchParams: [resolveModulePath('whatwg-url'), 'URLSearchParams']
|
|
202
|
-
}),
|
|
203
|
-
new stub_plugin_1.StubPlugin({
|
|
204
|
-
modules: [
|
|
205
|
-
'async_hooks',
|
|
206
|
-
'child_process',
|
|
207
|
-
'cluster',
|
|
208
|
-
'constants',
|
|
209
|
-
'dgram',
|
|
210
|
-
'dns',
|
|
211
|
-
'domain',
|
|
212
|
-
'http2',
|
|
213
|
-
'module',
|
|
214
|
-
'net',
|
|
215
|
-
'perf_hooks',
|
|
216
|
-
'readline',
|
|
217
|
-
'repl',
|
|
218
|
-
'sys',
|
|
219
|
-
'tls',
|
|
220
|
-
'trace_events',
|
|
221
|
-
'tty',
|
|
222
|
-
'v8',
|
|
223
|
-
'vm',
|
|
224
|
-
'worker_threads'
|
|
225
|
-
],
|
|
226
|
-
placeholder: 'requestedModule',
|
|
227
|
-
stub: path_1.resolve(__dirname, 'unsupported')
|
|
228
|
-
})
|
|
229
|
-
]
|
|
141
|
+
}
|
|
230
142
|
};
|
|
231
143
|
};
|
|
232
144
|
const getCompiler = (webpackConfig) => {
|
|
@@ -285,7 +197,7 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
|
|
|
285
197
|
}
|
|
286
198
|
};
|
|
287
199
|
exports.watch = (entryPoints, debugMode, callback, watchRun) => {
|
|
288
|
-
const config = getSandboxedRuntimeBuildConfig(entryPoints, {
|
|
200
|
+
const config = sandboxed_webpack_config_1.getSandboxedRuntimeBuildConfig(entryPoints, {
|
|
289
201
|
isWatchMode: true,
|
|
290
202
|
isDebugMode: debugMode,
|
|
291
203
|
appDirectory: process.cwd()
|
|
@@ -354,4 +266,21 @@ exports.createBundler = (getBuildConfig) => {
|
|
|
354
266
|
});
|
|
355
267
|
};
|
|
356
268
|
};
|
|
357
|
-
exports.
|
|
269
|
+
exports.sandboxBundle = exports.createBundler(sandboxed_webpack_config_1.getSandboxedRuntimeBuildConfig);
|
|
270
|
+
exports.nodeBundle = async (appDirectory, entryPoints) => {
|
|
271
|
+
const bundler = exports.createBundler(node_webpack_config_1.getNodeRuntimeBuildConfig);
|
|
272
|
+
const { output: bundlerOutput, sourceMap: bundlerSourceMap, metadata } = await bundler(appDirectory, entryPoints);
|
|
273
|
+
const wrapper = fs_1.readFileSync(path_1.join(__dirname, 'wrapper.js')).toString();
|
|
274
|
+
const output = {};
|
|
275
|
+
const sourceMap = {};
|
|
276
|
+
entryPoints.forEach(({ name }) => {
|
|
277
|
+
const wrappedName = 'bundled/' + name;
|
|
278
|
+
output[wrappedName] = bundlerOutput[name];
|
|
279
|
+
const sourceMapValue = bundlerSourceMap === null || bundlerSourceMap === void 0 ? void 0 : bundlerSourceMap[name];
|
|
280
|
+
if (sourceMapValue) {
|
|
281
|
+
sourceMap[wrappedName] = sourceMapValue;
|
|
282
|
+
}
|
|
283
|
+
output[name] = wrapper.replace("'__MODULE__'", JSON.stringify('./' + wrappedName));
|
|
284
|
+
});
|
|
285
|
+
return { output, sourceMap, metadata };
|
|
286
|
+
};
|
package/out/wrapper.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../src/wrapper.js"],"names":[],"mappings":""}
|
package/out/wrapper.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function createInstallationContext({ contextAri }) {
|
|
3
|
+
const ari = {};
|
|
4
|
+
if (ari.resourceType === 'project') {
|
|
5
|
+
return { projectId: ari.resourceId, installContext: contextAri };
|
|
6
|
+
}
|
|
7
|
+
if (ari.resourceType === 'repository') {
|
|
8
|
+
return { repositoryId: ari.resourceId, installContext: contextAri };
|
|
9
|
+
}
|
|
10
|
+
return { installContext: contextAri };
|
|
11
|
+
}
|
|
12
|
+
function isAccountIdDefined(accountId) {
|
|
13
|
+
return accountId !== undefined && accountId !== 'undefined';
|
|
14
|
+
}
|
|
15
|
+
function createPrincipal({ aaid: accountId }) {
|
|
16
|
+
return isAccountIdDefined(accountId) ? { accountId } : undefined;
|
|
17
|
+
}
|
|
18
|
+
function createLicenseContext({ license }) {
|
|
19
|
+
if (license) {
|
|
20
|
+
return {
|
|
21
|
+
license: {
|
|
22
|
+
isActive: license.isActive ? true : false
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function setupRequestContext(meta) {
|
|
28
|
+
return Object.assign(Object.assign({ principal: createPrincipal(meta) }, createLicenseContext(meta)), createInstallationContext(meta));
|
|
29
|
+
}
|
|
30
|
+
const adapter = (fn) => {
|
|
31
|
+
if (typeof fn === 'function') {
|
|
32
|
+
return async (lambdaEvent, _lambdaContext) => {
|
|
33
|
+
const event = lambdaEvent.body;
|
|
34
|
+
const context = setupRequestContext(lambdaEvent._meta);
|
|
35
|
+
const result = await fn(event, context);
|
|
36
|
+
return {
|
|
37
|
+
body: result,
|
|
38
|
+
metrics: []
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return fn;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const bundled = require('__MODULE__');
|
|
47
|
+
for (const key in bundled) {
|
|
48
|
+
exports[key] = adapter(bundled[key]);
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10-next.2",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@babel/preset-typescript": "^7.16.7",
|
|
21
21
|
"@forge/api": "2.7.0",
|
|
22
22
|
"@forge/babel-plugin-transform-ui": "1.1.0",
|
|
23
|
-
"@forge/cli-shared": "2.6.
|
|
24
|
-
"@forge/lint": "3.2.
|
|
23
|
+
"@forge/cli-shared": "2.6.1-next.2",
|
|
24
|
+
"@forge/lint": "3.2.1-next.2",
|
|
25
25
|
"assert": "^1.1.1",
|
|
26
26
|
"babel-loader": "^8.2.3",
|
|
27
27
|
"browserify-zlib": "^0.2.0",
|