@embroider/core 3.1.2 → 3.1.3-unstable.326562b
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/package.json +11 -11
- package/src/module-resolver.js +3 -13
- package/src/module-resolver.js.map +1 -1
- package/LICENSE +0 -21
- package/src/app-differ.d.ts +0 -11
- package/src/app-differ.js +0 -178
- package/src/app-differ.js.map +0 -1
- package/src/app.d.ts +0 -94
- package/src/app.js +0 -1177
- package/src/app.js.map +0 -1
- package/src/build-stage.d.ts +0 -27
- package/src/build-stage.js +0 -67
- package/src/build-stage.js.map +0 -1
- package/src/engine-mangler.d.ts +0 -2
- package/src/engine-mangler.js +0 -8
- package/src/engine-mangler.js.map +0 -1
- package/src/multi-tree-diff.d.ts +0 -28
- package/src/multi-tree-diff.js +0 -140
- package/src/multi-tree-diff.js.map +0 -1
- package/src/output-tree.d.ts +0 -2
- package/src/output-tree.js +0 -25
- package/src/output-tree.js.map +0 -1
- package/src/rename-require-plugin.d.ts +0 -1
- package/src/rename-require-plugin.js +0 -15
- package/src/rename-require-plugin.js.map +0 -1
package/src/app-differ.js
DELETED
@@ -1,178 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const multi_tree_diff_1 = __importDefault(require("./multi-tree-diff"));
|
7
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
8
|
-
const path_1 = require("path");
|
9
|
-
const messages_1 = require("./messages");
|
10
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
11
|
-
const fs_1 = require("fs");
|
12
|
-
const util_1 = require("util");
|
13
|
-
class AppDiffer {
|
14
|
-
constructor(ownAppJSDir, activeAddonDescendants,
|
15
|
-
// arguments below this point are only needed in fastboot mode. Fastboot
|
16
|
-
// makes this pretty messy because fastboot trees all merge into the app 🤮.
|
17
|
-
fastbootEnabled = false, ownFastbootJSDir) {
|
18
|
-
this.firstFastbootTree = Infinity;
|
19
|
-
// set of filenames logically located in the app
|
20
|
-
this.files = new Set();
|
21
|
-
// true for files that are fastboot-only.
|
22
|
-
this.isFastbootOnly = new Map();
|
23
|
-
this.sources = activeAddonDescendants.map(addon => maybeSource(addon, 'app-js')).filter(Boolean);
|
24
|
-
this.sources.push({
|
25
|
-
mayChange: true,
|
26
|
-
walk() {
|
27
|
-
return walk_sync_1.default.entries(ownAppJSDir);
|
28
|
-
},
|
29
|
-
isRelocated: false,
|
30
|
-
locate(relativePath) {
|
31
|
-
return (0, path_1.resolve)(ownAppJSDir, relativePath);
|
32
|
-
},
|
33
|
-
});
|
34
|
-
if (!fastbootEnabled) {
|
35
|
-
this.differ = new multi_tree_diff_1.default(this.sources, lastOneWins);
|
36
|
-
return;
|
37
|
-
}
|
38
|
-
this.firstFastbootTree = this.sources.length;
|
39
|
-
for (let addon of activeAddonDescendants) {
|
40
|
-
let source = maybeSource(addon, 'fastboot-js');
|
41
|
-
if (source) {
|
42
|
-
this.sources.push(source);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
if (ownFastbootJSDir) {
|
46
|
-
this.sources.push({
|
47
|
-
mayChange: true,
|
48
|
-
walk() {
|
49
|
-
return walk_sync_1.default.entries(ownFastbootJSDir);
|
50
|
-
},
|
51
|
-
isRelocated: false,
|
52
|
-
locate(relativePath) {
|
53
|
-
return (0, path_1.resolve)(ownFastbootJSDir, relativePath);
|
54
|
-
},
|
55
|
-
});
|
56
|
-
}
|
57
|
-
this.differ = new multi_tree_diff_1.default(this.sources, fastbootMerge(this.firstFastbootTree));
|
58
|
-
}
|
59
|
-
update() {
|
60
|
-
let { ops, sources } = this.differ.update();
|
61
|
-
(0, messages_1.debug)(`app-differ operations count: %s`, ops.length);
|
62
|
-
for (let [operation, relativePath] of ops) {
|
63
|
-
switch (operation) {
|
64
|
-
case 'unlink':
|
65
|
-
this.files.delete(relativePath);
|
66
|
-
break;
|
67
|
-
case 'rmdir':
|
68
|
-
case 'mkdir':
|
69
|
-
case 'change':
|
70
|
-
// this used to actually write to disk but we have moved the functionality into the resolver code
|
71
|
-
break;
|
72
|
-
case 'create':
|
73
|
-
let sourceIndices = sources.get(relativePath);
|
74
|
-
if (sourceIndices.length === 1) {
|
75
|
-
// a single file won. whether it's fastboot or non-fastboot doesn't
|
76
|
-
// actually change what we do here. It gets emitted in the app's
|
77
|
-
// namespace (if it's fastboot-only, non-fastboot code shouldn't be
|
78
|
-
// trying to import it anyway, because that would have already been
|
79
|
-
// an error pre-embroider).
|
80
|
-
this.isFastbootOnly.set(relativePath, sourceIndices[0] >= this.firstFastbootTree);
|
81
|
-
this.updateFiles(relativePath);
|
82
|
-
}
|
83
|
-
else {
|
84
|
-
// we have both fastboot and non-fastboot files for this path.
|
85
|
-
// Because of the way fastbootMerge is written, the first one is the
|
86
|
-
// non-fastboot.
|
87
|
-
this.isFastbootOnly.set(relativePath, false);
|
88
|
-
this.updateFiles(relativePath);
|
89
|
-
}
|
90
|
-
break;
|
91
|
-
default:
|
92
|
-
(0, assert_never_1.default)(operation);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
updateFiles(relativePath) {
|
97
|
-
this.files.add(relativePath);
|
98
|
-
}
|
99
|
-
}
|
100
|
-
exports.default = AppDiffer;
|
101
|
-
function lastOneWins(treeIds) {
|
102
|
-
return treeIds.slice(-1);
|
103
|
-
}
|
104
|
-
function fastbootMerge(firstFastbootTree) {
|
105
|
-
return function _fastbootMerge(treeIds) {
|
106
|
-
let mainWinner, fastbootWinner;
|
107
|
-
for (let id of treeIds) {
|
108
|
-
if (id < firstFastbootTree) {
|
109
|
-
mainWinner = id;
|
110
|
-
}
|
111
|
-
else {
|
112
|
-
fastbootWinner = id;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
if (mainWinner != null && fastbootWinner != null) {
|
116
|
-
return [mainWinner, fastbootWinner];
|
117
|
-
}
|
118
|
-
else if (mainWinner != null) {
|
119
|
-
return [mainWinner];
|
120
|
-
}
|
121
|
-
else if (fastbootWinner != null) {
|
122
|
-
return [fastbootWinner];
|
123
|
-
}
|
124
|
-
else {
|
125
|
-
throw new Error(`bug: should always have at least one winner in fastbootMerge`);
|
126
|
-
}
|
127
|
-
};
|
128
|
-
}
|
129
|
-
function maybeSource(addon, key) {
|
130
|
-
let maybeFiles = addon.meta[key];
|
131
|
-
if (maybeFiles) {
|
132
|
-
let files = maybeFiles;
|
133
|
-
return {
|
134
|
-
mayChange: addon.mayRebuild,
|
135
|
-
walk() {
|
136
|
-
return Object.entries(files).map(([externalName, internalName]) => {
|
137
|
-
try {
|
138
|
-
let stat = (0, fs_1.statSync)((0, path_1.resolve)(addon.root, internalName));
|
139
|
-
return {
|
140
|
-
relativePath: withoutMandatoryDotSlash(externalName, [
|
141
|
-
'in package.json at %s in key ember-addon.%s',
|
142
|
-
addon.root,
|
143
|
-
key,
|
144
|
-
]),
|
145
|
-
mode: stat.mode,
|
146
|
-
size: stat.size,
|
147
|
-
mtime: stat.mtime,
|
148
|
-
isDirectory() {
|
149
|
-
return false;
|
150
|
-
},
|
151
|
-
};
|
152
|
-
}
|
153
|
-
catch (err) {
|
154
|
-
if (err.code === 'ENOENT') {
|
155
|
-
throw new Error(`${addon.name}/package.json lists ${internalName} in ember-addon.${key}, but that file does not exist`);
|
156
|
-
}
|
157
|
-
throw err;
|
158
|
-
}
|
159
|
-
});
|
160
|
-
},
|
161
|
-
isRelocated: true,
|
162
|
-
locate(relativePath) {
|
163
|
-
let internal = files['./' + relativePath];
|
164
|
-
if (!internal) {
|
165
|
-
throw new Error(`bug: couldn't find ${relativePath} in ${JSON.stringify(files)}`);
|
166
|
-
}
|
167
|
-
return (0, path_1.resolve)(addon.root, internal);
|
168
|
-
},
|
169
|
-
};
|
170
|
-
}
|
171
|
-
}
|
172
|
-
function withoutMandatoryDotSlash(filename, debugInfo) {
|
173
|
-
if (!filename.startsWith('./')) {
|
174
|
-
throw new Error(`${(0, util_1.format)(debugInfo)}: ${filename} is required to start with "./"`);
|
175
|
-
}
|
176
|
-
return filename.slice(2);
|
177
|
-
}
|
178
|
-
//# sourceMappingURL=app-differ.js.map
|
package/src/app-differ.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"app-differ.js","sourceRoot":"","sources":["app-differ.ts"],"names":[],"mappings":";;;;;AACA,wEAA6D;AAC7D,0DAAiC;AACjC,+BAA+B;AAC/B,yCAAmC;AACnC,gEAAuC;AACvC,2BAA8B;AAC9B,+BAA8B;AAE9B,MAAqB,SAAS;IAW5B,YACE,WAAmB,EACnB,sBAAsC;IACtC,wEAAwE;IACxE,4EAA4E;IAC5E,eAAe,GAAG,KAAK,EACvB,gBAAqC;QAd/B,sBAAiB,GAAG,QAAQ,CAAC;QAErC,gDAAgD;QACvC,UAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;QAExC,yCAAyC;QACzC,mBAAc,GAAyB,IAAI,GAAG,EAAE,CAAC;QAU/C,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC;QAE7G,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,SAAS,EAAE,IAAI;YACf,IAAI;gBACF,OAAO,mBAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;YACD,WAAW,EAAE,KAAK;YAClB,MAAM,CAAC,YAAoB;gBACzB,OAAO,IAAA,cAAO,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5C,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,yBAAa,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC3D,OAAO;SACR;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ACH,CAAC,CAAC,CAAC;YACL,CAAC;YACD,WAAW,EAAE,IAAI;YACjB,MAAM,CAAC,YAAoB;gBACzB,IAAI,QAAQ,GAAG,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;gBAC1C,IAAI,CAAC,QAAQ,EAAE;oBACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;iBACnF;gBACD,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;SACF,CAAC;KACH;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,QAAgB,EAAE,SAAgB;IAClE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAA,aAAM,EAAC,SAAS,CAAC,KAAK,QAAQ,iCAAiC,CAAC,CAAC;KACrF;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { AddonPackage } from '@embroider/shared-internals';\nimport MultiTreeDiff, { InputTree } from './multi-tree-diff';\nimport walkSync from 'walk-sync';\nimport { resolve } from 'path';\nimport { debug } from './messages';\nimport assertNever from 'assert-never';\nimport { statSync } from 'fs';\nimport { format } from 'util';\n\nexport default class AppDiffer {\n private differ: MultiTreeDiff;\n private sources: Source[];\n private firstFastbootTree = Infinity;\n\n // set of filenames logically located in the app\n readonly files: Set<string> = new Set();\n\n // true for files that are fastboot-only.\n isFastbootOnly: Map<string, boolean> = new Map();\n\n constructor(\n ownAppJSDir: string,\n activeAddonDescendants: AddonPackage[],\n // arguments below this point are only needed in fastboot mode. Fastboot\n // makes this pretty messy because fastboot trees all merge into the app 🤮.\n fastbootEnabled = false,\n ownFastbootJSDir?: string | undefined\n ) {\n this.sources = activeAddonDescendants.map(addon => maybeSource(addon, 'app-js')).filter(Boolean) as Source[];\n\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownAppJSDir);\n },\n isRelocated: false,\n locate(relativePath: string) {\n return resolve(ownAppJSDir, relativePath);\n },\n });\n\n if (!fastbootEnabled) {\n this.differ = new MultiTreeDiff(this.sources, lastOneWins);\n return;\n }\n\n this.firstFastbootTree = this.sources.length;\n for (let addon of activeAddonDescendants) {\n let source = maybeSource(addon, 'fastboot-js');\n if (source) {\n this.sources.push(source);\n }\n }\n if (ownFastbootJSDir) {\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownFastbootJSDir);\n },\n isRelocated: false,\n locate(relativePath) {\n return resolve(ownFastbootJSDir, relativePath);\n },\n });\n }\n this.differ = new MultiTreeDiff(this.sources, fastbootMerge(this.firstFastbootTree));\n }\n\n update() {\n let { ops, sources } = this.differ.update();\n debug(`app-differ operations count: %s`, ops.length);\n for (let [operation, relativePath] of ops) {\n switch (operation) {\n case 'unlink':\n this.files.delete(relativePath);\n break;\n case 'rmdir':\n case 'mkdir':\n case 'change':\n // this used to actually write to disk but we have moved the functionality into the resolver code\n break;\n case 'create':\n let sourceIndices = sources.get(relativePath)!;\n if (sourceIndices.length === 1) {\n // a single file won. whether it's fastboot or non-fastboot doesn't\n // actually change what we do here. It gets emitted in the app's\n // namespace (if it's fastboot-only, non-fastboot code shouldn't be\n // trying to import it anyway, because that would have already been\n // an error pre-embroider).\n this.isFastbootOnly.set(relativePath, sourceIndices[0] >= this.firstFastbootTree);\n this.updateFiles(relativePath);\n } else {\n // we have both fastboot and non-fastboot files for this path.\n // Because of the way fastbootMerge is written, the first one is the\n // non-fastboot.\n this.isFastbootOnly.set(relativePath, false);\n this.updateFiles(relativePath);\n }\n break;\n default:\n assertNever(operation);\n }\n }\n }\n\n private updateFiles(relativePath: string) {\n this.files.add(relativePath);\n }\n}\n\nfunction lastOneWins(treeIds: number[]) {\n return treeIds.slice(-1);\n}\n\nfunction fastbootMerge(firstFastbootTree: number) {\n return function _fastbootMerge(treeIds: number[]): number[] {\n let mainWinner, fastbootWinner;\n for (let id of treeIds) {\n if (id < firstFastbootTree) {\n mainWinner = id;\n } else {\n fastbootWinner = id;\n }\n }\n if (mainWinner != null && fastbootWinner != null) {\n return [mainWinner, fastbootWinner];\n } else if (mainWinner != null) {\n return [mainWinner];\n } else if (fastbootWinner != null) {\n return [fastbootWinner];\n } else {\n throw new Error(`bug: should always have at least one winner in fastbootMerge`);\n }\n };\n}\n\ninterface Source extends InputTree {\n // find the real on disk location of the file that is presented externally as\n // `relativePath`\n locate(relativePath: string): string;\n\n // true if this source relocates its file out of their original package,\n // meaning we will need to track them in order to adjust package resolution\n isRelocated: boolean;\n}\n\nfunction maybeSource(addon: AddonPackage, key: 'app-js' | 'fastboot-js'): Source | undefined {\n let maybeFiles = addon.meta[key];\n if (maybeFiles) {\n let files = maybeFiles;\n return {\n mayChange: addon.mayRebuild,\n walk() {\n return Object.entries(files).map(([externalName, internalName]) => {\n try {\n let stat = statSync(resolve(addon.root, internalName));\n return {\n relativePath: withoutMandatoryDotSlash(externalName, [\n 'in package.json at %s in key ember-addon.%s',\n addon.root,\n key,\n ]),\n mode: stat.mode,\n size: stat.size,\n mtime: stat.mtime,\n isDirectory() {\n return false;\n },\n };\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new Error(\n `${addon.name}/package.json lists ${internalName} in ember-addon.${key}, but that file does not exist`\n );\n }\n throw err;\n }\n });\n },\n isRelocated: true,\n locate(relativePath: string) {\n let internal = files['./' + relativePath];\n if (!internal) {\n throw new Error(`bug: couldn't find ${relativePath} in ${JSON.stringify(files)}`);\n }\n return resolve(addon.root, internal);\n },\n };\n }\n}\n\nfunction withoutMandatoryDotSlash(filename: string, debugInfo: any[]): string {\n if (!filename.startsWith('./')) {\n throw new Error(`${format(debugInfo)}: ${filename} is required to start with \"./\"`);\n }\n return filename.slice(2);\n}\n"]}
|
package/src/app.d.ts
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
import { Package, AddonPackage } from '@embroider/shared-internals';
|
2
|
-
import { OutputPaths } from './wait-for-trees';
|
3
|
-
import { Asset } from './asset';
|
4
|
-
import Options from './options';
|
5
|
-
import { MacrosConfig } from '@embroider/macros/src/node';
|
6
|
-
import { PluginItem, TransformOptions } from '@babel/core';
|
7
|
-
import { Options as ResolverConfig } from './module-resolver';
|
8
|
-
import { Engine } from './app-files';
|
9
|
-
import type { Transform } from 'babel-plugin-ember-template-compilation';
|
10
|
-
export type EmberENV = unknown;
|
11
|
-
export interface AppAdapter<TreeNames, SpecificResolverConfig extends ResolverConfig = ResolverConfig> {
|
12
|
-
readonly allActiveAddons: AddonPackage[];
|
13
|
-
activeAddonChildren(pkg: Package): AddonPackage[];
|
14
|
-
appJSSrcDir(treePaths: OutputPaths<TreeNames>): string;
|
15
|
-
fastbootJSSrcDir(treePaths: OutputPaths<TreeNames>): string | undefined;
|
16
|
-
assets(treePaths: OutputPaths<TreeNames>): Asset[];
|
17
|
-
autoRun(): boolean;
|
18
|
-
appBoot(): string | undefined;
|
19
|
-
mainModule(): string;
|
20
|
-
mainModuleConfig(): unknown;
|
21
|
-
modulePrefix(): string;
|
22
|
-
podModulePrefix(): string | undefined;
|
23
|
-
rootURL(): string;
|
24
|
-
templateCompilerPath(): string;
|
25
|
-
hbsTransforms(resolverConfig: SpecificResolverConfig): Transform[];
|
26
|
-
jsPlugins(resolverConfig: SpecificResolverConfig): PluginItem[];
|
27
|
-
resolverConfig(engines: Engine[]): SpecificResolverConfig;
|
28
|
-
resolvableExtensions(): string[];
|
29
|
-
htmlbarsPlugins(): Transform[];
|
30
|
-
babelConfig(): TransformOptions;
|
31
|
-
babelMajorVersion(): 7;
|
32
|
-
emberENV(): EmberENV;
|
33
|
-
strictV2Format(): boolean;
|
34
|
-
developingAddons(): string[];
|
35
|
-
env: string;
|
36
|
-
}
|
37
|
-
export declare function excludeDotFiles(files: string[]): string[];
|
38
|
-
export declare const CACHE_BUSTING_PLUGIN: {
|
39
|
-
path: string;
|
40
|
-
version: any;
|
41
|
-
};
|
42
|
-
export declare function addCachablePlugin(babelConfig: TransformOptions): void;
|
43
|
-
export declare class AppBuilder<TreeNames> {
|
44
|
-
private root;
|
45
|
-
private app;
|
46
|
-
private adapter;
|
47
|
-
private options;
|
48
|
-
private macrosConfig;
|
49
|
-
private assets;
|
50
|
-
constructor(root: string, app: Package, adapter: AppAdapter<TreeNames>, options: Required<Options>, macrosConfig: MacrosConfig);
|
51
|
-
private scriptPriority;
|
52
|
-
private get resolvableExtensionsPattern();
|
53
|
-
private impliedAssets;
|
54
|
-
private impliedAddonAssets;
|
55
|
-
private babelParserConfig;
|
56
|
-
private babelConfig;
|
57
|
-
private insertEmberApp;
|
58
|
-
private implicitScriptsAsset;
|
59
|
-
private implicitStylesAsset;
|
60
|
-
private implicitTestScriptsAsset;
|
61
|
-
private implicitTestStylesAsset;
|
62
|
-
private findActiveAddons;
|
63
|
-
private partitionEngines;
|
64
|
-
private get activeFastboot();
|
65
|
-
private get fastbootConfig();
|
66
|
-
private appDiffers;
|
67
|
-
private updateAppJS;
|
68
|
-
private prepareAsset;
|
69
|
-
private prepareAssets;
|
70
|
-
private assetIsValid;
|
71
|
-
private updateOnDiskAsset;
|
72
|
-
private updateInMemoryAsset;
|
73
|
-
private updateBuiltEmberAsset;
|
74
|
-
private updateConcatenatedAsset;
|
75
|
-
private updateAssets;
|
76
|
-
private gatherAssets;
|
77
|
-
build(inputPaths: OutputPaths<TreeNames>): Promise<void>;
|
78
|
-
private combinePackageJSON;
|
79
|
-
private etcOptions;
|
80
|
-
private get portableHints();
|
81
|
-
private addBabelConfig;
|
82
|
-
private addResolverConfig;
|
83
|
-
private shouldSplitRoute;
|
84
|
-
private splitRoute;
|
85
|
-
private topAppJSAsset;
|
86
|
-
private get staticAppPathsPattern();
|
87
|
-
private requiredOtherFiles;
|
88
|
-
private appJSAsset;
|
89
|
-
private get modulePrefix();
|
90
|
-
private importPaths;
|
91
|
-
private routeEntrypoint;
|
92
|
-
private testJSEntrypoint;
|
93
|
-
private gatherImplicitModules;
|
94
|
-
}
|