@forge/bundler 6.1.2-next.0-experimental-47556b0 → 6.1.2-next.0-experimental-8a53773
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -5
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/nativeui.d.ts +2 -1
- package/out/nativeui.d.ts.map +1 -1
- package/out/nativeui.js +23 -15
- package/out/types.d.ts +7 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js +21 -1
- package/out/typescript.d.ts.map +1 -1
- package/out/typescript.js +2 -1
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +99 -19
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
-
## 6.1.2-next.0-experimental-
|
|
3
|
+
## 6.1.2-next.0-experimental-8a53773
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 93b8edc: Send 'app packaged' analytics event
|
|
7
8
|
- Updated dependencies [10ac877]
|
|
8
9
|
- Updated dependencies [10c0bc6]
|
|
9
|
-
- Updated dependencies [
|
|
10
|
+
- Updated dependencies [93b8edc]
|
|
10
11
|
- Updated dependencies [6447811]
|
|
11
12
|
- Updated dependencies [2f446cf]
|
|
12
|
-
- @forge/cli-shared@8.3.0-next.0-experimental-
|
|
13
|
-
- @forge/manifest@10.2.1-next.0-experimental-
|
|
14
|
-
- @forge/lint@5.10.1-next.0-experimental-
|
|
13
|
+
- @forge/cli-shared@8.3.0-next.0-experimental-8a53773
|
|
14
|
+
- @forge/manifest@10.2.1-next.0-experimental-8a53773
|
|
15
|
+
- @forge/lint@5.10.1-next.0-experimental-8a53773
|
|
15
16
|
|
|
16
17
|
## 6.1.2-next.0
|
|
17
18
|
|
package/out/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { getOutputDir, getEntryPoints } from './common';
|
|
|
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, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
5
|
+
export { Bundler, BundlerError, BundlerMetadata, emptyMetadata, mergeMetadata, BundlerOutput, BundlerWatch, EntryPoint, WatcherMonitor } from './types';
|
|
6
6
|
export { getCompiler, handleWebpackCompilationResult } from './webpack';
|
|
7
7
|
export { getNativeUiBuildConfig } 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,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,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,
|
|
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,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,MAAM,mBAAmB,CAAC;AAC3D,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.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.NativeUIBundler = exports.runLinter = exports.getEntryPoints = exports.getOutputDir = void 0;
|
|
3
|
+
exports.LocalWrapperProvider = exports.getWrapperProvider = exports.getNativeUiBuildConfig = exports.handleWebpackCompilationResult = exports.getCompiler = exports.mergeMetadata = exports.emptyMetadata = exports.BundlerError = exports.NODE_RUNTIME_CODE_FILE = exports.getNodeBundler = exports.NativeUIBundler = exports.runLinter = 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; } });
|
|
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "getNodeBundler", { enumerable: true, get: functi
|
|
|
13
13
|
Object.defineProperty(exports, "NODE_RUNTIME_CODE_FILE", { enumerable: true, get: function () { return runtime_1.NODE_RUNTIME_CODE_FILE; } });
|
|
14
14
|
var types_1 = require("./types");
|
|
15
15
|
Object.defineProperty(exports, "BundlerError", { enumerable: true, get: function () { return types_1.BundlerError; } });
|
|
16
|
+
Object.defineProperty(exports, "emptyMetadata", { enumerable: true, get: function () { return types_1.emptyMetadata; } });
|
|
17
|
+
Object.defineProperty(exports, "mergeMetadata", { enumerable: true, get: function () { return types_1.mergeMetadata; } });
|
|
16
18
|
var webpack_1 = require("./webpack");
|
|
17
19
|
Object.defineProperty(exports, "getCompiler", { enumerable: true, get: function () { return webpack_1.getCompiler; } });
|
|
18
20
|
Object.defineProperty(exports, "handleWebpackCompilationResult", { enumerable: true, get: function () { return webpack_1.handleWebpackCompilationResult; } });
|
package/out/nativeui.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ResourceDetails } from '@forge/cli-shared';
|
|
2
2
|
import { Translations } from '@forge/manifest';
|
|
3
|
-
import { BundlerArgs } from './types';
|
|
3
|
+
import { BundlerArgs, BundlerMetadata } from './types';
|
|
4
4
|
import { ConfigWithOutput, WebpackBundler } from './webpack';
|
|
5
5
|
export interface NativeUIBundleResult {
|
|
6
6
|
nativeUiBundlesDetails: ResourceDetails[];
|
|
7
|
+
metadata: BundlerMetadata;
|
|
7
8
|
}
|
|
8
9
|
export declare class NativeUIBundler extends WebpackBundler {
|
|
9
10
|
getConfig({ entryPoints, i18nConfig }: BundlerArgs): Promise<ConfigWithOutput>;
|
package/out/nativeui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../src/nativeui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"nativeui.d.ts","sourceRoot":"","sources":["../src/nativeui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAgB,eAAe,EAA+C,MAAM,SAAS,CAAC;AAClH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,sBAAsB,EAAE,eAAe,EAAE,CAAC;IAC1C,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,qBAAa,eAAgB,SAAQ,cAAc;IAC3C,SAAS,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIvE,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAyCrH"}
|
package/out/nativeui.js
CHANGED
|
@@ -9,29 +9,37 @@ class NativeUIBundler extends webpack_1.WebpackBundler {
|
|
|
9
9
|
return (0, nativeui_1.getNativeUiBuildConfig)(entryPoints, i18nConfig);
|
|
10
10
|
}
|
|
11
11
|
async bundleResources(resources, i18nConfig) {
|
|
12
|
-
const entryPoints = resources.map(({ key, path }) => ({
|
|
13
|
-
name: key,
|
|
14
|
-
path
|
|
15
|
-
}));
|
|
16
12
|
const nativeUiBundlesDetails = [];
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
let combinedMetadata = (0, types_1.emptyMetadata)();
|
|
14
|
+
await Promise.all(resources.map(async (resource) => {
|
|
15
|
+
const entryPoint = {
|
|
16
|
+
name: resource.key,
|
|
17
|
+
path: resource.path
|
|
18
|
+
};
|
|
19
|
+
let bundlerOutput;
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
+
bundlerOutput = await this.bundle({
|
|
22
|
+
appDirectory: '',
|
|
23
|
+
entryPoints: [entryPoint],
|
|
24
|
+
i18nConfig
|
|
25
|
+
});
|
|
21
26
|
}
|
|
22
27
|
catch (e) {
|
|
23
28
|
throw new types_1.BundlerError(e.message);
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
30
|
+
const { outputDir, metadata } = bundlerOutput;
|
|
31
|
+
this.logger.debug(`NativeUI bundle created: ${outputDir}`);
|
|
32
|
+
nativeUiBundlesDetails.push({
|
|
33
|
+
...resource,
|
|
34
|
+
path: outputDir
|
|
31
35
|
});
|
|
32
|
-
|
|
36
|
+
if (metadata) {
|
|
37
|
+
combinedMetadata = (0, types_1.mergeMetadata)(combinedMetadata, metadata);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
33
40
|
return {
|
|
34
|
-
nativeUiBundlesDetails
|
|
41
|
+
nativeUiBundlesDetails,
|
|
42
|
+
metadata: combinedMetadata
|
|
35
43
|
};
|
|
36
44
|
}
|
|
37
45
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { I18nResourceBundle, Logger, UserError } from '@forge/cli-shared';
|
|
2
2
|
import { Translations } from '@forge/manifest';
|
|
3
3
|
export declare type BundlerMetadata = {
|
|
4
|
-
|
|
4
|
+
jsFiles: number;
|
|
5
|
+
tsFiles: number;
|
|
6
|
+
esm: boolean;
|
|
7
|
+
dependencies: Set<string>;
|
|
8
|
+
sdkImports: Set<string>;
|
|
5
9
|
};
|
|
10
|
+
export declare function emptyMetadata(): BundlerMetadata;
|
|
11
|
+
export declare function mergeMetadata(metadata1: BundlerMetadata, metadata2: BundlerMetadata): BundlerMetadata;
|
|
6
12
|
export interface BundlerOutput {
|
|
7
13
|
outputDir: string;
|
|
8
14
|
metadata?: BundlerMetadata;
|
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,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,oBAAY,eAAe,GAAG;IAC5B,OAAO,CAAC,EAA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EAAE,WAAW,CAAC,CAAC,GAAG;IACzC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEJ,oBAAY,YAAY,GAAG;IACzB,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,eAAe,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAC1G,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,kBAAkB,GAAG,cAAc,GAAG;IAChD,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjF,CAAC;AAEF,qBAAa,YAAa,SAAQ,SAAS;CAAG"}
|
package/out/types.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BundlerError = void 0;
|
|
3
|
+
exports.BundlerError = exports.mergeMetadata = exports.emptyMetadata = void 0;
|
|
4
4
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
+
function emptyMetadata() {
|
|
6
|
+
return {
|
|
7
|
+
jsFiles: 0,
|
|
8
|
+
tsFiles: 0,
|
|
9
|
+
esm: false,
|
|
10
|
+
dependencies: new Set(),
|
|
11
|
+
sdkImports: new Set()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.emptyMetadata = emptyMetadata;
|
|
15
|
+
function mergeMetadata(metadata1, metadata2) {
|
|
16
|
+
return {
|
|
17
|
+
jsFiles: metadata1.jsFiles + metadata2.jsFiles,
|
|
18
|
+
tsFiles: metadata1.tsFiles + metadata2.tsFiles,
|
|
19
|
+
esm: metadata1.esm || metadata2.esm,
|
|
20
|
+
dependencies: new Set([...metadata1.dependencies, ...metadata2.dependencies]),
|
|
21
|
+
sdkImports: new Set([...metadata1.sdkImports, ...metadata2.sdkImports])
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.mergeMetadata = mergeMetadata;
|
|
5
25
|
class BundlerError extends cli_shared_1.UserError {
|
|
6
26
|
}
|
|
7
27
|
exports.BundlerError = BundlerError;
|
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;AASlC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,
|
|
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;AASlC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAEjB,aAAK,aAAa,GAAG,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AA6B/D,8BAAsB,iBAAkB,YAAW,OAAO;IAC5C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAEnD,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa;cAqB5D,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAKjF,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAyBjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2DtF"}
|
package/out/typescript.js
CHANGED
|
@@ -10,6 +10,7 @@ const cli_shared_1 = require("@forge/cli-shared");
|
|
|
10
10
|
const common_1 = require("./common");
|
|
11
11
|
const dependencies_1 = require("./dependencies");
|
|
12
12
|
const text_1 = require("./text");
|
|
13
|
+
const types_1 = require("./types");
|
|
13
14
|
const COPY_DEPENDENCIES_OPTIONS = {
|
|
14
15
|
exclude: ['@forge/react', '@forge/bridge']
|
|
15
16
|
};
|
|
@@ -34,7 +35,7 @@ class TypeScriptBundler {
|
|
|
34
35
|
return (0, cross_spawn_1.default)(tsc, processArgs, { stdio: ['ignore', 'pipe', 'inherit'] });
|
|
35
36
|
}
|
|
36
37
|
async getResult(args, outputDir) {
|
|
37
|
-
return { outputDir, metadata:
|
|
38
|
+
return { outputDir, metadata: (0, types_1.emptyMetadata)() };
|
|
38
39
|
}
|
|
39
40
|
async bundle(args) {
|
|
40
41
|
const outputDir = (0, common_1.getOutputDir)(args);
|
package/out/webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;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= exports.handleWebpackCompilationResult = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const parser = tslib_1.__importStar(require("@babel/parser"));
|
|
8
|
+
const traverse_1 = tslib_1.__importDefault(require("@babel/traverse"));
|
|
5
9
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
6
10
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
11
|
const text_1 = require("./text");
|
|
12
|
+
const types_1 = require("./types");
|
|
8
13
|
function handleWebpackCompilationResult(logger, err, stats) {
|
|
9
14
|
if (err) {
|
|
10
15
|
throw err;
|
|
@@ -36,25 +41,103 @@ function getCompiler(config) {
|
|
|
36
41
|
return (0, webpack_1.default)(config);
|
|
37
42
|
}
|
|
38
43
|
exports.getCompiler = getCompiler;
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
function moduleFromPath(name) {
|
|
45
|
+
const depMatch = name.match(/^\.\/node_modules\/([^/]+)\/([^/]+)/);
|
|
46
|
+
if (depMatch) {
|
|
47
|
+
const moduleName = depMatch[1][0] === '@' ? `${depMatch[1]}/${depMatch[2]}` : depMatch[1];
|
|
48
|
+
return { type: 'dependency', package: moduleName };
|
|
49
|
+
}
|
|
50
|
+
const externalMatch = name.match(/^external "(?:node:)?([^:"]+)"$/);
|
|
51
|
+
if (externalMatch) {
|
|
52
|
+
return { type: 'dependency', package: externalMatch[1].split('/')[0] };
|
|
53
|
+
}
|
|
54
|
+
if (name.startsWith('webpack/runtime/')) {
|
|
55
|
+
return { type: 'internal' };
|
|
56
|
+
}
|
|
57
|
+
if (!name.includes('.js') && !name.includes('.ts')) {
|
|
58
|
+
throw new Error(`Unknown module type for ${JSON.stringify(name)}.`);
|
|
59
|
+
}
|
|
60
|
+
return { type: 'local', path: name };
|
|
61
|
+
}
|
|
62
|
+
function processModule(metadata, module) {
|
|
63
|
+
if (module.modules) {
|
|
64
|
+
for (const subModule of module.modules) {
|
|
65
|
+
processModule(metadata, subModule);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!module.name) {
|
|
70
|
+
throw new Error('Module name is missing');
|
|
71
|
+
}
|
|
72
|
+
const packedModule = moduleFromPath(module.name);
|
|
73
|
+
const issuerModule = module.issuerName ? moduleFromPath(module.issuerName) : undefined;
|
|
74
|
+
if (packedModule.type === 'local') {
|
|
75
|
+
const ext = path_1.default.extname(packedModule.path);
|
|
76
|
+
if (ext.match(/^\.[cm]?jsx?$/)) {
|
|
77
|
+
metadata.jsFiles++;
|
|
78
|
+
}
|
|
79
|
+
else if (ext.match(/^\.[cm]?tsx?$/)) {
|
|
80
|
+
metadata.tsFiles++;
|
|
81
|
+
}
|
|
82
|
+
else if (ext === '.json') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const source = (0, fs_1.readFileSync)(packedModule.path, 'utf8');
|
|
86
|
+
const ast = parser.parse(source, {
|
|
87
|
+
sourceType: 'module',
|
|
88
|
+
plugins: ['typescript', 'jsx']
|
|
89
|
+
});
|
|
90
|
+
(0, traverse_1.default)(ast, {
|
|
91
|
+
ImportDeclaration: (path) => {
|
|
92
|
+
let from = path.node.source.value;
|
|
93
|
+
if (from.startsWith('@forge/')) {
|
|
94
|
+
from = from.replace('@forge/', '');
|
|
95
|
+
for (const specifier of path.node.specifiers) {
|
|
96
|
+
let member;
|
|
97
|
+
switch (specifier.type) {
|
|
98
|
+
case 'ImportDefaultSpecifier':
|
|
99
|
+
member = specifier.local.name;
|
|
100
|
+
break;
|
|
101
|
+
case 'ImportNamespaceSpecifier':
|
|
102
|
+
member = specifier.local.name;
|
|
103
|
+
break;
|
|
104
|
+
case 'ImportSpecifier':
|
|
105
|
+
switch (specifier.imported.type) {
|
|
106
|
+
case 'Identifier':
|
|
107
|
+
member = specifier.imported.name;
|
|
108
|
+
break;
|
|
109
|
+
case 'StringLiteral':
|
|
110
|
+
member = specifier.imported.value;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
metadata.sdkImports.add(`${from}.${member}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
53
117
|
}
|
|
54
118
|
});
|
|
55
|
-
|
|
119
|
+
}
|
|
120
|
+
if (issuerModule?.type === 'local' && packedModule.type === 'dependency') {
|
|
121
|
+
metadata.dependencies.add(packedModule.package);
|
|
56
122
|
}
|
|
57
123
|
}
|
|
124
|
+
function getMetadata(stats) {
|
|
125
|
+
const { modules } = stats.toJson({ modules: true });
|
|
126
|
+
const metadata = (0, types_1.emptyMetadata)();
|
|
127
|
+
for (const module of modules ?? []) {
|
|
128
|
+
processModule(metadata, module);
|
|
129
|
+
}
|
|
130
|
+
let packageJson;
|
|
131
|
+
try {
|
|
132
|
+
const packageFile = (0, fs_1.readFileSync)('package.json', 'utf8');
|
|
133
|
+
packageJson = JSON.parse(packageFile);
|
|
134
|
+
}
|
|
135
|
+
catch { }
|
|
136
|
+
if (packageJson?.type === 'module') {
|
|
137
|
+
metadata.esm = true;
|
|
138
|
+
}
|
|
139
|
+
return metadata;
|
|
140
|
+
}
|
|
58
141
|
class WebpackBundler {
|
|
59
142
|
logger;
|
|
60
143
|
constructor(logger) {
|
|
@@ -62,10 +145,7 @@ class WebpackBundler {
|
|
|
62
145
|
}
|
|
63
146
|
async getOutput(config, stats) {
|
|
64
147
|
const outputDir = config.output.path;
|
|
65
|
-
const metadata =
|
|
66
|
-
if (stats) {
|
|
67
|
-
metadata.modules = getNodeModuleNames(stats);
|
|
68
|
-
}
|
|
148
|
+
const metadata = getMetadata(stats);
|
|
69
149
|
return { outputDir, metadata };
|
|
70
150
|
}
|
|
71
151
|
async runCompiler(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "6.1.2-next.0-experimental-
|
|
3
|
+
"version": "6.1.2-next.0-experimental-8a53773",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -13,15 +13,17 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/core": "^7.24.0",
|
|
16
|
+
"@babel/parser": "7.28.0",
|
|
16
17
|
"@babel/plugin-transform-class-properties": "^7.23.3",
|
|
17
18
|
"@babel/plugin-transform-class-static-block": "^7.23.4",
|
|
18
19
|
"@babel/plugin-transform-numeric-separator": "^7.23.4",
|
|
19
20
|
"@babel/plugin-transform-optional-chaining": "^7.23.4",
|
|
20
21
|
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
21
|
-
"@
|
|
22
|
+
"@babel/traverse": "^7.24.0",
|
|
23
|
+
"@forge/cli-shared": "8.3.0-next.0-experimental-8a53773",
|
|
22
24
|
"@forge/i18n": "0.0.7",
|
|
23
|
-
"@forge/lint": "5.10.1-next.0-experimental-
|
|
24
|
-
"@forge/manifest": "10.2.1-next.0-experimental-
|
|
25
|
+
"@forge/lint": "5.10.1-next.0-experimental-8a53773",
|
|
26
|
+
"@forge/manifest": "10.2.1-next.0-experimental-8a53773",
|
|
25
27
|
"babel-loader": "^8.3.0",
|
|
26
28
|
"cheerio": "^1.1.0",
|
|
27
29
|
"cross-spawn": "^7.0.6",
|