@forge/bundler 6.1.3 → 6.1.4-experimental-73629cc
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 +126 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/metadata.d.ts +4 -0
- package/out/metadata.d.ts.map +1 -0
- package/out/metadata.js +117 -0
- package/out/nativeui.d.ts +2 -1
- package/out/nativeui.d.ts.map +1 -1
- package/out/nativeui.js +7 -2
- package/out/runtime.d.ts +3 -3
- package/out/runtime.d.ts.map +1 -1
- package/out/runtime.js +14 -7
- package/out/text.d.ts +2 -1
- package/out/text.d.ts.map +1 -1
- package/out/text.js +4 -2
- package/out/types.d.ts +10 -2
- package/out/types.d.ts.map +1 -1
- package/out/types.js +27 -1
- package/out/typescript.d.ts +6 -4
- package/out/typescript.d.ts.map +1 -1
- package/out/typescript.js +37 -6
- package/out/webpack.d.ts +9 -6
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +44 -6
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,131 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 6.1.4-experimental-73629cc
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fe2852a: Added backend SDK for permission handling
|
|
8
|
+
- Updated dependencies [fe2852a]
|
|
9
|
+
- @forge/manifest@10.4.0-experimental-73629cc
|
|
10
|
+
- @forge/cli-shared@8.5.0-experimental-73629cc
|
|
11
|
+
- @forge/lint@5.11.0-experimental-73629cc
|
|
12
|
+
|
|
13
|
+
## 6.1.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 97c4d60: Add bundler usage to analytics
|
|
18
|
+
- 725a653: Don't collect metadata from symlinked external dependencies
|
|
19
|
+
- 7b15cc4: Hide TypeScript bundler behind an EAP
|
|
20
|
+
- d27aec7: Send analytics about failed metadata collection
|
|
21
|
+
- bda7c8d: Send 'app packaged' analytics event
|
|
22
|
+
- Updated dependencies [b262081]
|
|
23
|
+
- Updated dependencies [7e13ccd]
|
|
24
|
+
- Updated dependencies [924b093]
|
|
25
|
+
- Updated dependencies [be30715]
|
|
26
|
+
- Updated dependencies [725a653]
|
|
27
|
+
- Updated dependencies [acb3247]
|
|
28
|
+
- Updated dependencies [a0e621c]
|
|
29
|
+
- Updated dependencies [7b15cc4]
|
|
30
|
+
- Updated dependencies [17dfed4]
|
|
31
|
+
- Updated dependencies [bda7c8d]
|
|
32
|
+
- Updated dependencies [a209a3d]
|
|
33
|
+
- Updated dependencies [2a0dadd]
|
|
34
|
+
- Updated dependencies [d3b9bde]
|
|
35
|
+
- @forge/cli-shared@8.5.0
|
|
36
|
+
- @forge/manifest@10.4.0
|
|
37
|
+
- @forge/lint@5.11.0
|
|
38
|
+
|
|
39
|
+
## 6.1.4-next.9
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 97c4d60: Add bundler usage to analytics
|
|
44
|
+
- Updated dependencies [b262081]
|
|
45
|
+
- Updated dependencies [a209a3d]
|
|
46
|
+
- @forge/cli-shared@8.5.0-next.8
|
|
47
|
+
- @forge/lint@5.11.0-next.8
|
|
48
|
+
|
|
49
|
+
## 6.1.4-next.8
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 725a653: Don't collect metadata from symlinked external dependencies
|
|
54
|
+
- 7b15cc4: Hide TypeScript bundler behind an EAP
|
|
55
|
+
- Updated dependencies [725a653]
|
|
56
|
+
- Updated dependencies [a0e621c]
|
|
57
|
+
- Updated dependencies [7b15cc4]
|
|
58
|
+
- @forge/cli-shared@8.5.0-next.7
|
|
59
|
+
- @forge/lint@5.11.0-next.7
|
|
60
|
+
|
|
61
|
+
## 6.1.4-next.7
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- d27aec7: Send analytics about failed metadata collection
|
|
66
|
+
|
|
67
|
+
## 6.1.4-next.6
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [924b093]
|
|
72
|
+
- @forge/cli-shared@8.5.0-next.6
|
|
73
|
+
- @forge/lint@5.11.0-next.6
|
|
74
|
+
|
|
75
|
+
## 6.1.4-next.5
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [7e13ccd]
|
|
80
|
+
- @forge/manifest@10.4.0-next.3
|
|
81
|
+
- @forge/cli-shared@8.5.0-next.5
|
|
82
|
+
- @forge/lint@5.11.0-next.5
|
|
83
|
+
|
|
84
|
+
## 6.1.4-next.4
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [acb3247]
|
|
89
|
+
- Updated dependencies [d3b9bde]
|
|
90
|
+
- @forge/manifest@10.4.0-next.2
|
|
91
|
+
- @forge/cli-shared@8.5.0-next.4
|
|
92
|
+
- @forge/lint@5.11.0-next.4
|
|
93
|
+
|
|
94
|
+
## 6.1.4-next.3
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- Updated dependencies [17dfed4]
|
|
99
|
+
- @forge/manifest@10.4.0-next.1
|
|
100
|
+
- @forge/cli-shared@8.5.0-next.3
|
|
101
|
+
- @forge/lint@5.11.0-next.3
|
|
102
|
+
|
|
103
|
+
## 6.1.4-next.2
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Updated dependencies [2a0dadd]
|
|
108
|
+
- @forge/cli-shared@8.5.0-next.2
|
|
109
|
+
- @forge/manifest@10.4.0-next.0
|
|
110
|
+
- @forge/lint@5.11.0-next.2
|
|
111
|
+
|
|
112
|
+
## 6.1.4-next.1
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- bda7c8d: Send 'app packaged' analytics event
|
|
117
|
+
- Updated dependencies [bda7c8d]
|
|
118
|
+
- @forge/cli-shared@8.5.0-next.1
|
|
119
|
+
- @forge/lint@5.10.3-next.1
|
|
120
|
+
|
|
121
|
+
## 6.1.4-next.0
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies [be30715]
|
|
126
|
+
- @forge/cli-shared@8.5.0-next.0
|
|
127
|
+
- @forge/lint@5.10.3-next.0
|
|
128
|
+
|
|
3
129
|
## 6.1.3
|
|
4
130
|
|
|
5
131
|
### Patch Changes
|
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; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AA6KzD,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAGjH"}
|
package/out/metadata.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadata = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
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"));
|
|
9
|
+
const text_1 = require("./text");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
class MetadataCollector {
|
|
12
|
+
logger;
|
|
13
|
+
appDirectory;
|
|
14
|
+
metadata = (0, types_1.emptyMetadata)();
|
|
15
|
+
constructor(logger, appDirectory) {
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
this.appDirectory = appDirectory;
|
|
18
|
+
}
|
|
19
|
+
async processPackageJson() {
|
|
20
|
+
const packageJsonFile = path_1.default.join(this.appDirectory, 'package.json');
|
|
21
|
+
try {
|
|
22
|
+
await (0, promises_1.access)(packageJsonFile);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const packageFile = await (0, promises_1.readFile)(packageJsonFile, 'utf8');
|
|
28
|
+
const packageJson = JSON.parse(packageFile);
|
|
29
|
+
if (packageJson.type === 'module') {
|
|
30
|
+
this.metadata.esm = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static packageFromImport(name) {
|
|
34
|
+
const parts = name.split('/');
|
|
35
|
+
if (parts.length === 0 || parts[0] === '') {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
if (parts[0].startsWith('@')) {
|
|
39
|
+
return `${parts[0]}/${parts[1]}`;
|
|
40
|
+
}
|
|
41
|
+
if (parts[0].startsWith('node:')) {
|
|
42
|
+
return parts[0].substring(5);
|
|
43
|
+
}
|
|
44
|
+
return parts[0];
|
|
45
|
+
}
|
|
46
|
+
async processSourceFile(filePath) {
|
|
47
|
+
if (filePath.split('/').includes('node_modules')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const rel = path_1.default.relative(await (0, promises_1.realpath)(this.appDirectory), await (0, promises_1.realpath)(filePath));
|
|
51
|
+
if (rel.startsWith('..')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const ext = path_1.default.extname(filePath);
|
|
55
|
+
if (ext.match(/^\.[cm]?jsx?$/)) {
|
|
56
|
+
this.metadata.jsFiles++;
|
|
57
|
+
}
|
|
58
|
+
else if (ext.match(/^\.[cm]?tsx?$/)) {
|
|
59
|
+
this.metadata.tsFiles++;
|
|
60
|
+
}
|
|
61
|
+
else if (ext === '.json') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const source = await (0, promises_1.readFile)(filePath, 'utf8');
|
|
65
|
+
const ast = parser.parse(source, {
|
|
66
|
+
sourceType: 'module',
|
|
67
|
+
plugins: ['typescript', 'jsx']
|
|
68
|
+
});
|
|
69
|
+
(0, traverse_1.default)(ast, {
|
|
70
|
+
ImportDeclaration: ({ node }) => this.processImport(node)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
processImport(node) {
|
|
74
|
+
const packageName = MetadataCollector.packageFromImport(node.source.value);
|
|
75
|
+
this.metadata.dependencies.add(packageName);
|
|
76
|
+
if (packageName.startsWith('@forge/')) {
|
|
77
|
+
for (const specifier of node.specifiers) {
|
|
78
|
+
let member;
|
|
79
|
+
switch (specifier.type) {
|
|
80
|
+
case 'ImportDefaultSpecifier':
|
|
81
|
+
case 'ImportNamespaceSpecifier':
|
|
82
|
+
member = '*';
|
|
83
|
+
break;
|
|
84
|
+
case 'ImportSpecifier':
|
|
85
|
+
switch (specifier.imported.type) {
|
|
86
|
+
case 'Identifier':
|
|
87
|
+
member = specifier.imported.name;
|
|
88
|
+
break;
|
|
89
|
+
case 'StringLiteral':
|
|
90
|
+
member = specifier.imported.value;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.metadata.sdkImports.add(`${packageName}.${member}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async collect({ files }) {
|
|
99
|
+
await this.warnIfFailed(() => this.processPackageJson());
|
|
100
|
+
await Promise.all(files.map((filePath) => this.warnIfFailed(() => this.processSourceFile(filePath))));
|
|
101
|
+
return this.metadata;
|
|
102
|
+
}
|
|
103
|
+
async warnIfFailed(action) {
|
|
104
|
+
try {
|
|
105
|
+
return await action();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.logger.debug(text_1.Text.metadataFailed(error));
|
|
109
|
+
this.metadata.errors++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function getMetadata(logger, appDirectory, files) {
|
|
114
|
+
const collector = new MetadataCollector(logger, appDirectory);
|
|
115
|
+
return collector.collect({ files });
|
|
116
|
+
}
|
|
117
|
+
exports.getMetadata = getMetadata;
|
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,EAA+
|
|
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
|
@@ -10,6 +10,7 @@ class NativeUIBundler extends webpack_1.WebpackBundler {
|
|
|
10
10
|
}
|
|
11
11
|
async bundleResources(resources, i18nConfig) {
|
|
12
12
|
const nativeUiBundlesDetails = [];
|
|
13
|
+
let combinedMetadata = (0, types_1.emptyMetadata)();
|
|
13
14
|
await Promise.all(resources.map(async (resource) => {
|
|
14
15
|
const entryPoint = {
|
|
15
16
|
name: resource.key,
|
|
@@ -26,15 +27,19 @@ class NativeUIBundler extends webpack_1.WebpackBundler {
|
|
|
26
27
|
catch (e) {
|
|
27
28
|
throw new types_1.BundlerError(e.message);
|
|
28
29
|
}
|
|
29
|
-
const { outputDir } = bundlerOutput;
|
|
30
|
+
const { outputDir, metadata } = bundlerOutput;
|
|
30
31
|
this.logger.debug(`NativeUI bundle created: ${outputDir}`);
|
|
31
32
|
nativeUiBundlesDetails.push({
|
|
32
33
|
...resource,
|
|
33
34
|
path: outputDir
|
|
34
35
|
});
|
|
36
|
+
if (metadata) {
|
|
37
|
+
combinedMetadata = (0, types_1.mergeMetadata)(combinedMetadata, metadata);
|
|
38
|
+
}
|
|
35
39
|
}));
|
|
36
40
|
return {
|
|
37
|
-
nativeUiBundlesDetails
|
|
41
|
+
nativeUiBundlesDetails,
|
|
42
|
+
metadata: combinedMetadata
|
|
38
43
|
};
|
|
39
44
|
}
|
|
40
45
|
}
|
package/out/runtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConfigReader } from '@forge/cli-shared';
|
|
2
|
-
import {
|
|
1
|
+
import { ConfigReader, Logger, StatsigService } from '@forge/cli-shared';
|
|
2
|
+
import { Bundler } from './types';
|
|
3
3
|
import { WrapperProvider } from './wrapper-provider';
|
|
4
4
|
export declare const NODE_RUNTIME_CODE_FILE = "__forge__.cjs";
|
|
5
5
|
export declare function userCodePath(entryKey: string): string;
|
|
6
|
-
export declare function getNodeBundler(logger:
|
|
6
|
+
export declare function getNodeBundler(logger: Logger, wrapperProvider: WrapperProvider, configReader: ConfigReader, statsigService: StatsigService): Bundler;
|
|
7
7
|
//# 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":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAEZ,MAAM,EAEN,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,OAAO,EAAkF,MAAM,SAAS,CAAC;AAGlH,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAMpE,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAoBtD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AA6JD,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
|
@@ -7,10 +7,11 @@ const promises_1 = tslib_1.__importDefault(require("fs/promises"));
|
|
|
7
7
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
8
8
|
var RawSource = webpack_1.default.sources.RawSource;
|
|
9
9
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
10
|
+
const i18n_1 = require("@forge/i18n");
|
|
10
11
|
const common_1 = require("./config/common");
|
|
11
12
|
const typescript_1 = require("./typescript");
|
|
12
13
|
const webpack_2 = require("./webpack");
|
|
13
|
-
const
|
|
14
|
+
const text_1 = require("./text");
|
|
14
15
|
exports.NODE_RUNTIME_CODE_FILE = '__forge__.cjs';
|
|
15
16
|
const NODE_RUNTIME_BACKUP_WRAPPER_FILE = '__forge_wrapper__.cjs';
|
|
16
17
|
const NODE_RUNTIME_USE_LOCAL_WRAPPER_FILE = '__forge_use_local_wrapper.txt';
|
|
@@ -80,8 +81,8 @@ class TypeScriptNodeBundler extends typescript_1.TypeScriptBundler {
|
|
|
80
81
|
super(logger);
|
|
81
82
|
this.wrapperProvider = wrapperProvider;
|
|
82
83
|
}
|
|
83
|
-
async getResult(args, outputDir) {
|
|
84
|
-
const result = await super.getResult(args, outputDir);
|
|
84
|
+
async getResult(args, outputDir, output) {
|
|
85
|
+
const result = await super.getResult(args, outputDir, output);
|
|
85
86
|
const emit = async (name, contents) => {
|
|
86
87
|
const outputPath = path_1.default.join(outputDir, name);
|
|
87
88
|
await promises_1.default.mkdir(path_1.default.dirname(outputPath), { recursive: true });
|
|
@@ -96,16 +97,22 @@ class TypeScriptNodeBundler extends typescript_1.TypeScriptBundler {
|
|
|
96
97
|
}
|
|
97
98
|
class ConfigBundler {
|
|
98
99
|
configReader;
|
|
100
|
+
statsigService;
|
|
99
101
|
bundlers;
|
|
100
|
-
constructor(logger, wrapperProvider, configReader) {
|
|
102
|
+
constructor(logger, wrapperProvider, configReader, statsigService) {
|
|
101
103
|
this.configReader = configReader;
|
|
104
|
+
this.statsigService = statsigService;
|
|
102
105
|
this.bundlers = new Map([
|
|
103
106
|
['webpack', new NodeBundler(logger, wrapperProvider)],
|
|
104
107
|
['typescript', new TypeScriptNodeBundler(logger, wrapperProvider)]
|
|
105
108
|
]);
|
|
106
109
|
}
|
|
107
110
|
async getBundlerType() {
|
|
108
|
-
|
|
111
|
+
const configuredBundler = (await this.configReader.readConfig()).app.package?.bundler ?? 'webpack';
|
|
112
|
+
if (configuredBundler === 'typescript' && !(await this.statsigService.isTypescriptBundlerEnabled())) {
|
|
113
|
+
throw new cli_shared_1.UserError(text_1.Text.typescriptBundlerEAP);
|
|
114
|
+
}
|
|
115
|
+
return configuredBundler;
|
|
109
116
|
}
|
|
110
117
|
async getBundler() {
|
|
111
118
|
return this.bundlers.get(await this.getBundlerType());
|
|
@@ -117,7 +124,7 @@ class ConfigBundler {
|
|
|
117
124
|
return (await this.getBundler()).watch(args, watch);
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
|
-
function getNodeBundler(logger, wrapperProvider, configReader) {
|
|
121
|
-
return new ConfigBundler(logger, wrapperProvider, configReader);
|
|
127
|
+
function getNodeBundler(logger, wrapperProvider, configReader, statsigService) {
|
|
128
|
+
return new ConfigBundler(logger, wrapperProvider, configReader, statsigService);
|
|
122
129
|
}
|
|
123
130
|
exports.getNodeBundler = getNodeBundler;
|
package/out/text.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const Text: {
|
|
|
2
2
|
genericBundlingError: (errors: string[]) => string;
|
|
3
3
|
typescriptError: (errors: string[]) => string;
|
|
4
4
|
noExecutableFile: string;
|
|
5
|
-
|
|
5
|
+
metadataFailed: (error: Error) => string;
|
|
6
|
+
typescriptBundlerEAP: string;
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=text.d.ts.map
|
package/out/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;mCACgB,MAAM,EAAE;8BACb,MAAM,EAAE;;4BAKV,KAAK;;CAE9B,CAAC"}
|
package/out/text.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Text = void 0;
|
|
4
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
4
5
|
exports.Text = {
|
|
5
6
|
genericBundlingError: (errors) => `Bundling failed: ${errors.join(', ')}`,
|
|
6
|
-
typescriptError: (errors) => `TypeScript errors in the app caused the bundling to fail. Fix the errors listed below before rerunning the command. ${errors.join('')}`,
|
|
7
|
+
typescriptError: (errors) => `TypeScript errors in the app caused the bundling to fail. Fix the errors listed below before rerunning the command. ${errors.join('\n')}`,
|
|
7
8
|
noExecutableFile: 'Could not find the main executable file',
|
|
8
|
-
|
|
9
|
+
metadataFailed: (error) => `Application code metadata processing failed: ${error.message}`,
|
|
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.`
|
|
9
11
|
};
|
package/out/types.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { I18nResourceBundle,
|
|
1
|
+
import { I18nResourceBundle, UserError } from '@forge/cli-shared';
|
|
2
2
|
import { Translations } from '@forge/manifest';
|
|
3
3
|
export declare type BundlerMetadata = {
|
|
4
4
|
modules?: string[];
|
|
5
|
+
jsFiles: number;
|
|
6
|
+
tsFiles: number;
|
|
7
|
+
esm: boolean;
|
|
8
|
+
dependencies: Set<string>;
|
|
9
|
+
sdkImports: Set<string>;
|
|
10
|
+
errors: number;
|
|
11
|
+
bundler?: string;
|
|
5
12
|
};
|
|
13
|
+
export declare function emptyMetadata(): BundlerMetadata;
|
|
14
|
+
export declare function mergeMetadata(metadata1: BundlerMetadata, metadata2: BundlerMetadata): BundlerMetadata;
|
|
6
15
|
export interface BundlerOutput {
|
|
7
16
|
outputDir: string;
|
|
8
17
|
metadata?: BundlerMetadata;
|
|
9
18
|
}
|
|
10
|
-
export declare type BundleLogger = Pick<Logger, 'trace' | 'debug' | 'info' | 'warn' | 'error'>;
|
|
11
19
|
export declare type BundlerWatchMode = 'watch' | 'debug';
|
|
12
20
|
export declare type EntryPoint = {
|
|
13
21
|
name: string;
|
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,
|
|
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,oBAAY,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;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,aAAa,IAAI,eAAe,CAS/C;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAAG,eAAe,CAarG;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,oBAAY,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF,oBAAY,gBAAgB,GAAG,WAAW,GACxC,QAAQ,CAAC,IAAI,CAAC,WAAW,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,33 @@
|
|
|
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
|
+
errors: 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.emptyMetadata = emptyMetadata;
|
|
16
|
+
function mergeMetadata(metadata1, metadata2) {
|
|
17
|
+
return {
|
|
18
|
+
...((metadata1.modules || metadata2.modules) && {
|
|
19
|
+
modules: [...(metadata1.modules ?? []), ...(metadata2.modules ?? [])]
|
|
20
|
+
}),
|
|
21
|
+
jsFiles: metadata1.jsFiles + metadata2.jsFiles,
|
|
22
|
+
tsFiles: metadata1.tsFiles + metadata2.tsFiles,
|
|
23
|
+
esm: metadata1.esm || metadata2.esm,
|
|
24
|
+
dependencies: new Set([...metadata1.dependencies, ...metadata2.dependencies]),
|
|
25
|
+
sdkImports: new Set([...metadata1.sdkImports, ...metadata2.sdkImports]),
|
|
26
|
+
errors: metadata1.errors + metadata2.errors,
|
|
27
|
+
bundler: metadata1.bundler || metadata2.bundler
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.mergeMetadata = mergeMetadata;
|
|
5
31
|
class BundlerError extends cli_shared_1.UserError {
|
|
6
32
|
}
|
|
7
33
|
exports.BundlerError = BundlerError;
|
package/out/typescript.d.ts
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { ChildProcessByStdio } from 'child_process';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
|
-
import {
|
|
5
|
+
import { Logger } from '@forge/cli-shared';
|
|
6
|
+
import { Bundler, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
6
7
|
declare type OutputProcess = ChildProcessByStdio<null, Readable, null>;
|
|
7
8
|
export declare abstract class TypeScriptBundler implements Bundler {
|
|
8
|
-
protected readonly logger:
|
|
9
|
-
constructor(logger:
|
|
9
|
+
protected readonly logger: Logger;
|
|
10
|
+
constructor(logger: Logger);
|
|
10
11
|
protected runTypeScript(args: BundlerArgs, outputDir: string): OutputProcess;
|
|
11
|
-
protected
|
|
12
|
+
protected isListedFile(line: string): string | null;
|
|
13
|
+
protected getResult(args: BundlerArgs, outputDir: string, output?: string): Promise<BundlerOutput>;
|
|
12
14
|
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
|
13
15
|
watch(args: BundlerWatchArgs, watch: BundlerWatch): Promise<BundlerWatchOutput>;
|
|
14
16
|
}
|
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;
|
|
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;AAKrE,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAGjB,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,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,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBlG,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IA6BjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2DtF"}
|
package/out/typescript.js
CHANGED
|
@@ -10,6 +10,8 @@ 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");
|
|
14
|
+
const metadata_1 = require("./metadata");
|
|
13
15
|
const COPY_DEPENDENCIES_OPTIONS = {
|
|
14
16
|
exclude: ['@forge/react', '@forge/bridge']
|
|
15
17
|
};
|
|
@@ -25,6 +27,9 @@ class TypeScriptBundler {
|
|
|
25
27
|
if (args.watchMode) {
|
|
26
28
|
processArgs.push('--watch');
|
|
27
29
|
}
|
|
30
|
+
else {
|
|
31
|
+
processArgs.push('--listFiles');
|
|
32
|
+
}
|
|
28
33
|
processArgs.push('--outDir', outputDir);
|
|
29
34
|
let tsc = 'tsc';
|
|
30
35
|
const appTsc = path_1.default.join(args.appDirectory, common_1.NODE_MODULES_DIR, '.bin', 'tsc');
|
|
@@ -33,21 +38,47 @@ class TypeScriptBundler {
|
|
|
33
38
|
}
|
|
34
39
|
return (0, cross_spawn_1.default)(tsc, processArgs, { stdio: ['ignore', 'pipe', 'inherit'] });
|
|
35
40
|
}
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
isListedFile(line) {
|
|
42
|
+
line = line.trim();
|
|
43
|
+
if (line.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (!line.match(/^\/.+\.[cm]?[jt]sx?$/)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return line;
|
|
50
|
+
}
|
|
51
|
+
async getResult(args, outputDir, output) {
|
|
52
|
+
let metadata;
|
|
53
|
+
if (output) {
|
|
54
|
+
const files = [];
|
|
55
|
+
for (const line of output.split('\n')) {
|
|
56
|
+
const filePath = this.isListedFile(line);
|
|
57
|
+
if (filePath) {
|
|
58
|
+
files.push(filePath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
metadata = await (0, metadata_1.getMetadata)(this.logger, args.appDirectory, files);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
metadata = (0, types_1.emptyMetadata)();
|
|
65
|
+
}
|
|
66
|
+
metadata.bundler = 'typescript';
|
|
67
|
+
return { outputDir, metadata };
|
|
38
68
|
}
|
|
39
69
|
async bundle(args) {
|
|
40
70
|
const outputDir = (0, common_1.getOutputDir)(args);
|
|
41
71
|
await (0, dependencies_1.copyProductionDependencies)(args.appDirectory, outputDir, COPY_DEPENDENCIES_OPTIONS);
|
|
42
72
|
const compiler = this.runTypeScript(args, outputDir);
|
|
43
|
-
|
|
44
|
-
compiler.stdout.on('data', (data) => output.
|
|
73
|
+
let output = '';
|
|
74
|
+
compiler.stdout.on('data', (data) => (output += data.toString()));
|
|
45
75
|
return new Promise((resolve, reject) => compiler.on('exit', async (code) => {
|
|
46
76
|
try {
|
|
47
77
|
if (code !== 0) {
|
|
48
|
-
|
|
78
|
+
const errors = output.split('\n').filter((line) => !this.isListedFile(line));
|
|
79
|
+
throw new cli_shared_1.BundlerTSError(text_1.Text.typescriptError(errors));
|
|
49
80
|
}
|
|
50
|
-
const result = await this.getResult(args, outputDir);
|
|
81
|
+
const result = await this.getResult(args, outputDir, output);
|
|
51
82
|
resolve(result);
|
|
52
83
|
}
|
|
53
84
|
catch (e) {
|
package/out/webpack.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
|
+
import { Logger } from '@forge/cli-shared';
|
|
2
3
|
import { CommonOutputOptions } from './config/common';
|
|
3
|
-
import { Bundler,
|
|
4
|
-
export declare function handleWebpackCompilationResult(logger:
|
|
4
|
+
import { Bundler, BundlerOutput, BundlerArgs, BundlerWatch, BundlerWatchArgs, BundlerWatchOutput } from './types';
|
|
5
|
+
export declare function handleWebpackCompilationResult(logger: Logger, err: Error | null | undefined, stats: Pick<webpack.Stats, 'hasErrors' | 'hasWarnings' | 'toJson'> | undefined): asserts stats is webpack.Stats;
|
|
5
6
|
export declare function getCompiler(config: webpack.Configuration): webpack.Compiler;
|
|
6
7
|
export declare type ConfigWithOutput = webpack.Configuration & {
|
|
7
8
|
output: CommonOutputOptions;
|
|
8
9
|
};
|
|
9
10
|
export declare abstract class WebpackBundler implements Bundler {
|
|
10
|
-
protected readonly logger:
|
|
11
|
-
constructor(logger:
|
|
12
|
-
protected getOutput(config: ConfigWithOutput, stats: webpack.Stats): Promise<BundlerOutput>;
|
|
13
|
-
protected
|
|
11
|
+
protected readonly logger: Logger;
|
|
12
|
+
constructor(logger: Logger);
|
|
13
|
+
protected getOutput(args: BundlerArgs, config: ConfigWithOutput, stats: webpack.Stats): Promise<BundlerOutput>;
|
|
14
|
+
protected isRegularModule(name: string): boolean;
|
|
15
|
+
protected localModules(stats: webpack.Stats): string[];
|
|
16
|
+
protected runCompiler(args: BundlerArgs, config: ConfigWithOutput): Promise<BundlerOutput>;
|
|
14
17
|
abstract getConfig(args: BundlerArgs): Promise<ConfigWithOutput>;
|
|
15
18
|
bundle(args: BundlerArgs): Promise<BundlerOutput>;
|
|
16
19
|
watch(args: BundlerWatchArgs, watch: BundlerWatch): Promise<BundlerWatchOutput>;
|
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":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,EAA4B,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EACL,OAAO,EAEP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC,GAAG,SAAS,GAC7E,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAkChC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,QAAQ,CAE3E;AAqBD,oBAAY,gBAAgB,GAAG,OAAO,CAAC,aAAa,GAAG;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEvF,8BAAsB,cAAe,YAAW,OAAO;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;cAE7B,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBpH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAsBhD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,MAAM,EAAE;cA0BtC,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAsBhG,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAE1D,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAKjD,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsCtF"}
|
package/out/webpack.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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"));
|
|
5
6
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
6
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
|
+
const metadata_1 = require("./metadata");
|
|
7
9
|
const text_1 = require("./text");
|
|
8
10
|
function handleWebpackCompilationResult(logger, err, stats) {
|
|
9
11
|
if (err) {
|
|
@@ -60,15 +62,51 @@ class WebpackBundler {
|
|
|
60
62
|
constructor(logger) {
|
|
61
63
|
this.logger = logger;
|
|
62
64
|
}
|
|
63
|
-
async getOutput(config, stats) {
|
|
65
|
+
async getOutput(args, config, stats) {
|
|
64
66
|
const outputDir = config.output.path;
|
|
65
|
-
const metadata =
|
|
67
|
+
const metadata = await (0, metadata_1.getMetadata)(this.logger, args.appDirectory, this.localModules(stats));
|
|
66
68
|
if (stats) {
|
|
67
69
|
metadata.modules = getNodeModuleNames(stats);
|
|
68
70
|
}
|
|
69
71
|
return { outputDir, metadata };
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
isRegularModule(name) {
|
|
74
|
+
if (name.match(/^external "(?:node:)?([^:"]+)"$/)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (name.startsWith('webpack/runtime/')) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (path_1.default.extname(name) === '.json') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!path_1.default.extname(name).match(/^\.[cm]?[jt]sx?$/)) {
|
|
84
|
+
throw new Error(`Unknown module type for ${JSON.stringify(name)}.`);
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
localModules(stats) {
|
|
89
|
+
const { modules } = stats.toJson({ modules: true });
|
|
90
|
+
const result = [];
|
|
91
|
+
const addModules = (modules) => {
|
|
92
|
+
for (const module of modules) {
|
|
93
|
+
if (module.modules) {
|
|
94
|
+
addModules(module.modules);
|
|
95
|
+
}
|
|
96
|
+
else if (!module.name) {
|
|
97
|
+
throw new Error('Module name is missing');
|
|
98
|
+
}
|
|
99
|
+
else if (this.isRegularModule(module.name)) {
|
|
100
|
+
result.push(module.name);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
if (modules) {
|
|
105
|
+
addModules(modules);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
async runCompiler(args, config) {
|
|
72
110
|
const compiler = getCompiler(config);
|
|
73
111
|
return new Promise((resolve, reject) => {
|
|
74
112
|
compiler.run(async (compilerError, stats) => {
|
|
@@ -79,7 +117,7 @@ class WebpackBundler {
|
|
|
79
117
|
reject(closeError);
|
|
80
118
|
}
|
|
81
119
|
});
|
|
82
|
-
resolve(await this.getOutput(config, stats));
|
|
120
|
+
resolve(await this.getOutput(args, config, stats));
|
|
83
121
|
}
|
|
84
122
|
catch (err) {
|
|
85
123
|
reject(err);
|
|
@@ -89,7 +127,7 @@ class WebpackBundler {
|
|
|
89
127
|
}
|
|
90
128
|
async bundle(args) {
|
|
91
129
|
const config = await this.getConfig(args);
|
|
92
|
-
return await this.runCompiler(config);
|
|
130
|
+
return await this.runCompiler(args, config);
|
|
93
131
|
}
|
|
94
132
|
async watch(args, watch) {
|
|
95
133
|
const config = await this.getConfig(args);
|
|
@@ -106,7 +144,7 @@ class WebpackBundler {
|
|
|
106
144
|
try {
|
|
107
145
|
handleWebpackCompilationResult(this.logger, compilerError, stats);
|
|
108
146
|
this.logger.info(cli_shared_1.LogColor.trace(args.successMessage));
|
|
109
|
-
const result = await this.getOutput(config, stats);
|
|
147
|
+
const result = await this.getOutput(args, config, stats);
|
|
110
148
|
if (isFirstRun) {
|
|
111
149
|
isFirstRun = false;
|
|
112
150
|
resolve({ result, stop: () => watching.close(() => void 0) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.4-experimental-73629cc",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -13,15 +13,18 @@
|
|
|
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
|
+
"@babel/types": "^7.24.0",
|
|
24
|
+
"@forge/cli-shared": "8.5.0-experimental-73629cc",
|
|
22
25
|
"@forge/i18n": "0.0.7",
|
|
23
|
-
"@forge/lint": "5.
|
|
24
|
-
"@forge/manifest": "10.
|
|
26
|
+
"@forge/lint": "5.11.0-experimental-73629cc",
|
|
27
|
+
"@forge/manifest": "10.4.0-experimental-73629cc",
|
|
25
28
|
"babel-loader": "^8.3.0",
|
|
26
29
|
"cheerio": "^1.1.0",
|
|
27
30
|
"cross-spawn": "^7.0.6",
|
|
@@ -31,6 +34,7 @@
|
|
|
31
34
|
"node-fetch": "2.7.0",
|
|
32
35
|
"tmp": "^0.2.3",
|
|
33
36
|
"ts-loader": "^9.5.2",
|
|
37
|
+
"type-fest": "4.10.2",
|
|
34
38
|
"typescript": "4.8.4",
|
|
35
39
|
"webpack": "^5.99.9",
|
|
36
40
|
"webpack-bundle-analyzer": "^4.10.2"
|