@embroider/core 3.4.20-unstable.e6197c7 → 3.4.20-unstable.e73d3a7
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 +4 -4
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -2
- package/src/index.js.map +1 -1
- package/src/module-request.d.ts +1 -0
- package/src/module-request.js +9 -0
- package/src/module-request.js.map +1 -1
- package/src/module-resolver.d.ts +9 -3
- package/src/module-resolver.js +134 -78
- package/src/module-resolver.js.map +1 -1
- package/src/node-resolve.d.ts +6 -1
- package/src/node-resolve.js +27 -9
- package/src/node-resolve.js.map +1 -1
- package/src/packager.d.ts +0 -8
- package/src/packager.js +0 -9
- package/src/packager.js.map +1 -1
- package/src/virtual-content.d.ts +26 -31
- package/src/virtual-content.js +42 -105
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +4 -6
- package/src/virtual-entrypoint.js +2 -56
- package/src/virtual-entrypoint.js.map +1 -1
- package/src/virtual-route-entrypoint.d.ts +4 -10
- package/src/virtual-route-entrypoint.js +1 -39
- package/src/virtual-route-entrypoint.js.map +1 -1
- package/src/virtual-test-support-styles.d.ts +5 -2
- package/src/virtual-test-support-styles.js +2 -5
- package/src/virtual-test-support-styles.js.map +1 -1
- package/src/virtual-test-support.d.ts +5 -2
- package/src/virtual-test-support.js +2 -5
- package/src/virtual-test-support.js.map +1 -1
- package/src/virtual-vendor-styles.d.ts +5 -1
- package/src/virtual-vendor-styles.js +2 -1
- package/src/virtual-vendor-styles.js.map +1 -1
- package/src/virtual-vendor.d.ts +5 -2
- package/src/virtual-vendor.js +4 -8
- package/src/virtual-vendor.js.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@embroider/core",
|
3
|
-
"version": "3.4.20-unstable.
|
3
|
+
"version": "3.4.20-unstable.e73d3a7",
|
4
4
|
"private": false,
|
5
5
|
"description": "A build system for EmberJS applications.",
|
6
6
|
"repository": {
|
@@ -49,9 +49,9 @@
|
|
49
49
|
"semver": "^7.3.5",
|
50
50
|
"typescript-memoize": "^1.0.1",
|
51
51
|
"walk-sync": "^3.0.0",
|
52
|
-
"@embroider/macros": "1.16.10-unstable.
|
53
|
-
"@embroider/reverse-exports": "0.1.1-unstable.
|
54
|
-
"@embroider/shared-internals": "2.8.2-unstable.
|
52
|
+
"@embroider/macros": "1.16.10-unstable.e73d3a7",
|
53
|
+
"@embroider/reverse-exports": "0.1.1-unstable.e73d3a7",
|
54
|
+
"@embroider/shared-internals": "2.8.2-unstable.e73d3a7"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
57
|
"@glimmer/syntax": "^0.84.2",
|
package/src/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { Packager, PackagerConstructor, Variant, applyVariantToBabelConfig,
|
1
|
+
export { Packager, PackagerConstructor, Variant, applyVariantToBabelConfig, getPackagerCacheDir } from './packager';
|
2
2
|
export { HTMLEntrypoint, BundleSummary } from './html-entrypoint';
|
3
3
|
export { default as Stage } from './stage';
|
4
4
|
export { default as Options, optionsWithDefaults } from './options';
|
package/src/index.js
CHANGED
@@ -17,10 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.virtualContent = exports.ResolverLoader = exports.ModuleRequest = exports.Resolver = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.jsHandlebarsCompile = exports.WaitForTrees = exports.optionsWithDefaults = exports.HTMLEntrypoint = exports.getPackagerCacheDir = exports.
|
20
|
+
exports.virtualContent = exports.ResolverLoader = exports.ModuleRequest = exports.Resolver = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.jsHandlebarsCompile = exports.WaitForTrees = exports.optionsWithDefaults = exports.HTMLEntrypoint = exports.getPackagerCacheDir = exports.applyVariantToBabelConfig = void 0;
|
21
21
|
var packager_1 = require("./packager");
|
22
22
|
Object.defineProperty(exports, "applyVariantToBabelConfig", { enumerable: true, get: function () { return packager_1.applyVariantToBabelConfig; } });
|
23
|
-
Object.defineProperty(exports, "getAppMeta", { enumerable: true, get: function () { return packager_1.getAppMeta; } });
|
24
23
|
Object.defineProperty(exports, "getPackagerCacheDir", { enumerable: true, get: function () { return packager_1.getPackagerCacheDir; } });
|
25
24
|
var html_entrypoint_1 = require("./html-entrypoint");
|
26
25
|
Object.defineProperty(exports, "HTMLEntrypoint", { enumerable: true, get: function () { return html_entrypoint_1.HTMLEntrypoint; } });
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uCAAoH;AAAnE,qHAAA,yBAAyB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAC/F,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAEvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,mDAAwE;AAA/D,+HAAA,OAAO,OAAgB;AAChC,iDAAiE;AAAxD,oHAAA,OAAO,OAAuB;AACvC,uCAA4F;AAAnF,gGAAA,IAAI,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,iGAAA,KAAK,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA;AACvE,qDAA6C;AAApC,2GAAA,QAAQ,OAAA;AACjB,mDAAkH;AAAzG,+GAAA,aAAa,OAAA;AAEtB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAyE;AAAhE,iHAAA,cAAc,OAAA;AAGvB,8EAA8E;AAC9E,+DAA+D;AAC/D,8DAA4C","sourcesContent":["export { Packager, PackagerConstructor, Variant, applyVariantToBabelConfig, getPackagerCacheDir } from './packager';\nexport { HTMLEntrypoint, BundleSummary } from './html-entrypoint';\nexport { default as Stage } from './stage';\nexport { default as Options, optionsWithDefaults } from './options';\nexport { default as WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport { Resolver } from './module-resolver';\nexport { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';\nexport type { Options as ResolverOptions } from './module-resolver-options';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent, type VirtualResponse } from './virtual-content';\nexport type { Engine } from './app-files';\n\n// this is reexported because we already make users manage a peerDep from some\n// other packages (like embroider/webpack and @embroider/compat\nexport * from '@embroider/shared-internals';\n"]}
|
package/src/module-request.d.ts
CHANGED
package/src/module-request.js
CHANGED
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
13
13
|
var _ModuleRequest_adapter, _ModuleRequest_specifier, _ModuleRequest_fromFile, _ModuleRequest_meta, _ModuleRequest_resolvedTo;
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.ModuleRequest = void 0;
|
16
|
+
exports.extractResolution = extractResolution;
|
16
17
|
class ModuleRequest {
|
17
18
|
static create(createAdapter, params) {
|
18
19
|
let result = createAdapter(params);
|
@@ -88,4 +89,12 @@ class ModuleRequest {
|
|
88
89
|
}
|
89
90
|
exports.ModuleRequest = ModuleRequest;
|
90
91
|
_ModuleRequest_adapter = new WeakMap(), _ModuleRequest_specifier = new WeakMap(), _ModuleRequest_fromFile = new WeakMap(), _ModuleRequest_meta = new WeakMap(), _ModuleRequest_resolvedTo = new WeakMap();
|
92
|
+
async function extractResolution(res) {
|
93
|
+
if (typeof res === 'function') {
|
94
|
+
return await res();
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
return res;
|
98
|
+
}
|
99
|
+
}
|
91
100
|
//# sourceMappingURL=module-request.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"module-request.js","sourceRoot":"","sources":["module-request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"module-request.js","sourceRoot":"","sources":["module-request.ts"],"names":[],"mappings":"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","sourcesContent":["import type { VirtualResponse } from './virtual-content';\n\n// This is generic because different build systems have different ways of\n// representing a found module, and we just pass those values through.\nexport type Resolution<T = unknown, E = unknown> =\n | { type: 'found'; filename: string; virtual: VirtualResponse | false; result: T }\n\n // the important thing about this Resolution is that embroider should do its\n // fallback behaviors here.\n | { type: 'not_found'; err: E };\n\nexport type RequestAdapterCreate<Init, Res extends Resolution> = (\n params: Init\n) => { initialState: InitialRequestState; adapter: RequestAdapter<Res> } | undefined;\n\nexport interface RequestAdapter<Res extends Resolution> {\n readonly debugType: string;\n resolve(request: ModuleRequest<Res>): Promise<Res>;\n\n // the function-returning variants of both of these are only because webpack\n // plugins are a pain in the butt. Integrators are encouraged to use the plain\n // Response-returning variants in all sane build environments.\n notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);\n virtualResponse(request: ModuleRequest<Res>, response: VirtualResponse): Res | (() => Promise<Res>);\n}\n\nexport interface InitialRequestState {\n readonly specifier: string;\n readonly fromFile: string;\n readonly meta: Record<string, unknown> | undefined;\n}\n\nexport class ModuleRequest<Res extends Resolution = Resolution> implements ModuleRequest<Res> {\n static create<Init, Res extends Resolution>(\n createAdapter: RequestAdapterCreate<Init, Res>,\n params: Init\n ): ModuleRequest<Res> | undefined {\n let result = createAdapter(params);\n if (result) {\n return new ModuleRequest(result.adapter, result.initialState);\n }\n }\n\n #adapter: RequestAdapter<Res>;\n #specifier: string;\n #fromFile: string;\n #meta: Record<string, unknown> | undefined;\n #resolvedTo: Res | (() => Promise<Res>) | undefined;\n\n private constructor(adapter: RequestAdapter<Res>, initialize: InitialRequestState) {\n this.#adapter = adapter;\n this.#specifier = initialize.specifier;\n this.#fromFile = initialize.fromFile;\n this.#meta = initialize.meta;\n }\n\n get specifier(): string {\n return this.#specifier;\n }\n\n get fromFile(): string {\n return this.#fromFile;\n }\n\n get debugType(): string {\n return this.#adapter.debugType;\n }\n\n get meta(): Record<string, unknown> | undefined {\n return this.#meta;\n }\n\n get resolvedTo(): Res | (() => Promise<Res>) | undefined {\n return this.#resolvedTo;\n }\n\n alias(newSpecifier: string): this {\n if (this.#specifier === newSpecifier) {\n return this;\n }\n let result = this.clone();\n result.#specifier = newSpecifier;\n return result;\n }\n\n rehome(newFromFile: string): this {\n if (this.#fromFile === newFromFile) {\n return this;\n }\n let result = this.clone();\n result.#fromFile = newFromFile;\n return result;\n }\n\n virtualize(virtualResponse: VirtualResponse): this {\n return this.resolveTo(this.#adapter.virtualResponse(this, virtualResponse));\n }\n\n withMeta(meta: Record<string, any> | undefined): this {\n let result = this.clone();\n result.#meta = meta;\n result.#resolvedTo = this.#resolvedTo;\n return result;\n }\n\n notFound(): this {\n return this.resolveTo(this.#adapter.notFoundResponse(this));\n }\n\n resolveTo(res: Res | (() => Promise<Res>)): this {\n let result = this.clone();\n result.#resolvedTo = res;\n return result;\n }\n\n defaultResolve(): Promise<Res> {\n return this.#adapter.resolve(this);\n }\n\n clone(): this {\n return new ModuleRequest(this.#adapter, this) as this;\n }\n}\n\nexport async function extractResolution<Res extends Resolution = Resolution>(\n res: Res | (() => Promise<Res>)\n): Promise<Res> {\n if (typeof res === 'function') {\n return await res();\n } else {\n return res;\n }\n}\n"]}
|
package/src/module-resolver.d.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
import type { Package } from '@embroider/shared-internals';
|
2
2
|
import { RewrittenPackageCache } from '@embroider/shared-internals';
|
3
|
+
import { type NodeResolveOpts } from './node-resolve';
|
3
4
|
import type { Options, EngineConfig } from './module-resolver-options';
|
4
|
-
import type
|
5
|
+
import { type ModuleRequest, type Resolution } from './module-request';
|
5
6
|
export declare class Resolver {
|
6
7
|
readonly options: Options;
|
7
8
|
constructor(options: Options);
|
8
9
|
private beforeResolve;
|
9
10
|
resolve<ResolveResolution extends Resolution>(request: ModuleRequest<ResolveResolution>): Promise<ResolveResolution>;
|
10
|
-
nodeResolve(specifier: string, fromFile: string): Promise<{
|
11
|
+
nodeResolve(specifier: string, fromFile: string, opts?: NodeResolveOpts): Promise<{
|
11
12
|
type: 'virtual';
|
12
13
|
filename: string;
|
13
14
|
content: string;
|
@@ -19,6 +20,8 @@ export declare class Resolver {
|
|
19
20
|
err: Error;
|
20
21
|
}>;
|
21
22
|
get packageCache(): RewrittenPackageCache;
|
23
|
+
private afterResolve;
|
24
|
+
private handleSyntheticComponents;
|
22
25
|
private logicalPackage;
|
23
26
|
private generateFastbootSwitch;
|
24
27
|
private handleFastbootSwitch;
|
@@ -55,7 +58,10 @@ export declare class Resolver {
|
|
55
58
|
private getEntryFromMergeMap;
|
56
59
|
private withResolvableExtensions;
|
57
60
|
private searchAppTree;
|
58
|
-
|
61
|
+
reverseSearchAppTree(owningPackage: Package, fromFile: string): {
|
62
|
+
owningEngine: EngineConfig;
|
63
|
+
inAppName: string;
|
64
|
+
} | undefined;
|
59
65
|
reverseComponentLookup(filename: string): string | undefined;
|
60
66
|
private tryReverseComponent;
|
61
67
|
}
|
package/src/module-resolver.js
CHANGED
@@ -17,14 +17,12 @@ const debug_1 = __importDefault(require("debug"));
|
|
17
17
|
const assert_never_1 = __importDefault(require("assert-never"));
|
18
18
|
const reverse_exports_1 = require("@embroider/reverse-exports");
|
19
19
|
const resolve_exports_1 = require("resolve.exports");
|
20
|
-
const virtual_content_1 = require("./virtual-content");
|
21
20
|
const typescript_memoize_1 = require("typescript-memoize");
|
22
21
|
const describe_exports_1 = require("./describe-exports");
|
23
22
|
const fs_1 = require("fs");
|
24
23
|
const node_resolve_1 = require("./node-resolve");
|
25
|
-
const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
|
26
24
|
const semver_1 = require("semver");
|
27
|
-
const
|
25
|
+
const module_request_1 = require("./module-request");
|
28
26
|
const debug = (0, debug_1.default)('embroider:resolver');
|
29
27
|
// Using a formatter makes this work lazy so nothing happens when we aren't
|
30
28
|
// logging. It is unfortunate that formatters are a globally mutable config and
|
@@ -96,16 +94,12 @@ class Resolver {
|
|
96
94
|
request = await this.beforeResolve(request);
|
97
95
|
let resolution;
|
98
96
|
if (request.resolvedTo) {
|
99
|
-
|
100
|
-
resolution = await request.resolvedTo();
|
101
|
-
}
|
102
|
-
else {
|
103
|
-
resolution = request.resolvedTo;
|
104
|
-
}
|
97
|
+
resolution = await (0, module_request_1.extractResolution)(request.resolvedTo);
|
105
98
|
}
|
106
99
|
else {
|
107
100
|
resolution = await request.defaultResolve();
|
108
101
|
}
|
102
|
+
resolution = await this.afterResolve(request, resolution);
|
109
103
|
switch (resolution.type) {
|
110
104
|
case 'found':
|
111
105
|
return resolution;
|
@@ -121,12 +115,7 @@ class Resolver {
|
|
121
115
|
return resolution;
|
122
116
|
}
|
123
117
|
if (nextRequest.resolvedTo) {
|
124
|
-
|
125
|
-
return await nextRequest.resolvedTo();
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
return nextRequest.resolvedTo;
|
129
|
-
}
|
118
|
+
return await (0, module_request_1.extractResolution)(nextRequest.resolvedTo);
|
130
119
|
}
|
131
120
|
if (nextRequest.fromFile === request.fromFile && nextRequest.specifier === request.specifier) {
|
132
121
|
throw new Error('Bug Discovered! New request is not === original request but has the same fromFile and specifier. This will likely create a loop.');
|
@@ -136,12 +125,40 @@ class Resolver {
|
|
136
125
|
// Use standard NodeJS resolving, with our required compatibility rules on
|
137
126
|
// top. This is a convenience method for calling resolveSync with the
|
138
127
|
// defaultResolve already configured to be "do the normal node thing".
|
139
|
-
async nodeResolve(specifier, fromFile) {
|
140
|
-
return (0, node_resolve_1.nodeResolve)(this, specifier, fromFile);
|
128
|
+
async nodeResolve(specifier, fromFile, opts) {
|
129
|
+
return (0, node_resolve_1.nodeResolve)(this, specifier, fromFile, opts);
|
141
130
|
}
|
142
131
|
get packageCache() {
|
143
132
|
return shared_internals_2.RewrittenPackageCache.shared('embroider', this.options.appRoot);
|
144
133
|
}
|
134
|
+
async afterResolve(request, resolution) {
|
135
|
+
resolution = await this.handleSyntheticComponents(request, resolution);
|
136
|
+
return resolution;
|
137
|
+
}
|
138
|
+
async handleSyntheticComponents(request, resolution) {
|
139
|
+
// Key assumption: the system's defaultResolve performs extension search for
|
140
|
+
// extensionless requests, with JS at a higher priority than HBS.
|
141
|
+
// When the request had an explicit ".js" extension, the system default
|
142
|
+
// extension search doesn't help us locate an HBS, so we need to check for
|
143
|
+
// it ourselves here.
|
144
|
+
if (resolution.type === 'not_found') {
|
145
|
+
let hbsSpecifier = (0, shared_internals_1.syntheticJStoHBS)(request.specifier);
|
146
|
+
if (hbsSpecifier) {
|
147
|
+
resolution = await this.resolve(request.alias(hbsSpecifier));
|
148
|
+
}
|
149
|
+
}
|
150
|
+
// At this point, we might have resolved an HBS file (either because the
|
151
|
+
// request was extensionless and the default search found it, or because of
|
152
|
+
// our own code above) when the request was for a JS file.
|
153
|
+
if (resolution.type === 'found') {
|
154
|
+
let syntheticId = (0, shared_internals_1.needsSyntheticComponentJS)(request.specifier, resolution.filename);
|
155
|
+
if (syntheticId && (0, shared_internals_1.isInComponents)(resolution.filename, this.packageCache)) {
|
156
|
+
let newRequest = logTransition(`synthetic component JS`, request, request.virtualize({ type: 'template-only-component-js', specifier: syntheticId }));
|
157
|
+
return await (0, module_request_1.extractResolution)(newRequest.resolvedTo);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return resolution;
|
161
|
+
}
|
145
162
|
logicalPackage(owningPackage, file) {
|
146
163
|
let logicalLocation = this.reverseSearchAppTree(owningPackage, file);
|
147
164
|
if (logicalLocation) {
|
@@ -177,12 +194,12 @@ class Resolver {
|
|
177
194
|
let { names } = (0, describe_exports_1.describeExports)((0, fs_1.readFileSync)((0, path_1.resolve)(pkg.root, fastbootFile.shadowedFilename), 'utf8'), {
|
178
195
|
configFile: false,
|
179
196
|
});
|
180
|
-
let switchFile =
|
181
|
-
if (switchFile === request.fromFile) {
|
197
|
+
let switchFile = fastbootSwitch(candidate, (0, path_1.resolve)(pkg.root, 'package.json'), names);
|
198
|
+
if (switchFile.specifier === request.fromFile) {
|
182
199
|
return logTransition('internal lookup from fastbootSwitch', request);
|
183
200
|
}
|
184
201
|
else {
|
185
|
-
return logTransition('shadowed app fastboot', request, request.virtualize(
|
202
|
+
return logTransition('shadowed app fastboot', request, request.virtualize(switchFile));
|
186
203
|
}
|
187
204
|
}
|
188
205
|
else {
|
@@ -198,7 +215,7 @@ class Resolver {
|
|
198
215
|
if (request.resolvedTo) {
|
199
216
|
return request;
|
200
217
|
}
|
201
|
-
let match =
|
218
|
+
let match = decodeFastbootSwitch(request.fromFile);
|
202
219
|
if (!match) {
|
203
220
|
return request;
|
204
221
|
}
|
@@ -245,57 +262,88 @@ class Resolver {
|
|
245
262
|
if (request.resolvedTo) {
|
246
263
|
return request;
|
247
264
|
}
|
248
|
-
let
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
let
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
265
|
+
for (let variant of ['', 'test-']) {
|
266
|
+
let suffix = `-embroider-implicit-${variant}modules.js`;
|
267
|
+
if (!request.specifier.endsWith(suffix)) {
|
268
|
+
continue;
|
269
|
+
}
|
270
|
+
let filename = request.specifier.slice(0, -1 * suffix.length);
|
271
|
+
if (!filename.endsWith('/') && filename.endsWith('\\')) {
|
272
|
+
continue;
|
273
|
+
}
|
274
|
+
filename = filename.slice(0, -1);
|
275
|
+
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
276
|
+
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
277
|
+
throw new Error(`bug: found implicit modules import in non-ember package at ${request.fromFile}`);
|
278
|
+
}
|
279
|
+
let type = `implicit-${variant}modules`;
|
280
|
+
let packageName = (0, shared_internals_1.packageName)(filename);
|
281
|
+
if (packageName) {
|
282
|
+
let dep = this.packageCache.resolve(packageName, pkg);
|
283
|
+
return logTransition(`dep's implicit modules`, request, request.virtualize({ type, specifier: (0, path_1.resolve)(dep.root, `-embroider-${type}.js`), fromFile: dep.root }));
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
return logTransition(`own implicit modules`, request, request.virtualize({ type, specifier: (0, path_1.resolve)(pkg.root, `-embroider-${type}.js`), fromFile: pkg.root }));
|
287
|
+
}
|
263
288
|
}
|
289
|
+
return request;
|
264
290
|
}
|
265
291
|
handleEntrypoint(request) {
|
292
|
+
var _a;
|
266
293
|
if (request.resolvedTo) {
|
267
294
|
return request;
|
268
295
|
}
|
269
|
-
|
270
|
-
|
271
|
-
|
296
|
+
const compatModulesSpecifier = '@embroider/virtual/compat-modules';
|
297
|
+
let isCompatModules = request.specifier === compatModulesSpecifier || request.specifier.startsWith(compatModulesSpecifier + '/');
|
298
|
+
if (!isCompatModules) {
|
299
|
+
return request;
|
300
|
+
}
|
301
|
+
const requestingPkg = this.packageCache.ownerOfFile(request.fromFile);
|
302
|
+
if (!(requestingPkg === null || requestingPkg === void 0 ? void 0 : requestingPkg.isV2Ember())) {
|
303
|
+
throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
|
304
|
+
}
|
305
|
+
let pkg;
|
306
|
+
if (request.specifier === compatModulesSpecifier) {
|
307
|
+
pkg = requestingPkg;
|
272
308
|
}
|
273
309
|
else {
|
274
|
-
|
310
|
+
let packageName = request.specifier.slice(compatModulesSpecifier.length + 1);
|
311
|
+
pkg = this.packageCache.resolve(packageName, requestingPkg);
|
275
312
|
}
|
313
|
+
let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-entrypoint.js', {
|
314
|
+
browser: true,
|
315
|
+
conditions: ['default', 'imports'],
|
316
|
+
});
|
317
|
+
let specifier = (0, path_1.resolve)(pkg.root, (_a = matched === null || matched === void 0 ? void 0 : matched[0]) !== null && _a !== void 0 ? _a : '-embroider-entrypoint.js');
|
318
|
+
return logTransition('entrypoint', request, request.virtualize({
|
319
|
+
type: 'entrypoint',
|
320
|
+
specifier,
|
321
|
+
fromDir: (0, path_1.dirname)(specifier),
|
322
|
+
}));
|
276
323
|
}
|
277
324
|
handleRouteEntrypoint(request) {
|
278
325
|
if (request.resolvedTo) {
|
279
326
|
return request;
|
280
327
|
}
|
281
|
-
|
282
|
-
if (!
|
328
|
+
const publicPrefix = '@embroider/core/route/';
|
329
|
+
if (!request.specifier.startsWith(publicPrefix)) {
|
283
330
|
return request;
|
284
331
|
}
|
332
|
+
let routeName = request.specifier.slice(publicPrefix.length);
|
285
333
|
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
286
334
|
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
287
335
|
throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
|
288
336
|
}
|
289
|
-
|
337
|
+
let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-route-entrypoint.js', {
|
338
|
+
browser: true,
|
339
|
+
conditions: ['default', 'imports'],
|
340
|
+
});
|
341
|
+
let target = matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`;
|
342
|
+
let specifier = (0, path_1.resolve)(pkg.root, target);
|
343
|
+
return logTransition('route entrypoint', request, request.virtualize({ type: 'route-entrypoint', specifier, route: routeName, fromDir: (0, path_1.dirname)(specifier) }));
|
290
344
|
}
|
291
345
|
handleImplicitTestScripts(request) {
|
292
|
-
|
293
|
-
const candidates = [
|
294
|
-
'@embroider/virtual/test-support.js',
|
295
|
-
'/@embroider/virtual/test-support.js',
|
296
|
-
'./@embroider/virtual/test-support.js',
|
297
|
-
];
|
298
|
-
if (!candidates.includes(request.specifier)) {
|
346
|
+
if (request.specifier !== '@embroider/virtual/test-support.js') {
|
299
347
|
return request;
|
300
348
|
}
|
301
349
|
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
@@ -305,13 +353,7 @@ class Resolver {
|
|
305
353
|
return logTransition('test-support', request, request.virtualize({ type: 'test-support-js', specifier: (0, path_1.resolve)(pkg.root, '-embroider-test-support.js') }));
|
306
354
|
}
|
307
355
|
handleTestSupportStyles(request) {
|
308
|
-
|
309
|
-
const candidates = [
|
310
|
-
'@embroider/virtual/test-support.css',
|
311
|
-
'/@embroider/virtual/test-support.css',
|
312
|
-
'./@embroider/virtual/test-support.css',
|
313
|
-
];
|
314
|
-
if (!candidates.includes(request.specifier)) {
|
356
|
+
if (request.specifier !== '@embroider/virtual/test-support.css') {
|
315
357
|
return request;
|
316
358
|
}
|
317
359
|
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
@@ -351,13 +393,7 @@ class Resolver {
|
|
351
393
|
}
|
352
394
|
}
|
353
395
|
handleVendorStyles(request) {
|
354
|
-
|
355
|
-
const candidates = [
|
356
|
-
'@embroider/virtual/vendor.css',
|
357
|
-
'/@embroider/virtual/vendor.css',
|
358
|
-
'./@embroider/virtual/vendor.css',
|
359
|
-
];
|
360
|
-
if (!candidates.includes(request.specifier)) {
|
396
|
+
if (request.specifier !== '@embroider/virtual/vendor.css') {
|
361
397
|
return request;
|
362
398
|
}
|
363
399
|
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
@@ -371,6 +407,7 @@ class Resolver {
|
|
371
407
|
return logTransition('resolveHelper', request, request.alias(`${target.packageName}/helpers/${target.memberName}`).rehome((0, path_1.resolve)(inEngine.root, 'package.json')));
|
372
408
|
}
|
373
409
|
async resolveComponent(path, inEngine, request) {
|
410
|
+
var _a, _b;
|
374
411
|
let target = this.parseGlobalPath(path, inEngine);
|
375
412
|
let hbsModule = null;
|
376
413
|
let jsModule = null;
|
@@ -401,7 +438,10 @@ class Resolver {
|
|
401
438
|
}
|
402
439
|
return logTransition(`resolveComponent found legacy HBS`, request, request.virtualize({
|
403
440
|
type: 'component-pair',
|
404
|
-
|
441
|
+
hbsModule: hbsModule.filename,
|
442
|
+
jsModule: (_a = jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename) !== null && _a !== void 0 ? _a : null,
|
443
|
+
debugName: (0, path_1.basename)(hbsModule.filename).replace(/\.(js|hbs)$/, ''),
|
444
|
+
specifier: `${this.options.appRoot}/embroider-pair-component/${encodeURIComponent(hbsModule.filename)}/__vpc__/${encodeURIComponent((_b = jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename) !== null && _b !== void 0 ? _b : '')}`,
|
405
445
|
}));
|
406
446
|
}
|
407
447
|
else if (jsModule) {
|
@@ -648,6 +688,7 @@ class Resolver {
|
|
648
688
|
return request;
|
649
689
|
}
|
650
690
|
handleRenaming(request) {
|
691
|
+
var _a;
|
651
692
|
if (request.resolvedTo) {
|
652
693
|
return request;
|
653
694
|
}
|
@@ -683,7 +724,7 @@ class Resolver {
|
|
683
724
|
}
|
684
725
|
if (pkg.name === packageName) {
|
685
726
|
// we found a self-import
|
686
|
-
if (pkg.meta['auto-upgraded']) {
|
727
|
+
if ((_a = pkg.meta) === null || _a === void 0 ? void 0 : _a['auto-upgraded']) {
|
687
728
|
// auto-upgraded packages always get automatically adjusted. They never
|
688
729
|
// supported fancy package.json exports features so this direct mapping
|
689
730
|
// to the root is always right.
|
@@ -720,13 +761,7 @@ class Resolver {
|
|
720
761
|
return request;
|
721
762
|
}
|
722
763
|
handleVendor(request) {
|
723
|
-
|
724
|
-
const candidates = [
|
725
|
-
'@embroider/virtual/vendor.js',
|
726
|
-
'/@embroider/virtual/vendor.js',
|
727
|
-
'./@embroider/virtual/vendor.js',
|
728
|
-
];
|
729
|
-
if (!candidates.includes(request.specifier)) {
|
764
|
+
if (request.specifier !== '@embroider/virtual/vendor.js') {
|
730
765
|
return request;
|
731
766
|
}
|
732
767
|
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
@@ -750,6 +785,7 @@ class Resolver {
|
|
750
785
|
return newRequest.withMeta({ originalFromFile });
|
751
786
|
}
|
752
787
|
preHandleExternal(request) {
|
788
|
+
var _a;
|
753
789
|
if (request.resolvedTo) {
|
754
790
|
return request;
|
755
791
|
}
|
@@ -790,7 +826,7 @@ class Resolver {
|
|
790
826
|
// package to which it belongs (normally the app) that affects some policy
|
791
827
|
// choices about what it can import
|
792
828
|
let logicalPackage = this.logicalPackage(pkg, fromFile);
|
793
|
-
if (logicalPackage.meta['auto-upgraded'] && !logicalPackage.hasDependency('ember-auto-import')) {
|
829
|
+
if (((_a = logicalPackage.meta) === null || _a === void 0 ? void 0 : _a['auto-upgraded']) && !logicalPackage.hasDependency('ember-auto-import')) {
|
794
830
|
try {
|
795
831
|
let dep = this.packageCache.resolve(packageName, logicalPackage);
|
796
832
|
if (!dep.isEmberAddon()) {
|
@@ -994,10 +1030,7 @@ class Resolver {
|
|
994
1030
|
throw new Error(`${matched.entry['app-js'].fromPackageName} declared ${inEngineSpecifier} in packageJSON.ember-addon.app-js, but that module does not exist`);
|
995
1031
|
}
|
996
1032
|
let { names } = (0, describe_exports_1.describeExports)((0, fs_1.readFileSync)(foundAppJS.filename, 'utf8'), { configFile: false });
|
997
|
-
return request.virtualize(
|
998
|
-
type: 'fastboot-switch',
|
999
|
-
specifier: (0, virtual_content_1.fastbootSwitch)(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names),
|
1000
|
-
});
|
1033
|
+
return request.virtualize(fastbootSwitch(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names));
|
1001
1034
|
}
|
1002
1035
|
}
|
1003
1036
|
// check whether the given file with the given owningPackage is an addon's
|
@@ -1088,4 +1121,27 @@ function engineRelativeName(pkg, filename) {
|
|
1088
1121
|
return '.' + outsideName.slice(pkg.name.length);
|
1089
1122
|
}
|
1090
1123
|
}
|
1124
|
+
const fastbootSwitchSuffix = '/embroider_fastboot_switch';
|
1125
|
+
function fastbootSwitch(specifier, fromFile, names) {
|
1126
|
+
let filename = `${(0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier)}${fastbootSwitchSuffix}`;
|
1127
|
+
let virtualSpecifier;
|
1128
|
+
if (names.size > 0) {
|
1129
|
+
virtualSpecifier = `${filename}?names=${[...names].join(',')}`;
|
1130
|
+
}
|
1131
|
+
else {
|
1132
|
+
virtualSpecifier = filename;
|
1133
|
+
}
|
1134
|
+
return {
|
1135
|
+
type: 'fastboot-switch',
|
1136
|
+
specifier: virtualSpecifier,
|
1137
|
+
names,
|
1138
|
+
hasDefaultExport: 'x',
|
1139
|
+
};
|
1140
|
+
}
|
1141
|
+
function decodeFastbootSwitch(filename) {
|
1142
|
+
let index = filename.indexOf(fastbootSwitchSuffix);
|
1143
|
+
if (index >= 0) {
|
1144
|
+
return { filename: filename.slice(0, index) };
|
1145
|
+
}
|
1146
|
+
}
|
1091
1147
|
//# sourceMappingURL=module-resolver.js.map
|