@forge/bundler 7.1.0-next.7 → 7.1.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/runtime.d.ts +2 -0
- package/out/runtime.d.ts.map +1 -1
- package/out/runtime.js +78 -38
- package/out/text.d.ts +1 -1
- package/out/text.js +1 -1
- package/out/types.d.ts +4 -2
- package/out/types.d.ts.map +1 -1
- package/out/types.js +4 -0
- package/out/typescript.d.ts +2 -2
- package/out/typescript.d.ts.map +1 -1
- package/out/typescript.js +4 -1
- package/out/webpack.d.ts +4 -3
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +3 -2
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 7.1.0-next.9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a36d70b: Implement manual bundler
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [a36d70b]
|
|
12
|
+
- @forge/cli-shared@9.3.0-next.9
|
|
13
|
+
- @forge/lint@6.0.3-next.9
|
|
14
|
+
|
|
15
|
+
## 7.1.0-next.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [89ccb1e]
|
|
20
|
+
- @forge/manifest@13.3.0-next.7
|
|
21
|
+
- @forge/cli-shared@9.3.0-next.8
|
|
22
|
+
- @forge/lint@6.0.3-next.8
|
|
23
|
+
|
|
3
24
|
## 7.1.0-next.7
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/out/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { getOutputDir, getEntryPoints, createEntryPointsForResource } from './co
|
|
|
2
2
|
export { runLinter } from './lint';
|
|
3
3
|
export { NativeUIBundler, NativeUIBundleResult } from './nativeui';
|
|
4
4
|
export { getNodeBundler, NODE_RUNTIME_CODE_FILE } from './runtime';
|
|
5
|
-
export { Bundler, BundlerError, BundlerMetadata, emptyMetadata, mergeMetadata, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
5
|
+
export { AdditionalOutputs, Bundler, BundlerError, BundlerMetadata, emptyMetadata, mergeMetadata, mergeOutputs, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
6
6
|
export { getCompiler, handleWebpackCompilationResult } from './webpack';
|
|
7
7
|
export { getNativeUiBuildConfig, getNativeUiWorkerBuildConfig } from './config/nativeui';
|
|
8
8
|
export { getWrapperProvider, LocalWrapperProvider } from './wrapper-provider';
|
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,YAAY,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiWorkerBuildConfig = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.mergeMetadata = exports.emptyMetadata = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.NativeUIBundler = exports.runLinter = exports.createEntryPointsForResource = exports.getEntryPoints = exports.getOutputDir = void 0;
|
|
3
|
+
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiWorkerBuildConfig = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.mergeOutputs = exports.mergeMetadata = exports.emptyMetadata = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.NativeUIBundler = exports.runLinter = exports.createEntryPointsForResource = exports.getEntryPoints = exports.getOutputDir = void 0;
|
|
4
4
|
var common_1 = require("./common");
|
|
5
5
|
Object.defineProperty(exports, "getOutputDir", { enumerable: true, get: function () { return common_1.getOutputDir; } });
|
|
6
6
|
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return common_1.getEntryPoints; } });
|
|
@@ -16,6 +16,7 @@ var types_1 = require("./types");
|
|
|
16
16
|
Object.defineProperty(exports, "BundlerError", { enumerable: true, get: function () { return types_1.BundlerError; } });
|
|
17
17
|
Object.defineProperty(exports, "emptyMetadata", { enumerable: true, get: function () { return types_1.emptyMetadata; } });
|
|
18
18
|
Object.defineProperty(exports, "mergeMetadata", { enumerable: true, get: function () { return types_1.mergeMetadata; } });
|
|
19
|
+
Object.defineProperty(exports, "mergeOutputs", { enumerable: true, get: function () { return types_1.mergeOutputs; } });
|
|
19
20
|
var webpack_1 = require("./webpack");
|
|
20
21
|
Object.defineProperty(exports, "getCompiler", { enumerable: true, get: function () { return webpack_1.getCompiler; } });
|
|
21
22
|
Object.defineProperty(exports, "handleWebpackCompilationResult", { enumerable: true, get: function () { return webpack_1.handleWebpackCompilationResult; } });
|
package/out/runtime.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ConfigReader, Logger, StatsigService } from '@forge/cli-shared';
|
|
2
|
+
import { ManifestSchema } from '@forge/manifest';
|
|
2
3
|
import { Bundler } from './types';
|
|
3
4
|
import { WrapperProvider } from './wrapper-provider';
|
|
5
|
+
export type PackageOptions = NonNullable<ManifestSchema['app']['package']>;
|
|
4
6
|
export declare const NODE_RUNTIME_CODE_FILE = "__forge__.cjs";
|
|
5
7
|
export declare function getNodeBundler(logger: Logger, wrapperProvider: WrapperProvider, configReader: ConfigReader, statsigService: StatsigService): Bundler;
|
|
6
8
|
//# 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":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAiC,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAEnH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD,OAAO,EAEL,OAAO,EAOR,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAK3E,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AA8NtD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,GAC7B,OAAO,CAET"}
|
package/out/runtime.js
CHANGED
|
@@ -4,43 +4,45 @@ exports.NODE_RUNTIME_CODE_FILE = void 0;
|
|
|
4
4
|
exports.getNodeBundler = getNodeBundler;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
var RawSource = webpack_1.default.sources.RawSource;
|
|
7
|
+
const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
|
|
8
|
+
const debounce_1 = tslib_1.__importDefault(require("debounce"));
|
|
10
9
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
11
10
|
const i18n_1 = require("@forge/i18n");
|
|
12
11
|
const common_1 = require("./config/common");
|
|
13
|
-
const
|
|
14
|
-
const webpack_2 = require("./webpack");
|
|
12
|
+
const metadata_1 = require("./metadata");
|
|
15
13
|
const text_1 = require("./text");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
const typescript_1 = require("./typescript");
|
|
16
|
+
const webpack_1 = require("./webpack");
|
|
16
17
|
exports.NODE_RUNTIME_CODE_FILE = '__forge__.cjs';
|
|
17
18
|
const NODE_RUNTIME_BACKUP_WRAPPER_FILE = '__forge_wrapper__.cjs';
|
|
18
19
|
const NODE_RUNTIME_USE_LOCAL_WRAPPER_FILE = '__forge_use_local_wrapper.txt';
|
|
19
20
|
const NODE_RUNTIME_VERSION_FILE = 'runtime.json';
|
|
20
|
-
async function
|
|
21
|
+
async function getRuntimeArtifacts(provider, args) {
|
|
22
|
+
const result = new Map();
|
|
21
23
|
const wrapper = await provider.getNodeRuntimeWrapper();
|
|
22
24
|
const loader = await provider.getNodeRuntimeLoader();
|
|
23
25
|
let entrypointScript;
|
|
24
26
|
if (loader) {
|
|
25
27
|
entrypointScript = loader;
|
|
26
|
-
|
|
28
|
+
result.set(NODE_RUNTIME_BACKUP_WRAPPER_FILE, Buffer.from(wrapper.script));
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
31
|
entrypointScript = wrapper;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
result.set(exports.NODE_RUNTIME_CODE_FILE, Buffer.from(entrypointScript.script));
|
|
32
34
|
if (process.env.FORGE_RUNTIME_PATH) {
|
|
33
|
-
|
|
35
|
+
result.set(NODE_RUNTIME_USE_LOCAL_WRAPPER_FILE, Buffer.from('Local wrapper used'));
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
result.set(NODE_RUNTIME_VERSION_FILE, Buffer.from(JSON.stringify({ version: entrypointScript.version }, null, 2)));
|
|
38
|
+
if (args.i18nResourceBundle) {
|
|
39
|
+
for (const [fileName, filePath] of (0, cli_shared_1.listFilesInI18nResourceBundle)(args.i18nResourceBundle)) {
|
|
40
|
+
result.set(path_1.default.join(i18n_1.I18N_BUNDLE_FOLDER_NAME, fileName), filePath);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
42
44
|
}
|
|
43
|
-
class NodeBundler extends
|
|
45
|
+
class NodeBundler extends webpack_1.WebpackBundler {
|
|
44
46
|
wrapperProvider;
|
|
45
47
|
constructor(logger, wrapperProvider) {
|
|
46
48
|
super(logger);
|
|
@@ -57,19 +59,13 @@ class NodeBundler extends webpack_2.WebpackBundler {
|
|
|
57
59
|
fullySpecified: false
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
|
-
webpackConfig.plugins.push({
|
|
61
|
-
apply: (compiler) => {
|
|
62
|
-
compiler.hooks.make.tapPromise('AfterEmitPlugin', async (compilation) => {
|
|
63
|
-
const emit = async (name, contents) => compilation.emitAsset(name, new RawSource(contents));
|
|
64
|
-
await emitWrapperFiles(this.wrapperProvider, emit);
|
|
65
|
-
if (args.i18nResourceBundle) {
|
|
66
|
-
await emitI18nFiles(args.i18nResourceBundle, emit);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
62
|
return [webpackConfig];
|
|
72
63
|
}
|
|
64
|
+
async getOutput(args, config, stats) {
|
|
65
|
+
const result = await super.getOutput(args, config, stats);
|
|
66
|
+
result.additionalOutputs = (0, types_1.mergeOutputs)(result.additionalOutputs, await getRuntimeArtifacts(this.wrapperProvider, args));
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
73
69
|
}
|
|
74
70
|
class TypeScriptNodeBundler extends typescript_1.TypeScriptBundler {
|
|
75
71
|
wrapperProvider;
|
|
@@ -79,18 +75,62 @@ class TypeScriptNodeBundler extends typescript_1.TypeScriptBundler {
|
|
|
79
75
|
}
|
|
80
76
|
async getResult(args, outputDir, output, additionalOutputs) {
|
|
81
77
|
const result = await super.getResult(args, outputDir, output, additionalOutputs);
|
|
82
|
-
|
|
83
|
-
const outputPath = path_1.default.join(outputDir, name);
|
|
84
|
-
await promises_1.default.mkdir(path_1.default.dirname(outputPath), { recursive: true });
|
|
85
|
-
await promises_1.default.writeFile(outputPath, contents);
|
|
86
|
-
};
|
|
87
|
-
await emitWrapperFiles(this.wrapperProvider, emit);
|
|
88
|
-
if (args.i18nResourceBundle) {
|
|
89
|
-
await emitI18nFiles(args.i18nResourceBundle, emit);
|
|
90
|
-
}
|
|
78
|
+
result.additionalOutputs = (0, types_1.mergeOutputs)(result.additionalOutputs, await getRuntimeArtifacts(this.wrapperProvider, args));
|
|
91
79
|
return result;
|
|
92
80
|
}
|
|
93
81
|
}
|
|
82
|
+
class ManualBundler {
|
|
83
|
+
logger;
|
|
84
|
+
wrapperProvider;
|
|
85
|
+
static WATCH_DEBOUNCE_MS = 200;
|
|
86
|
+
path;
|
|
87
|
+
constructor(config, logger, wrapperProvider) {
|
|
88
|
+
this.logger = logger;
|
|
89
|
+
this.wrapperProvider = wrapperProvider;
|
|
90
|
+
if (!config?.path) {
|
|
91
|
+
throw new cli_shared_1.UserError(text_1.Text.manualBundlerPathRequired);
|
|
92
|
+
}
|
|
93
|
+
this.path = config.path;
|
|
94
|
+
}
|
|
95
|
+
async bundle(args) {
|
|
96
|
+
const outputDir = path_1.default.join(args.appDirectory, this.path);
|
|
97
|
+
const additionalOutputs = await getRuntimeArtifacts(this.wrapperProvider, args);
|
|
98
|
+
const metadata = await (0, metadata_1.getMetadata)(this.logger, args.appDirectory, new Set());
|
|
99
|
+
metadata.bundler = 'manual@2026';
|
|
100
|
+
return { outputDir, additionalOutputs, metadata };
|
|
101
|
+
}
|
|
102
|
+
async watch(args, watch) {
|
|
103
|
+
const result = await this.bundle(args);
|
|
104
|
+
const watcher = chokidar_1.default.watch(result.outputDir, {
|
|
105
|
+
persistent: false,
|
|
106
|
+
ignoreInitial: true,
|
|
107
|
+
ignored: (path) => path.includes('node_modules')
|
|
108
|
+
});
|
|
109
|
+
const onChange = (0, debounce_1.default)(async () => {
|
|
110
|
+
await watch.onBuildWillStart();
|
|
111
|
+
try {
|
|
112
|
+
const nextResult = await this.bundle(args);
|
|
113
|
+
await watch.onBuildFinished(null, nextResult);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
await watch.onBuildFinished(error);
|
|
117
|
+
}
|
|
118
|
+
}, ManualBundler.WATCH_DEBOUNCE_MS);
|
|
119
|
+
watcher.on('all', () => void onChange());
|
|
120
|
+
watcher.on('error', (error) => void watch.onBuildFinished(error));
|
|
121
|
+
await new Promise((resolve, reject) => {
|
|
122
|
+
watcher.once('ready', resolve);
|
|
123
|
+
watcher.once('error', reject);
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
result,
|
|
127
|
+
stop: async () => {
|
|
128
|
+
onChange.clear();
|
|
129
|
+
await watcher.close();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
94
134
|
class ConfigBundler {
|
|
95
135
|
logger;
|
|
96
136
|
wrapperProvider;
|
|
@@ -111,7 +151,7 @@ class ConfigBundler {
|
|
|
111
151
|
return new TypeScriptNodeBundler(this.logger, this.wrapperProvider);
|
|
112
152
|
}
|
|
113
153
|
if (config?.bundler === 'manual@2026') {
|
|
114
|
-
|
|
154
|
+
return new ManualBundler(config, this.logger, this.wrapperProvider);
|
|
115
155
|
}
|
|
116
156
|
return new NodeBundler(this.logger, this.wrapperProvider);
|
|
117
157
|
}
|
package/out/text.d.ts
CHANGED
package/out/text.js
CHANGED
|
@@ -8,5 +8,5 @@ exports.Text = {
|
|
|
8
8
|
noExecutableFile: 'Could not find the main executable file',
|
|
9
9
|
metadataFailed: (error) => `Application code metadata processing failed: ${error.message}`,
|
|
10
10
|
typescriptBundlerEAP: `TypeScript bundler is a Forge EAP feature. Please see ${cli_shared_1.Text.go('dac/platform/forge/manifest-reference/#package')} for more details.`,
|
|
11
|
-
|
|
11
|
+
manualBundlerPathRequired: 'For manual packaging, the path to the packaged runtime code is required.'
|
|
12
12
|
};
|
package/out/types.d.ts
CHANGED
|
@@ -12,11 +12,13 @@ export type BundlerMetadata = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare function emptyMetadata(): BundlerMetadata;
|
|
14
14
|
export declare function mergeMetadata(metadata1: BundlerMetadata, metadata2: BundlerMetadata): BundlerMetadata;
|
|
15
|
+
export type AdditionalOutputs = Map<string, string | Buffer>;
|
|
15
16
|
export interface BundlerOutput {
|
|
16
17
|
outputDir: string;
|
|
17
|
-
additionalOutputs?:
|
|
18
|
+
additionalOutputs?: AdditionalOutputs;
|
|
18
19
|
metadata?: BundlerMetadata;
|
|
19
20
|
}
|
|
21
|
+
export declare function mergeOutputs(outputs1: AdditionalOutputs | undefined, outputs2: AdditionalOutputs | undefined): AdditionalOutputs;
|
|
20
22
|
export type BundlerWatchMode = 'watch' | 'debug';
|
|
21
23
|
export type EntryPoint = {
|
|
22
24
|
name: string;
|
|
@@ -38,7 +40,7 @@ export type BundlerWatch = {
|
|
|
38
40
|
onBuildFinished: ((err: null, result: BundlerOutput) => Promise<void>) & ((err: Error) => Promise<void>);
|
|
39
41
|
};
|
|
40
42
|
export interface WatcherMonitor {
|
|
41
|
-
stop(): void
|
|
43
|
+
stop(): Promise<void>;
|
|
42
44
|
}
|
|
43
45
|
export type BundlerWatchOutput = WatcherMonitor & {
|
|
44
46
|
result: BundlerOutput;
|
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,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;I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gB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjF,CAAC;AAEF,qBAAa,YAAa,SAAQ,SAAS;CAAG"}
|
package/out/types.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BundlerError = void 0;
|
|
4
4
|
exports.emptyMetadata = emptyMetadata;
|
|
5
5
|
exports.mergeMetadata = mergeMetadata;
|
|
6
|
+
exports.mergeOutputs = mergeOutputs;
|
|
6
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
8
|
function emptyMetadata() {
|
|
8
9
|
return {
|
|
@@ -28,6 +29,9 @@ function mergeMetadata(metadata1, metadata2) {
|
|
|
28
29
|
bundler: metadata1.bundler || metadata2.bundler
|
|
29
30
|
};
|
|
30
31
|
}
|
|
32
|
+
function mergeOutputs(outputs1, outputs2) {
|
|
33
|
+
return new Map([...(outputs1 ?? []), ...(outputs2 ?? [])]);
|
|
34
|
+
}
|
|
31
35
|
class BundlerError extends cli_shared_1.UserError {
|
|
32
36
|
}
|
|
33
37
|
exports.BundlerError = BundlerError;
|
package/out/typescript.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ChildProcessByStdio } from 'child_process';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { Logger } from '@forge/cli-shared';
|
|
4
|
-
import { Bundler, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
4
|
+
import { AdditionalOutputs, Bundler, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
5
5
|
type OutputProcess = ChildProcessByStdio<null, Readable, null>;
|
|
6
6
|
export declare abstract class TypeScriptBundler implements Bundler {
|
|
7
7
|
protected readonly logger: Logger;
|
|
8
8
|
constructor(logger: Logger);
|
|
9
9
|
protected runTypeScript(args: BundlerArgs, outputDir: string): OutputProcess;
|
|
10
10
|
protected isListedFile(line: string): string | null;
|
|
11
|
-
protected getResult(args: BundlerArgs, outputDir: string, output?: string, additionalOutputs?:
|
|
11
|
+
protected getResult(args: BundlerArgs, outputDir: string, output?: string, additionalOutputs?: AdditionalOutputs): Promise<BundlerOutput>;
|
|
12
12
|
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
|
13
13
|
watch(args: BundlerWatchArgs, watch: BundlerWatch): Promise<BundlerWatchOutput>;
|
|
14
14
|
}
|
package/out/typescript.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../src/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,OAAO,EAA4B,MAAM,EAAE,MAAM,mBAAmB,CAAC;AASrE,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAGjB,KAAK,aAAa,GAAG,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE/D,8BAAsB,iBAAkB,YAAW,OAAO;IAC5C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;IAE7C,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa;IAwB5E,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;cAWnC,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../src/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,OAAO,EAA4B,MAAM,EAAE,MAAM,mBAAmB,CAAC;AASrE,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAGjB,KAAK,aAAa,GAAG,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE/D,8BAAsB,iBAAkB,YAAW,OAAO;IAC5C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;IAE7C,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa;IAwB5E,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;cAWnC,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,aAAa,CAAC;IAkBnB,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IA4BjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA8DtF"}
|
package/out/typescript.js
CHANGED
|
@@ -118,7 +118,10 @@ class TypeScriptBundler {
|
|
|
118
118
|
if (isFirstRun) {
|
|
119
119
|
isFirstRun = false;
|
|
120
120
|
this.logger.info(cli_shared_1.LogColor.trace(args.successMessage));
|
|
121
|
-
resolve({
|
|
121
|
+
resolve({
|
|
122
|
+
result,
|
|
123
|
+
stop: async () => void compiler.kill()
|
|
124
|
+
});
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
127
|
await watch.onBuildFinished(null, result);
|
package/out/webpack.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import webpack from 'webpack';
|
|
|
2
2
|
import { Logger } from '@forge/cli-shared';
|
|
3
3
|
import { CommonOutputOptions } from './config/common';
|
|
4
4
|
import { Bundler, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
5
|
-
export
|
|
5
|
+
export type Stats = webpack.Stats;
|
|
6
|
+
export declare function handleWebpackCompilationResult(logger: Logger, err: Error | null | undefined, stats: Pick<Stats, 'hasErrors' | 'hasWarnings' | 'toJson'> | undefined): asserts stats is Stats;
|
|
6
7
|
export declare function getCompiler(config: webpack.Configuration): webpack.Compiler;
|
|
7
8
|
export type ConfigWithOutput = webpack.Configuration & {
|
|
8
9
|
output: CommonOutputOptions;
|
|
@@ -11,9 +12,9 @@ export type Configs = [ConfigWithOutput, ...ConfigWithOutput[]];
|
|
|
11
12
|
export declare abstract class WebpackBundler implements Bundler {
|
|
12
13
|
protected readonly logger: Logger;
|
|
13
14
|
constructor(logger: Logger);
|
|
14
|
-
protected getOutput(args: BundlerArgs, config: ConfigWithOutput, stats:
|
|
15
|
+
protected getOutput(args: BundlerArgs, config: ConfigWithOutput, stats: Stats): Promise<BundlerOutput>;
|
|
15
16
|
protected isRegularModule(name: string): boolean;
|
|
16
|
-
protected localModules(stats:
|
|
17
|
+
protected localModules(stats: Stats): Set<string>;
|
|
17
18
|
protected runCompiler(args: BundlerArgs, config: ConfigWithOutput): Promise<BundlerOutput>;
|
|
18
19
|
abstract getConfigs(args: BundlerArgs): Promise<Configs>;
|
|
19
20
|
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
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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MAAM,CAAC;cAwBjC,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAsBhG,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAElD,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAWjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2CtF"}
|
package/out/webpack.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.handleWebpackCompilationResult = handleWebpackCompilationResult;
|
|
|
5
5
|
exports.getCompiler = getCompiler;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const util_1 = require("util");
|
|
8
9
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
9
10
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
10
11
|
const metadata_1 = require("./metadata");
|
|
@@ -125,7 +126,7 @@ class WebpackBundler {
|
|
|
125
126
|
const outputs = await Promise.all(configs.map((cfg) => this.runCompiler(args, cfg)));
|
|
126
127
|
const [primary, ...rest] = outputs;
|
|
127
128
|
const metadata = rest.reduce((acc, output) => (output.metadata ? (0, types_1.mergeMetadata)(acc, output.metadata) : acc), primary.metadata ?? (0, types_1.emptyMetadata)());
|
|
128
|
-
return {
|
|
129
|
+
return { ...primary, metadata };
|
|
129
130
|
}
|
|
130
131
|
async watch(args, watch) {
|
|
131
132
|
const configs = await this.getConfigs(args);
|
|
@@ -146,7 +147,7 @@ class WebpackBundler {
|
|
|
146
147
|
const result = await this.getOutput(args, targetConfig, stats);
|
|
147
148
|
if (isFirstRun) {
|
|
148
149
|
isFirstRun = false;
|
|
149
|
-
resolve({ result, stop: ()
|
|
150
|
+
resolve({ result, stop: (0, util_1.promisify)(watching.close.bind(watching)) });
|
|
150
151
|
}
|
|
151
152
|
else {
|
|
152
153
|
await watch.onBuildFinished(null, result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "7.1.0-next.
|
|
3
|
+
"version": "7.1.0-next.9",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
22
22
|
"@babel/traverse": "^7.24.0",
|
|
23
23
|
"@babel/types": "^7.24.0",
|
|
24
|
-
"@forge/cli-shared": "9.3.0-next.
|
|
24
|
+
"@forge/cli-shared": "9.3.0-next.9",
|
|
25
25
|
"@forge/i18n": "1.0.0",
|
|
26
|
-
"@forge/lint": "6.0.3-next.
|
|
27
|
-
"@forge/manifest": "13.3.0-next.
|
|
26
|
+
"@forge/lint": "6.0.3-next.9",
|
|
27
|
+
"@forge/manifest": "13.3.0-next.7",
|
|
28
28
|
"babel-loader": "^8.3.0",
|
|
29
29
|
"cheerio": "^1.2.0",
|
|
30
|
+
"chokidar": "^4.0.3",
|
|
30
31
|
"cross-spawn": "^7.0.6",
|
|
32
|
+
"debounce": "^2.2.0",
|
|
31
33
|
"fs-extra": "^11.2.0",
|
|
32
34
|
"html-webpack-plugin": "^5.6.3",
|
|
33
35
|
"nock": "13.5.6",
|