@embroider/core 3.4.20-unstable.b89b741 → 3.4.20-unstable.c3af848

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.
Files changed (37) hide show
  1. package/package.json +6 -6
  2. package/src/index.d.ts +2 -2
  3. package/src/index.js +1 -2
  4. package/src/index.js.map +1 -1
  5. package/src/module-request.d.ts +5 -6
  6. package/src/module-request.js +11 -2
  7. package/src/module-request.js.map +1 -1
  8. package/src/module-resolver.d.ts +3 -1
  9. package/src/module-resolver.js +130 -108
  10. package/src/module-resolver.js.map +1 -1
  11. package/src/node-resolve.d.ts +2 -1
  12. package/src/node-resolve.js +6 -8
  13. package/src/node-resolve.js.map +1 -1
  14. package/src/packager.d.ts +0 -8
  15. package/src/packager.js +0 -9
  16. package/src/packager.js.map +1 -1
  17. package/src/virtual-content.d.ts +28 -10
  18. package/src/virtual-content.js +45 -114
  19. package/src/virtual-content.js.map +1 -1
  20. package/src/virtual-entrypoint.d.ts +4 -2
  21. package/src/virtual-entrypoint.js +2 -18
  22. package/src/virtual-entrypoint.js.map +1 -1
  23. package/src/virtual-route-entrypoint.d.ts +4 -9
  24. package/src/virtual-route-entrypoint.js +1 -33
  25. package/src/virtual-route-entrypoint.js.map +1 -1
  26. package/src/virtual-test-support-styles.d.ts +5 -2
  27. package/src/virtual-test-support-styles.js +2 -5
  28. package/src/virtual-test-support-styles.js.map +1 -1
  29. package/src/virtual-test-support.d.ts +5 -2
  30. package/src/virtual-test-support.js +2 -5
  31. package/src/virtual-test-support.js.map +1 -1
  32. package/src/virtual-vendor-styles.d.ts +5 -1
  33. package/src/virtual-vendor-styles.js +2 -1
  34. package/src/virtual-vendor-styles.js.map +1 -1
  35. package/src/virtual-vendor.d.ts +5 -2
  36. package/src/virtual-vendor.js +4 -8
  37. package/src/virtual-vendor.js.map +1 -1
@@ -17,13 +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");
25
+ const module_request_1 = require("./module-request");
27
26
  const debug = (0, debug_1.default)('embroider:resolver');
28
27
  // Using a formatter makes this work lazy so nothing happens when we aren't
29
28
  // logging. It is unfortunate that formatters are a globally mutable config and
