@forge/bundler 4.20.10-next.1 → 4.21.0-next.3
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 +19 -0
- package/out/common.d.ts +7 -0
- package/out/common.d.ts.map +1 -0
- package/out/common.js +21 -0
- package/out/config/common.d.ts +1 -3
- package/out/config/common.d.ts.map +1 -1
- package/out/config/common.js +3 -10
- package/out/index.d.ts +4 -3
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -5
- package/out/lint.d.ts +4 -0
- package/out/lint.d.ts.map +1 -0
- package/out/lint.js +35 -0
- package/out/runtime.d.ts +4 -2
- package/out/runtime.d.ts.map +1 -1
- package/out/runtime.js +22 -26
- package/out/types.d.ts +2 -2
- package/out/types.d.ts.map +1 -1
- package/out/webpack.d.ts +1 -4
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +5 -34
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 4.21.0-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @forge/api@5.1.1-next.1
|
|
8
|
+
|
|
9
|
+
## 4.21.0-next.2
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 30f197e: Refactoring to enable alternate bundler support
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [70cd30c]
|
|
18
|
+
- Updated dependencies [30f197e]
|
|
19
|
+
- @forge/cli-shared@6.6.2-next.1
|
|
20
|
+
- @forge/lint@5.7.2-next.1
|
|
21
|
+
|
|
3
22
|
## 4.20.10-next.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/out/common.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Handler } from '@forge/cli-shared';
|
|
2
|
+
import { BundlerArgs, EntryPoint } from './types';
|
|
3
|
+
export declare function getOutputDir(args: Pick<BundlerArgs, 'watchMode'>): string;
|
|
4
|
+
export declare const SOURCE_DIR = "src";
|
|
5
|
+
export declare const NODE_MODULES_DIR = "node_modules";
|
|
6
|
+
export declare function getEntryPoints(handlers: Handler[]): EntryPoint[];
|
|
7
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAmC,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,MAAM,CAKzE;AAED,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAOhE"}
|
package/out/common.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntryPoints = exports.NODE_MODULES_DIR = exports.SOURCE_DIR = exports.getOutputDir = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
|
+
function getOutputDir(args) {
|
|
8
|
+
const outputDir = args.watchMode === 'debug' ? path_1.default.resolve(cli_shared_1.TUNNEL_BUNDLE_DIRECTORY) : (0, cli_shared_1.tmpDir)('dist');
|
|
9
|
+
return outputDir;
|
|
10
|
+
}
|
|
11
|
+
exports.getOutputDir = getOutputDir;
|
|
12
|
+
exports.SOURCE_DIR = 'src';
|
|
13
|
+
exports.NODE_MODULES_DIR = 'node_modules';
|
|
14
|
+
function getEntryPoints(handlers) {
|
|
15
|
+
const modules = new Set(handlers.map(({ module }) => module));
|
|
16
|
+
return Array.from(modules).map((module) => ({
|
|
17
|
+
name: module,
|
|
18
|
+
path: path_1.default.resolve(exports.SOURCE_DIR, module)
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
exports.getEntryPoints = getEntryPoints;
|
package/out/config/common.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
|
|
3
|
-
import { Handler } from '@forge/cli-shared';
|
|
4
3
|
import { Translations } from '@forge/manifest';
|
|
5
|
-
import { BundlerArgs
|
|
6
|
-
export declare function getEntryPoints(handlers: Handler[]): EntryPoint[];
|
|
4
|
+
import { BundlerArgs } from '../types';
|
|
7
5
|
export declare const resolveModulePath: (moduleName: string) => string;
|
|
8
6
|
export declare function resolveStubPath(stubName: string): string;
|
|
9
7
|
export declare const getDevToolConfig: ({ watchMode }: Pick<BundlerArgs, 'watchMode'>) => string;
|
|
@@ -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;
|
|
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;AAIjF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,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,mBA4G1D,CAAC"}
|
package/out/config/common.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommonWebpackConfig = exports.geti18nRule = exports.getDevToolConfig = exports.resolveStubPath = exports.resolveModulePath =
|
|
3
|
+
exports.getCommonWebpackConfig = exports.geti18nRule = exports.getDevToolConfig = exports.resolveStubPath = exports.resolveModulePath = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
7
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
8
|
const i18n_1 = require("@forge/i18n");
|
|
9
|
+
const common_1 = require("../common");
|
|
9
10
|
const text_1 = require("../text");
|
|
10
11
|
const tsconfig_interactor_1 = require("../tsconfig-interactor");
|
|
11
|
-
function getEntryPoints(handlers) {
|
|
12
|
-
const modules = new Set(handlers.map(({ module }) => module));
|
|
13
|
-
return Array.from(modules).map((module) => ({
|
|
14
|
-
name: module,
|
|
15
|
-
path: path_1.default.resolve('src', module)
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
exports.getEntryPoints = getEntryPoints;
|
|
19
12
|
const resolveModulePath = (moduleName) => {
|
|
20
13
|
return require.resolve(moduleName);
|
|
21
14
|
};
|
|
@@ -57,7 +50,7 @@ const getCommonWebpackConfig = (args) => {
|
|
|
57
50
|
for (const entrypoint of entryPoints) {
|
|
58
51
|
resolvedEntryPoints[entrypoint.name] = path_1.default.resolve(entrypoint.path);
|
|
59
52
|
}
|
|
60
|
-
const outputDir =
|
|
53
|
+
const outputDir = (0, common_1.getOutputDir)(args);
|
|
61
54
|
return {
|
|
62
55
|
entry: resolvedEntryPoints,
|
|
63
56
|
mode: 'production',
|
package/out/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
export { getOutputDir, getEntryPoints } from './common';
|
|
2
|
+
export { runLinter } from './lint';
|
|
1
3
|
export { NativeUIBundler, NativeUIBundleResult } from './nativeui';
|
|
2
|
-
export { SandboxBundler,
|
|
4
|
+
export { SandboxBundler, getNodeBundler } from './runtime';
|
|
3
5
|
export { Bundler, BundlerError, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
4
|
-
export { getCompiler, handleWebpackCompilationResult
|
|
5
|
-
export { getEntryPoints } from './config/common';
|
|
6
|
+
export { getCompiler, handleWebpackCompilationResult } from './webpack';
|
|
6
7
|
export { getNativeUiBuildConfig } from './config/nativeui';
|
|
7
8
|
export { getWrapperProvider, LocalWrapperProvider } from './wrapper-provider';
|
|
8
9
|
//# 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,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.
|
|
3
|
+
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.BundlerError = exports.getNodeBundler = exports.SandboxBundler = exports.NativeUIBundler = exports.runLinter = exports.getEntryPoints = exports.getOutputDir = void 0;
|
|
4
|
+
var common_1 = require("./common");
|
|
5
|
+
Object.defineProperty(exports, "getOutputDir", { enumerable: true, get: function () { return common_1.getOutputDir; } });
|
|
6
|
+
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
|
|
7
|
+
var lint_1 = require("./lint");
|
|
8
|
+
Object.defineProperty(exports, "runLinter", { enumerable: true, get: function () { return lint_1.runLinter; } });
|
|
4
9
|
var nativeui_1 = require("./nativeui");
|
|
5
10
|
Object.defineProperty(exports, "NativeUIBundler", { enumerable: true, get: function () { return nativeui_1.NativeUIBundler; } });
|
|
6
11
|
var runtime_1 = require("./runtime");
|
|
7
12
|
Object.defineProperty(exports, "SandboxBundler", { enumerable: true, get: function () { return runtime_1.SandboxBundler; } });
|
|
8
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "getNodeBundler", { enumerable: true, get: function () { return runtime_1.getNodeBundler; } });
|
|
9
14
|
var types_1 = require("./types");
|
|
10
15
|
Object.defineProperty(exports, "BundlerError", { enumerable: true, get: function () { return types_1.BundlerError; } });
|
|
11
16
|
var webpack_1 = require("./webpack");
|
|
12
17
|
Object.defineProperty(exports, "getCompiler", { enumerable: true, get: function () { return webpack_1.getCompiler; } });
|
|
13
18
|
Object.defineProperty(exports, "handleWebpackCompilationResult", { enumerable: true, get: function () { return webpack_1.handleWebpackCompilationResult; } });
|
|
14
|
-
Object.defineProperty(exports, "runLinter", { enumerable: true, get: function () { return webpack_1.runLinter; } });
|
|
15
|
-
var common_1 = require("./config/common");
|
|
16
|
-
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
|
|
17
19
|
var nativeui_2 = require("./config/nativeui");
|
|
18
20
|
Object.defineProperty(exports, "getNativeUiBuildConfig", { enumerable: true, get: function () { return nativeui_2.getNativeUiBuildConfig; } });
|
|
19
21
|
var wrapper_provider_1 = require("./wrapper-provider");
|
package/out/lint.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FileSystemReader, FileSystemWriter } from '@forge/cli-shared';
|
|
2
|
+
import { LintLogger } from '@forge/lint';
|
|
3
|
+
export declare function runLinter(logger?: LintLogger, fileSystemReader?: FileSystemReader, fileSystemWriter?: FileSystemWriter): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,gBAAgB,EAAwB,gBAAgB,EAAsB,MAAM,mBAAmB,CAAC;AACvH,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlE,wBAAsB,SAAS,CAE7B,MAAM,GAAE,UAAkC,EAC1C,gBAAgB,mBAAyB,EACzC,gBAAgB,mBAAyB,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf"}
|
package/out/lint.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runLinter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
|
+
const lint_1 = require("@forge/lint");
|
|
8
|
+
const common_1 = require("./common");
|
|
9
|
+
async function runLinter(logger = { info: console.log }, fileSystemReader = new cli_shared_1.FileSystemReader(), fileSystemWriter = new cli_shared_1.FileSystemWriter()) {
|
|
10
|
+
logger.info(`\n${cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.lint.running)}`);
|
|
11
|
+
const exclude = [...(await (0, cli_shared_1.listGitIgnoreFiles)(fileSystemReader)), '.git', common_1.NODE_MODULES_DIR];
|
|
12
|
+
const configFile = new cli_shared_1.ConfigFile(fileSystemReader, fileSystemWriter);
|
|
13
|
+
const manifest = await configFile.readConfig();
|
|
14
|
+
const csuikResources = await configFile.getResources(['nativeUI']);
|
|
15
|
+
const csuikDirectories = csuikResources.map((resource) => path_1.default.dirname(resource.path));
|
|
16
|
+
const [filesToLint, ...csuikFilesByDirectory] = await Promise.all([
|
|
17
|
+
fileSystemReader.recursiveReadDir('./src', exclude),
|
|
18
|
+
...csuikDirectories.map((directory) => fileSystemReader.recursiveReadDir(directory, exclude))
|
|
19
|
+
]);
|
|
20
|
+
const csuikFilesToLint = csuikFilesByDirectory.reduce((allFiles, directoryFiles) => allFiles.concat(directoryFiles), []);
|
|
21
|
+
try {
|
|
22
|
+
const lintResults = await (0, lint_1.lint)([...filesToLint, ...csuikFilesToLint], manifest, 'development', logger);
|
|
23
|
+
if (lintResults.some((result) => result.size())) {
|
|
24
|
+
logger.info('');
|
|
25
|
+
(0, lint_1.reportLintResults)(logger, lintResults);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
logger.info(cli_shared_1.LogColor.trace(cli_shared_1.Text.lint.noProblems) + '\n');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logger.info(cli_shared_1.Text.tunnel.lintFailed + '\n');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.runLinter = runLinter;
|
package/out/runtime.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigReader } from '@forge/cli-shared';
|
|
1
2
|
import { BundleLogger, BundlerArgs } from './types';
|
|
2
3
|
import { ConfigWithOutput, WebpackBundler } from './webpack';
|
|
3
4
|
import { WrapperProvider } from './wrapper-provider';
|
|
@@ -5,10 +6,11 @@ export declare class SandboxBundler extends WebpackBundler {
|
|
|
5
6
|
constructor(logger: BundleLogger);
|
|
6
7
|
getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
declare class NodeBundler extends WebpackBundler {
|
|
9
10
|
private readonly wrapperProvider;
|
|
10
11
|
constructor(logger: BundleLogger, wrapperProvider: WrapperProvider);
|
|
11
12
|
getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
12
|
-
private insertWrapperBundle;
|
|
13
13
|
}
|
|
14
|
+
export declare function getNodeBundler(logger: BundleLogger, wrapperProvider: WrapperProvider, configReader: ConfigReader): NodeBundler;
|
|
15
|
+
export {};
|
|
14
16
|
//# sourceMappingURL=runtime.d.ts.map
|
package/out/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAChE,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;AAoCD,cAAM,WAAY,SAAQ,cAAc;IAGpC,OAAO,CAAC,QAAQ,CAAC,eAAe;gBADhC,MAAM,EAAE,YAAY,EACH,eAAe,EAAE,eAAe;IAKnD,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB;CA8C/C;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,WAAW,CAKb"}
|
package/out/runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getNodeBundler = exports.SandboxBundler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
6
6
|
var RawSource = webpack_1.default.sources.RawSource;
|
|
@@ -18,6 +18,22 @@ class SandboxBundler extends webpack_2.WebpackBundler {
|
|
|
18
18
|
exports.SandboxBundler = SandboxBundler;
|
|
19
19
|
const NODE_RUNTIME_VERSION_FILE = 'runtime.json';
|
|
20
20
|
const NODE_WEBPACK_USER_CODE_DIR = 'bundled';
|
|
21
|
+
async function emitWrapperFiles(provider, entrypoints, emit) {
|
|
22
|
+
const wrapper = await provider.getNodeRuntimeWrapper();
|
|
23
|
+
const loader = await provider.getNodeRuntimeLoader();
|
|
24
|
+
if (loader) {
|
|
25
|
+
for (const entrypoint of entrypoints) {
|
|
26
|
+
await emit(`${entrypoint.name}.cjs`, loader.script);
|
|
27
|
+
}
|
|
28
|
+
await emit('__forge_wrapper__.cjs', wrapper.script);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
for (const entrypoint of entrypoints) {
|
|
32
|
+
await emit(`${entrypoint.name}.cjs`, wrapper.script);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
await emit(NODE_RUNTIME_VERSION_FILE, JSON.stringify({ version: loader ? loader.version : wrapper.version }, null, 2));
|
|
36
|
+
}
|
|
21
37
|
class NodeBundler extends webpack_2.WebpackBundler {
|
|
22
38
|
wrapperProvider;
|
|
23
39
|
constructor(logger, wrapperProvider) {
|
|
@@ -42,33 +58,13 @@ class NodeBundler extends webpack_2.WebpackBundler {
|
|
|
42
58
|
});
|
|
43
59
|
webpackConfig.plugins.push({
|
|
44
60
|
apply: (compiler) => {
|
|
45
|
-
compiler.hooks.make.tapPromise('AfterEmitPlugin', this.
|
|
61
|
+
compiler.hooks.make.tapPromise('AfterEmitPlugin', async (compilation) => await emitWrapperFiles(this.wrapperProvider, args.entryPoints, async (name, contents) => compilation.emitAsset(name, new RawSource(contents))));
|
|
46
62
|
}
|
|
47
63
|
});
|
|
48
64
|
return webpackConfig;
|
|
49
65
|
}
|
|
50
|
-
insertWrapperBundle(entrypoints) {
|
|
51
|
-
return async (compilation) => {
|
|
52
|
-
const wrapper = await this.wrapperProvider.getNodeRuntimeWrapper();
|
|
53
|
-
const loader = await this.wrapperProvider.getNodeRuntimeLoader();
|
|
54
|
-
if (loader) {
|
|
55
|
-
const loaderSource = new RawSource(loader.script);
|
|
56
|
-
for (const entrypoint of entrypoints) {
|
|
57
|
-
compilation.emitAsset(`${entrypoint.name}.cjs`, loaderSource);
|
|
58
|
-
}
|
|
59
|
-
const wrapperSource = new RawSource(wrapper.script);
|
|
60
|
-
compilation.emitAsset('__forge_wrapper__.cjs', wrapperSource);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const source = new RawSource(wrapper.script);
|
|
64
|
-
for (const entrypoint of entrypoints) {
|
|
65
|
-
compilation.emitAsset(`${entrypoint.name}.cjs`, source);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
compilation.emitAsset(NODE_RUNTIME_VERSION_FILE, new RawSource(JSON.stringify({
|
|
69
|
-
version: loader ? loader.version : wrapper.version
|
|
70
|
-
}, null, 2)));
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
66
|
}
|
|
74
|
-
|
|
67
|
+
function getNodeBundler(logger, wrapperProvider, configReader) {
|
|
68
|
+
return new NodeBundler(logger, wrapperProvider);
|
|
69
|
+
}
|
|
70
|
+
exports.getNodeBundler = getNodeBundler;
|
package/out/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface BundlerOutput {
|
|
|
7
7
|
outputDir: string;
|
|
8
8
|
metadata?: BundlerMetadata;
|
|
9
9
|
}
|
|
10
|
-
export declare type BundleLogger = Pick<Logger, 'trace' | 'debug' | 'info' | 'warn'>;
|
|
10
|
+
export declare type BundleLogger = Pick<Logger, 'trace' | 'debug' | 'info' | 'warn' | 'error'>;
|
|
11
11
|
export declare type BundlerWatchMode = 'watch' | 'debug';
|
|
12
12
|
export declare type EntryPoint = {
|
|
13
13
|
name: string;
|
|
@@ -19,7 +19,7 @@ export declare type BundlerArgs = {
|
|
|
19
19
|
i18nConfig?: Translations;
|
|
20
20
|
watchMode?: BundlerWatchMode;
|
|
21
21
|
};
|
|
22
|
-
export declare type BundlerWatchArgs = BundlerArgs & {
|
|
22
|
+
export declare type BundlerWatchArgs = BundlerArgs & Required<Pick<BundlerArgs, 'watchMode'>> & {
|
|
23
23
|
successMessage: string;
|
|
24
24
|
};
|
|
25
25
|
export declare type BundlerWatch = {
|
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,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;CACpB,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;
|
|
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;CACpB,CAAC;AAEF,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,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjF,CAAC;AAEF,qBAAa,YAAa,SAAQ,SAAS;CAAG"}
|
package/out/webpack.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
|
-
import { FileSystemReader, FileSystemWriter } from '@forge/cli-shared';
|
|
3
|
-
import { LintLogger } from '@forge/lint';
|
|
4
2
|
import { CommonOutputOptions } from './config/common';
|
|
5
3
|
import { Bundler, BundleLogger, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
6
4
|
export declare function handleWebpackCompilationResult(logger: BundleLogger, err: Error | null | undefined, stats: Pick<webpack.Stats, 'hasErrors' | 'hasWarnings' | 'toJson'> | undefined): asserts stats is webpack.Stats;
|
|
7
5
|
export declare function getCompiler(config: webpack.Configuration): webpack.Compiler;
|
|
8
|
-
export declare const runLinter: (logger?: LintLogger, fileSystemReader?: FileSystemReader, fileSystemWriter?: FileSystemWriter) => Promise<void>;
|
|
9
6
|
export declare type ConfigWithOutput = webpack.Configuration & {
|
|
10
7
|
output: CommonOutputOptions;
|
|
11
8
|
};
|
|
12
9
|
export declare abstract class WebpackBundler implements Bundler {
|
|
13
10
|
protected readonly logger: BundleLogger;
|
|
14
11
|
constructor(logger: BundleLogger);
|
|
15
|
-
protected getOutput(config: ConfigWithOutput, stats: webpack.Stats): BundlerOutput
|
|
12
|
+
protected getOutput(config: ConfigWithOutput, stats: webpack.Stats): Promise<BundlerOutput>;
|
|
16
13
|
protected runCompiler(config: ConfigWithOutput): Promise<BundlerOutput>;
|
|
17
14
|
abstract getConfig(args: BundlerArgs): ConfigWithOutput;
|
|
18
15
|
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
package/out/webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../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AE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsCtF"}
|
package/out/webpack.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebpackBundler = exports.
|
|
3
|
+
exports.WebpackBundler = exports.getCompiler = exports.handleWebpackCompilationResult = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
5
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
7
6
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
|
-
const lint_1 = require("@forge/lint");
|
|
9
7
|
const text_1 = require("./text");
|
|
10
8
|
function handleWebpackCompilationResult(logger, err, stats) {
|
|
11
9
|
if (err) {
|
|
@@ -57,39 +55,12 @@ function getNodeModuleNames(stats) {
|
|
|
57
55
|
return Array.from(filteredModuleNames);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
const runLinter = async (logger = { info: console.log }, fileSystemReader = new cli_shared_1.FileSystemReader(), fileSystemWriter = new cli_shared_1.FileSystemWriter()) => {
|
|
61
|
-
logger.info(`\n${cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.lint.running)}`);
|
|
62
|
-
const exclude = [...(await (0, cli_shared_1.listGitIgnoreFiles)(fileSystemReader)), '.git', 'node_modules'];
|
|
63
|
-
const configFile = new cli_shared_1.ConfigFile(fileSystemReader, fileSystemWriter);
|
|
64
|
-
const manifest = await configFile.readConfig();
|
|
65
|
-
const csuikResources = await configFile.getResources(['nativeUI']);
|
|
66
|
-
const csuikDirectories = csuikResources.map((resource) => path_1.default.dirname(resource.path));
|
|
67
|
-
const [filesToLint, ...csuikFilesByDirectory] = await Promise.all([
|
|
68
|
-
fileSystemReader.recursiveReadDir('./src', exclude),
|
|
69
|
-
...csuikDirectories.map((directory) => fileSystemReader.recursiveReadDir(directory, exclude))
|
|
70
|
-
]);
|
|
71
|
-
const csuikFilesToLint = csuikFilesByDirectory.reduce((allFiles, directoryFiles) => allFiles.concat(directoryFiles), []);
|
|
72
|
-
try {
|
|
73
|
-
const lintResults = await (0, lint_1.lint)([...filesToLint, ...csuikFilesToLint], manifest, 'development', logger);
|
|
74
|
-
if (lintResults.some((result) => result.size())) {
|
|
75
|
-
logger.info('');
|
|
76
|
-
(0, lint_1.reportLintResults)(logger, lintResults);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
logger.info(cli_shared_1.LogColor.trace(cli_shared_1.Text.lint.noProblems) + '\n');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
logger.info(cli_shared_1.Text.tunnel.lintFailed + '\n');
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
exports.runLinter = runLinter;
|
|
87
58
|
class WebpackBundler {
|
|
88
59
|
logger;
|
|
89
60
|
constructor(logger) {
|
|
90
61
|
this.logger = logger;
|
|
91
62
|
}
|
|
92
|
-
getOutput(config, stats) {
|
|
63
|
+
async getOutput(config, stats) {
|
|
93
64
|
const outputDir = config.output.path;
|
|
94
65
|
const metadata = {};
|
|
95
66
|
if (stats) {
|
|
@@ -100,7 +71,7 @@ class WebpackBundler {
|
|
|
100
71
|
async runCompiler(config) {
|
|
101
72
|
const compiler = getCompiler(config);
|
|
102
73
|
return new Promise((resolve, reject) => {
|
|
103
|
-
compiler.run((compilerError, stats) => {
|
|
74
|
+
compiler.run(async (compilerError, stats) => {
|
|
104
75
|
try {
|
|
105
76
|
handleWebpackCompilationResult(this.logger, compilerError, stats);
|
|
106
77
|
compiler.close((closeError) => {
|
|
@@ -108,7 +79,7 @@ class WebpackBundler {
|
|
|
108
79
|
reject(closeError);
|
|
109
80
|
}
|
|
110
81
|
});
|
|
111
|
-
resolve(this.getOutput(config, stats));
|
|
82
|
+
resolve(await this.getOutput(config, stats));
|
|
112
83
|
}
|
|
113
84
|
catch (err) {
|
|
114
85
|
reject(err);
|
|
@@ -135,7 +106,7 @@ class WebpackBundler {
|
|
|
135
106
|
try {
|
|
136
107
|
handleWebpackCompilationResult(this.logger, compilerError, stats);
|
|
137
108
|
this.logger.info(cli_shared_1.LogColor.trace(args.successMessage));
|
|
138
|
-
const result = this.getOutput(config, stats);
|
|
109
|
+
const result = await this.getOutput(config, stats);
|
|
139
110
|
if (isFirstRun) {
|
|
140
111
|
isFirstRun = false;
|
|
141
112
|
resolve({ result, stop: () => watching.close(() => void 0) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.21.0-next.3",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"@babel/plugin-transform-optional-chaining": "^7.23.4",
|
|
20
20
|
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
21
21
|
"@babel/preset-typescript": "^7.23.3",
|
|
22
|
-
"@forge/api": "5.1.1-next.
|
|
22
|
+
"@forge/api": "5.1.1-next.1",
|
|
23
23
|
"@forge/babel-plugin-transform-ui": "1.1.21",
|
|
24
|
-
"@forge/cli-shared": "6.6.2-next.
|
|
24
|
+
"@forge/cli-shared": "6.6.2-next.1",
|
|
25
25
|
"@forge/i18n": "0.0.4",
|
|
26
|
-
"@forge/lint": "5.7.2-next.
|
|
26
|
+
"@forge/lint": "5.7.2-next.1",
|
|
27
27
|
"@forge/manifest": "8.7.1-next.0",
|
|
28
28
|
"@forge/util": "1.4.8",
|
|
29
29
|
"assert": "^2.1.0",
|