@@ -95,19 +94,14 @@ class Resolver {
95
94
  request = await this.beforeResolve(request);
96
95
  let resolution;
97
96
  if (request.resolvedTo) {
98
- if (typeof request.resolvedTo === 'function') {
99
- resolution = await request.resolvedTo();
100
- }
101
- else {
102
- resolution = request.resolvedTo;
103
- }
97
+ resolution = await (0, module_request_1.extractResolution)(request.resolvedTo);
104
98
  }
105
99
  else {
106
100
  resolution = await request.defaultResolve();
107
101
  }
102
+ resolution = await this.afterResolve(request, resolution);
108
103
  switch (resolution.type) {
109
104
  case 'found':
110
- case 'ignored':
111
105
  return resolution;
112
106
  case 'not_found':
113
107
  break;
@@ -121,12 +115,7 @@ class Resolver {
121
115
  return resolution;
122
116
  }
123
117
  if (nextRequest.resolvedTo) {
124
- if (typeof nextRequest.resolvedTo === 'function') {
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.');
@@ -142,6 +131,34 @@ class Resolver {
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,8 +194,8 @@ 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 = (0, virtual_content_1.fastbootSwitch)(candidate, (0, path_1.resolve)(pkg.root, 'package.json'), names);
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 {
@@ -198,7 +215,7 @@ class Resolver {
198
215
  if (request.resolvedTo) {
199
216
  return request;
200
217
  }
201
- let match = (0, virtual_content_1.decodeFastbootSwitch)(request.fromFile);
218
+ let match = decodeFastbootSwitch(request.fromFile);
202
219
  if (!match) {
203
220
  return request;
204
221
  }
@@ -245,68 +262,74 @@ class Resolver {
245
262
  if (request.resolvedTo) {
246
263
  return request;
247
264
  }
248
- let im = (0, virtual_content_1.decodeImplicitModules)(request.specifier);
249
- if (!im) {
250
- return request;
251
- }
252
- let pkg = this.packageCache.ownerOfFile(request.fromFile);
253
- if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
254
- throw new Error(`bug: found implicit modules import in non-ember package at ${request.fromFile}`);
255
- }
256
- let packageName = (0, shared_internals_1.packageName)(im.fromFile);
257
- if (packageName) {
258
- let dep = this.packageCache.resolve(packageName, pkg);
259
- return logTransition(`dep's implicit modules`, request, request.virtualize((0, path_1.resolve)(dep.root, `-embroider-${im.type}.js`)));
260
- }
261
- else {
262
- return logTransition(`own implicit modules`, request, request.virtualize((0, path_1.resolve)(pkg.root, `-embroider-${im.type}.js`)));
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) {
266
292
  var _a;
267
293
  if (request.resolvedTo) {
268
294
  return request;
269
295
  }
270
- //TODO move the extra forwardslash handling out into the vite plugin
271
- const candidates = [
272
- '@embroider/virtual/compat-modules',
273
- '/@embroider/virtual/compat-modules',
274
- './@embroider/virtual/compat-modules',
275
- ];
276
- if (!candidates.some(c => request.specifier.startsWith(c + '/') || request.specifier === c)) {
296
+ const compatModulesSpecifier = '@embroider/virtual/compat-modules';
297
+ let isCompatModules = request.specifier === compatModulesSpecifier || request.specifier.startsWith(compatModulesSpecifier + '/');
298
+ if (!isCompatModules) {
277
299
  return request;
278
300
  }
279
- const result = /\.?\/?@embroider\/virtual\/compat-modules(?:\/(?<packageName>.*))?/.exec(request.specifier);
280
- if (!result) {
281
- // TODO make a better error
282
- throw new Error('entrypoint does not match pattern' + request.specifier);
283
- }
284
- const { packageName } = result.groups;
285
301
  const requestingPkg = this.packageCache.ownerOfFile(request.fromFile);
286
302
  if (!(requestingPkg === null || requestingPkg === void 0 ? void 0 : requestingPkg.isV2Ember())) {
287
303
  throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
288
304
  }
289
305
  let pkg;
290
- if (packageName) {
291
- pkg = this.packageCache.resolve(packageName, requestingPkg);
306
+ if (request.specifier === compatModulesSpecifier) {
307
+ pkg = requestingPkg;
292
308
  }
293
309
  else {
294
- pkg = requestingPkg;
310
+ let packageName = request.specifier.slice(compatModulesSpecifier.length + 1);
311
+ pkg = this.packageCache.resolve(packageName, requestingPkg);
295
312
  }
296
313
  let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-entrypoint.js', {
297
314
  browser: true,
298
315
  conditions: ['default', 'imports'],
299
316
  });
300
- return logTransition('entrypoint', request, request.virtualize((0, path_1.resolve)(pkg.root, (_a = matched === null || matched === void 0 ? void 0 : matched[0]) !== null && _a !== void 0 ? _a : '-embroider-entrypoint.js')));
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
+ }));
301
323
  }
302
324
  handleRouteEntrypoint(request) {
303
325
  if (request.resolvedTo) {
304
326
  return request;
305
327
  }
306
- let routeName = (0, virtual_route_entrypoint_1.decodePublicRouteEntrypoint)(request.specifier);
307
- if (!routeName) {
328
+ const publicPrefix = '@embroider/core/route/';
329
+ if (!request.specifier.startsWith(publicPrefix)) {
308
330
  return request;
309
331
  }
332
+ let routeName = request.specifier.slice(publicPrefix.length);
310
333
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
311
334
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
312
335
  throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
@@ -315,39 +338,32 @@ class Resolver {
315
338
  browser: true,
316
339
  conditions: ['default', 'imports'],
317
340
  });
318
- return logTransition('route entrypoint', request, request.virtualize((0, virtual_route_entrypoint_1.encodeRouteEntrypoint)(pkg.root, matched === null || matched === void 0 ? void 0 : matched[0], routeName)));
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) }));
319
344
  }
320
345
  handleImplicitTestScripts(request) {
321
- //TODO move the extra forwardslash handling out into the vite plugin
322
- const candidates = [
323
- '@embroider/virtual/test-support.js',
324
- '/@embroider/virtual/test-support.js',
325
- './@embroider/virtual/test-support.js',
326
- ];
327
- if (!candidates.includes(request.specifier)) {
346
+ if (request.specifier !== '@embroider/virtual/test-support.js') {
328
347
  return request;
329
348
  }
330
349
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
331
350
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
332
351
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/test-support.js. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
333
352
  }
334
- return logTransition('test-support', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-test-support.js')));
353
+ return logTransition('test-support', request, request.virtualize({ type: 'test-support-js', specifier: (0, path_1.resolve)(pkg.root, '-embroider-test-support.js') }));
335
354
  }
336
355
  handleTestSupportStyles(request) {
337
- //TODO move the extra forwardslash handling out into the vite plugin
338
- const candidates = [
339
- '@embroider/virtual/test-support.css',
340
- '/@embroider/virtual/test-support.css',
341
- './@embroider/virtual/test-support.css',
342
- ];
343
- if (!candidates.includes(request.specifier)) {
356
+ if (request.specifier !== '@embroider/virtual/test-support.css') {
344
357
  return request;
345
358
  }
346
359
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
347
360
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
348
361
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/test-support.css. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
349
362
  }
350
- return logTransition('test-support-styles', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-test-support-styles.css')));
363
+ return logTransition('test-support-styles', request, request.virtualize({
364
+ type: 'test-support-css',
365
+ specifier: (0, path_1.resolve)(pkg.root, '-embroider-test-support-styles.css'),
366
+ }));
351
367
  }
352
368
  async handleGlobalsCompat(request) {
353
369
  if (request.resolvedTo) {
@@ -377,35 +393,28 @@ class Resolver {
377
393
  }
378
394
  }
379
395
  handleVendorStyles(request) {
380
- //TODO move the extra forwardslash handling out into the vite plugin
381
- const candidates = [
382
- '@embroider/virtual/vendor.css',
383
- '/@embroider/virtual/vendor.css',
384
- './@embroider/virtual/vendor.css',
385
- ];
386
- if (!candidates.includes(request.specifier)) {
396
+ if (request.specifier !== '@embroider/virtual/vendor.css') {
387
397
  return request;
388
398
  }
389
399
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
390
400
  if (!pkg || !this.options.engines.some(e => e.root === (pkg === null || pkg === void 0 ? void 0 : pkg.root))) {
391
401
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app or Engine. The top-level Ember app is the only one that has support for @embroider/virtual/vendor.css. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
392
402
  }
393
- return logTransition('vendor-styles', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-vendor-styles.css')));
403
+ return logTransition('vendor-styles', request, request.virtualize({ type: 'vendor-css', specifier: (0, path_1.resolve)(pkg.root, '-embroider-vendor-styles.css') }));
394
404
  }
395
405
  resolveHelper(path, inEngine, request) {
396
406
  let target = this.parseGlobalPath(path, inEngine);
397
407
  return logTransition('resolveHelper', request, request.alias(`${target.packageName}/helpers/${target.memberName}`).rehome((0, path_1.resolve)(inEngine.root, 'package.json')));
398
408
  }
399
409
  async resolveComponent(path, inEngine, request) {
410
+ var _a, _b;
400
411
  let target = this.parseGlobalPath(path, inEngine);
401
412
  let hbsModule = null;
402
413
  let jsModule = null;
403
414
  // first, the various places our template might be.
404
415
  for (let candidate of this.componentTemplateCandidates(target.packageName)) {
405
416
  let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`;
406
- let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from).withMeta({
407
- runtimeFallback: false,
408
- }));
417
+ let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from));
409
418
  if (resolution.type === 'found') {
410
419
  hbsModule = resolution;
411
420
  break;
@@ -414,12 +423,7 @@ class Resolver {
414
423
  // then the various places our javascript might be.
415
424
  for (let candidate of this.componentJSCandidates(target.packageName)) {
416
425
  let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`;
417
- let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from).withMeta({
418
- runtimeFallback: false,
419
- }));
420
- if (resolution.type === 'ignored') {
421
- return logTransition(`resolving to ignored component`, request, request.resolveTo(resolution));
422
- }
426
+ let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from));
423
427
  // .hbs is a resolvable extension for us, so we need to exclude it here.
424
428
  // It matches as a priority lower than .js, so finding an .hbs means
425
429
  // there's definitely not a .js.
@@ -432,7 +436,13 @@ class Resolver {
432
436
  if (!this.emberVersionSupportsSeparateTemplates) {
433
437
  throw new Error(`Components with separately resolved templates were removed at Ember 6.0. Migrate to either co-located js/ts + hbs files or to gjs/gts. https://deprecations.emberjs.com/id/component-template-resolving/. Bad template was: ${hbsModule.filename}.`);
434
438
  }
435
- return logTransition(`resolveComponent found legacy HBS`, request, request.virtualize((0, virtual_content_1.virtualPairComponent)(hbsModule.filename, jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename)));
439
+ return logTransition(`resolveComponent found legacy HBS`, request, request.virtualize({
440
+ type: 'component-pair',
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 : '')}`,
445
+ }));
436
446
  }
437
447
  else if (jsModule) {
438
448
  return logTransition(`resolving to resolveComponent found only JS`, request, request.resolveTo(jsModule));
@@ -446,13 +456,8 @@ class Resolver {
446
456
  // component, so here to resolve the ambiguity we need to actually resolve
447
457
  // that candidate to see if it works.
448
458
  let helperCandidate = this.resolveHelper(path, inEngine, request);
449
- let helperMatch = await this.resolve(request.alias(helperCandidate.specifier).rehome(helperCandidate.fromFile).withMeta({
450
- runtimeFallback: false,
451
- }));
452
- // for the case of 'ignored' that means that esbuild found this helper in an external
453
- // package so it should be considered found in this case and we should not look for a
454
- // component with this name
455
- if (helperMatch.type === 'found' || helperMatch.type === 'ignored') {
459
+ let helperMatch = await this.resolve(request.alias(helperCandidate.specifier).rehome(helperCandidate.fromFile));
460
+ if (helperMatch.type === 'found') {
456
461
  return logTransition('resolve to ambiguous case matched a helper', request, request.resolveTo(helperMatch));
457
462
  }
458
463
  // unlike resolveHelper, resolveComponent already does pre-resolution in
@@ -683,6 +688,7 @@ class Resolver {
683
688
  return request;
684
689
  }
685
690
  handleRenaming(request) {
691
+ var _a;
686
692
  if (request.resolvedTo) {
687
693
  return request;
688
694
  }
@@ -718,7 +724,7 @@ class Resolver {
718
724
  }
719
725
  if (pkg.name === packageName) {
720
726
  // we found a self-import
721
- if (pkg.meta['auto-upgraded']) {
727
+ if ((_a = pkg.meta) === null || _a === void 0 ? void 0 : _a['auto-upgraded']) {
722
728
  // auto-upgraded packages always get automatically adjusted. They never
723
729
  // supported fancy package.json exports features so this direct mapping
724
730
  // to the root is always right.
@@ -755,20 +761,14 @@ class Resolver {
755
761
  return request;
756
762
  }
757
763
  handleVendor(request) {
758
- //TODO move the extra forwardslash handling out into the vite plugin
759
- const candidates = [
760
- '@embroider/virtual/vendor.js',
761
- '/@embroider/virtual/vendor.js',
762
- './@embroider/virtual/vendor.js',
763
- ];
764
- if (!candidates.includes(request.specifier)) {
764
+ if (request.specifier !== '@embroider/virtual/vendor.js') {
765
765
  return request;
766
766
  }
767
767
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
768
768
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
769
769
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/vendor.js. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
770
770
  }
771
- return logTransition('vendor', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-vendor.js')));
771
+ return logTransition('vendor', request, request.virtualize({ type: 'vendor-js', specifier: (0, path_1.resolve)(pkg.root, '-embroider-vendor.js') }));
772
772
  }
773
773
  resolveWithinMovedPackage(request, pkg) {
774
774
  let levels = ['..'];
@@ -785,6 +785,7 @@ class Resolver {
785
785
  return newRequest.withMeta({ originalFromFile });
786
786
  }
787
787
  preHandleExternal(request) {
788
+ var _a;
788
789
  if (request.resolvedTo) {
789
790
  return request;
790
791
  }
@@ -825,7 +826,7 @@ class Resolver {
825
826
  // package to which it belongs (normally the app) that affects some policy
826
827
  // choices about what it can import
827
828
  let logicalPackage = this.logicalPackage(pkg, fromFile);
828
- 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')) {
829
830
  try {
830
831
  let dep = this.packageCache.resolve(packageName, logicalPackage);
831
832
  if (!dep.isEmberAddon()) {
@@ -1024,14 +1025,12 @@ class Resolver {
1024
1025
  case 'fastboot-only':
1025
1026
  return request.alias(matched.entry['fastboot-js'].specifier).rehome(matched.entry['fastboot-js'].fromFile);
1026
1027
  case 'both':
1027
- let foundAppJS = await this.resolve(request.alias(matched.entry['app-js'].specifier).rehome(matched.entry['app-js'].fromFile).withMeta({
1028
- runtimeFallback: false,
1029
- }));
1028
+ let foundAppJS = await this.resolve(request.alias(matched.entry['app-js'].specifier).rehome(matched.entry['app-js'].fromFile));
1030
1029
  if (foundAppJS.type !== 'found') {
1031
1030
  throw new Error(`${matched.entry['app-js'].fromPackageName} declared ${inEngineSpecifier} in packageJSON.ember-addon.app-js, but that module does not exist`);
1032
1031
  }
1033
1032
  let { names } = (0, describe_exports_1.describeExports)((0, fs_1.readFileSync)(foundAppJS.filename, 'utf8'), { configFile: false });
1034
- return request.virtualize((0, virtual_content_1.fastbootSwitch)(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names));
1033
+ return request.virtualize(fastbootSwitch(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names));
1035
1034
  }
1036
1035
  }
1037
1036
  // check whether the given file with the given owningPackage is an addon's
@@ -1122,4 +1121,27 @@ function engineRelativeName(pkg, filename) {
1122
1121
  return '.' + outsideName.slice(pkg.name.length);
1123
1122
  }
1124
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
+ }
1125
1147
  //# sourceMappingURL=module-resolver.js.map