@embroider/core 3.4.15-unstable.5063729 → 3.4.15-unstable.99a3649

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/core",
3
- "version": "3.4.15-unstable.5063729",
3
+ "version": "3.4.15-unstable.99a3649",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "resolve.exports": "^2.0.2",
42
42
  "typescript-memoize": "^1.0.1",
43
43
  "walk-sync": "^3.0.0",
44
- "@embroider/macros": "1.16.6-unstable.5063729",
45
- "@embroider/reverse-exports": "0.1.1-unstable.5063729",
46
- "@embroider/shared-internals": "2.6.3-unstable.5063729"
44
+ "@embroider/macros": "1.16.6-unstable.99a3649",
45
+ "@embroider/reverse-exports": "0.1.1-unstable.99a3649",
46
+ "@embroider/shared-internals": "2.6.3-unstable.99a3649"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@glimmer/syntax": "^0.84.2",
@@ -61,8 +61,8 @@
61
61
  "fixturify": "^2.1.1",
62
62
  "tmp": "^0.1.0",
63
63
  "typescript": "^5.4.5",
64
- "@embroider/sample-transforms": "0.0.0",
65
- "@embroider/test-support": "0.36.0"
64
+ "@embroider/test-support": "0.36.0",
65
+ "@embroider/sample-transforms": "0.0.0"
66
66
  },
67
67
  "engines": {
68
68
  "node": "12.* || 14.* || >= 16"
@@ -7,7 +7,6 @@ export interface RouteFiles {
7
7
  }
8
8
  export declare class AppFiles {
9
9
  readonly engine: Engine;
10
- readonly tests: ReadonlyArray<string>;
11
10
  readonly components: ReadonlyArray<string>;
12
11
  readonly helpers: ReadonlyArray<string>;
13
12
  readonly modifiers: ReadonlyArray<string>;
package/src/app-files.js CHANGED
@@ -5,7 +5,6 @@ const path_1 = require("path");
5
5
  class AppFiles {
6
6
  constructor(engine, appFiles, fastbootFiles, resolvableExtensions, staticAppPathsPattern, podModulePrefix) {
7
7
  this.engine = engine;
8
- let tests = [];
9
8
  let components = [];
10
9
  let helpers = [];
11
10
  let modifiers = [];
@@ -50,7 +49,7 @@ class AppFiles {
50
49
  continue;
51
50
  }
52
51
  if (relativePath.startsWith('tests/')) {
53
- tests.push(relativePath);
52
+ // skip tests because they are dealt with separately
54
53
  continue;
55
54
  }
56
55
  if (relativePath.startsWith('components/')) {
@@ -100,7 +99,6 @@ class AppFiles {
100
99
  otherAppFiles.push(relativePath);
101
100
  }
102
101
  }
103
- this.tests = tests;
104
102
  this.components = components;
105
103
  this.helpers = helpers;
106
104
  this.modifiers = modifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAU3B,MAAa,QAAQ;IAUnB,YACW,MAAc,EACvB,QAAqB,EACrB,aAA0B,EAC1B,oBAA4B,EAC5B,qBAAyC,EACzC,eAAwB;QALf,WAAM,GAAN,MAAM,CAAQ;QAOvB,IAAI,KAAK,GAAa,EAAE,CAAC;QACzB,IAAI,UAAU,GAAa,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAa,EAAE,CAAC;QAC3B,IAAI,SAAS,GAAa,EAAE,CAAC;QAC7B,IAAI,aAAa,GAAa,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QAExC,IAAI,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;QACtC,IAAI,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;QACjD,IAAI,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;QAEhD,KAAK,IAAI,CAAC,IAAI,QAAQ,EAAE,CAAC;YACvB,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACrB,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QACD,KAAK,IAAI,CAA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UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,8DAA8D;QAC9D,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEjB,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,OAAO,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACN,IAAI,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;gBACvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACpC,MAAM,GAAG,QAAQ,CAAC;YACpB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAA2C,CAAC,GAAG,YAAY,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA/MD,4BA+MC","sourcesContent":["import { sep } from 'path';\nimport type { Package, AddonPackage } from '@embroider/shared-internals';\n\nexport interface RouteFiles {\n route?: string;\n template?: string;\n controller?: string;\n children: Map<string, RouteFiles>;\n}\n\nexport class AppFiles {\n readonly tests: ReadonlyArray<string>;\n readonly components: ReadonlyArray<string>;\n readonly helpers: ReadonlyArray<string>;\n readonly modifiers: ReadonlyArray<string>;\n private perRoute: RouteFiles;\n readonly otherAppFiles: ReadonlyArray<string>;\n readonly isFastbootOnly: Map<string, boolean>;\n readonly fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n\n constructor(\n readonly engine: Engine,\n appFiles: Set<string>,\n fastbootFiles: Set<string>,\n resolvableExtensions: RegExp,\n staticAppPathsPattern: RegExp | undefined,\n podModulePrefix?: string\n ) {\n let tests: string[] = [];\n let components: string[] = [];\n let helpers: string[] = [];\n let modifiers: string[] = [];\n let otherAppFiles: string[] = [];\n this.perRoute = { children: new Map() };\n\n let combinedFiles = new Set<string>();\n let combinedNonFastbootFiles = new Set<string>();\n let isFastbootOnly = new Map<string, boolean>();\n\n for (let f of appFiles) {\n combinedFiles.add(f);\n combinedNonFastbootFiles.add(f);\n }\n for (let f of fastbootFiles) {\n combinedFiles.add(f);\n }\n\n for (let addon of engine.addons.keys()) {\n let appJS = addon.meta['app-js'];\n if (appJS) {\n for (let filename of Object.keys(appJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n combinedNonFastbootFiles.add(filename);\n }\n }\n\n let fastbootJS = addon.meta['fastboot-js'];\n if (fastbootJS) {\n for (let filename of Object.keys(fastbootJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n }\n }\n }\n\n for (let relativePath of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(relativePath));\n relativePath = relativePath.split(sep).join('/');\n if (!resolvableExtensions.test(relativePath)) {\n continue;\n }\n\n if (/\\.d\\.ts$/.test(relativePath)) {\n // .d.ts files are technically \"*.ts\" files but aren't really and we\n // don't want to include them when we crawl through the app.\n continue;\n }\n\n if (relativePath.startsWith('tests/')) {\n tests.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('components/')) {\n // hbs files are not resolvable when they're used via co-location with\n // an associated js file because it's the js that is resolvable.\n // An hbs file is used via colocation when it's inside the components\n // directory, and also not named \"template.hbs\" (because that is an\n // older pattern used with pods-like layouts).\n let isHbs = relativePath.endsWith('.hbs');\n if (!isHbs || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\n } else if (isHbs) {\n // template-only components will be compiled as js files during the\n // build process, so we push a virtual path to js in the list of files\n // because the resolver will be able to recognize a template-only and\n // give a correct answer in the end.\n let jsPath = relativePath.replace(/\\.hbs$/, '.js');\n if (!combinedFiles.has(jsPath)) {\n components.push(jsPath);\n }\n }\n continue;\n }\n\n if (relativePath.startsWith('templates/components/')) {\n components.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('helpers/')) {\n helpers.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('modifiers/')) {\n modifiers.push(relativePath);\n continue;\n }\n\n if (\n (podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix)) ||\n this.handleClassicRouteFile(relativePath)\n ) {\n continue;\n }\n\n if (staticAppPathsPattern) {\n if (!staticAppPathsPattern.test(relativePath)) {\n otherAppFiles.push(relativePath);\n }\n } else {\n otherAppFiles.push(relativePath);\n }\n }\n this.tests = tests;\n this.components = components;\n this.helpers = helpers;\n this.modifiers = modifiers;\n this.otherAppFiles = otherAppFiles;\n this.isFastbootOnly = isFastbootOnly;\n\n // this deliberately only describes the app's fastboot files. Not the full\n // merge from all the addons. This is because they need different handling\n // in the module resolver -- addon fastboot files can always be a\n // fallbackResolve, because if the app happens to define the same name\n // (whether fastboot-specific or just browser) that wins over the addon.\n // Whereas if the app itself defines a fastbot-specific version of a file,\n // that must take precedence over the *normal* resolution, and must be\n // implemented in beforeResolve.\n this.fastbootFiles = Object.fromEntries(\n [...fastbootFiles].map(name => [\n `./${name}`,\n {\n localFilename: `./_fastboot_/${name}`,\n shadowedFilename: appFiles.has(name) ? `./${name}` : undefined,\n },\n ])\n );\n }\n\n private handleClassicRouteFile(relativePath: string): boolean {\n let [prefix, ...rest] = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n if (!['controllers', 'templates', 'routes'].includes(prefix)) {\n return false;\n }\n let type = prefix.slice(0, -1) as 'controller' | 'template' | 'route';\n let cursor = this.perRoute;\n for (let part of rest) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type] = relativePath;\n return true;\n }\n\n private handlePodsRouteFile(relativePath: string, podModulePrefix: string): boolean {\n let parts = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n let type = parts.pop();\n if (!type || !['controller', 'template', 'route'].includes(type)) {\n return false;\n }\n let podParts = podModulePrefix.split('/');\n // The first part of podModulePrefix is the app's package name\n podParts.shift();\n\n for (let podPart of podParts) {\n if (parts.shift() !== podPart) {\n return false;\n }\n }\n\n let cursor = this.perRoute;\n for (let part of parts) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type as 'controller' | 'template' | 'route'] = relativePath;\n return true;\n }\n\n get routeFiles(): Readonly<RouteFiles> {\n return this.perRoute;\n }\n}\n\nexport interface Engine {\n // the engine's own package\n package: Package;\n // the set of active addons in the engine. For each one we keep track of a file that can resolve the addon, because we'll need that later.\n addons: Map<AddonPackage, string>;\n // is this the top-level engine?\n isApp: boolean;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // TODO: remove this after we remove the stage2 entrypoint\n appRelativePath: string;\n}\n"]}
1
+ {"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAU3B,MAAa,QAAQ;IASnB,YACW,MAAc,EACvB,QAAqB,EACrB,aAA0B,EAC1B,oBAA4B,EAC5B,qBAAyC,EACzC,eAAwB;QALf,WAAM,GAAN,MAAM,CAAQ;QAOvB,IAAI,UAAU,GAAa,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAa,EAAE,CAAC;Q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AC;YACpB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAA2C,CAAC,GAAG,YAAY,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA5MD,4BA4MC","sourcesContent":["import { sep } from 'path';\nimport type { Package, AddonPackage } from '@embroider/shared-internals';\n\nexport interface RouteFiles {\n route?: string;\n template?: string;\n controller?: string;\n children: Map<string, RouteFiles>;\n}\n\nexport class AppFiles {\n readonly components: ReadonlyArray<string>;\n readonly helpers: ReadonlyArray<string>;\n readonly modifiers: ReadonlyArray<string>;\n private perRoute: RouteFiles;\n readonly otherAppFiles: ReadonlyArray<string>;\n readonly isFastbootOnly: Map<string, boolean>;\n readonly fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n\n constructor(\n readonly engine: Engine,\n appFiles: Set<string>,\n fastbootFiles: Set<string>,\n resolvableExtensions: RegExp,\n staticAppPathsPattern: RegExp | undefined,\n podModulePrefix?: string\n ) {\n let components: string[] = [];\n let helpers: string[] = [];\n let modifiers: string[] = [];\n let otherAppFiles: string[] = [];\n this.perRoute = { children: new Map() };\n\n let combinedFiles = new Set<string>();\n let combinedNonFastbootFiles = new Set<string>();\n let isFastbootOnly = new Map<string, boolean>();\n\n for (let f of appFiles) {\n combinedFiles.add(f);\n combinedNonFastbootFiles.add(f);\n }\n for (let f of fastbootFiles) {\n combinedFiles.add(f);\n }\n\n for (let addon of engine.addons.keys()) {\n let appJS = addon.meta['app-js'];\n if (appJS) {\n for (let filename of Object.keys(appJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n combinedNonFastbootFiles.add(filename);\n }\n }\n\n let fastbootJS = addon.meta['fastboot-js'];\n if (fastbootJS) {\n for (let filename of Object.keys(fastbootJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n }\n }\n }\n\n for (let relativePath of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(relativePath));\n relativePath = relativePath.split(sep).join('/');\n if (!resolvableExtensions.test(relativePath)) {\n continue;\n }\n\n if (/\\.d\\.ts$/.test(relativePath)) {\n // .d.ts files are technically \"*.ts\" files but aren't really and we\n // don't want to include them when we crawl through the app.\n continue;\n }\n\n if (relativePath.startsWith('tests/')) {\n // skip tests because they are dealt with separately\n continue;\n }\n\n if (relativePath.startsWith('components/')) {\n // hbs files are not resolvable when they're used via co-location with\n // an associated js file because it's the js that is resolvable.\n // An hbs file is used via colocation when it's inside the components\n // directory, and also not named \"template.hbs\" (because that is an\n // older pattern used with pods-like layouts).\n let isHbs = relativePath.endsWith('.hbs');\n if (!isHbs || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\n } else if (isHbs) {\n // template-only components will be compiled as js files during the\n // build process, so we push a virtual path to js in the list of files\n // because the resolver will be able to recognize a template-only and\n // give a correct answer in the end.\n let jsPath = relativePath.replace(/\\.hbs$/, '.js');\n if (!combinedFiles.has(jsPath)) {\n components.push(jsPath);\n }\n }\n continue;\n }\n\n if (relativePath.startsWith('templates/components/')) {\n components.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('helpers/')) {\n helpers.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('modifiers/')) {\n modifiers.push(relativePath);\n continue;\n }\n\n if (\n (podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix)) ||\n this.handleClassicRouteFile(relativePath)\n ) {\n continue;\n }\n\n if (staticAppPathsPattern) {\n if (!staticAppPathsPattern.test(relativePath)) {\n otherAppFiles.push(relativePath);\n }\n } else {\n otherAppFiles.push(relativePath);\n }\n }\n this.components = components;\n this.helpers = helpers;\n this.modifiers = modifiers;\n this.otherAppFiles = otherAppFiles;\n this.isFastbootOnly = isFastbootOnly;\n\n // this deliberately only describes the app's fastboot files. Not the full\n // merge from all the addons. This is because they need different handling\n // in the module resolver -- addon fastboot files can always be a\n // fallbackResolve, because if the app happens to define the same name\n // (whether fastboot-specific or just browser) that wins over the addon.\n // Whereas if the app itself defines a fastbot-specific version of a file,\n // that must take precedence over the *normal* resolution, and must be\n // implemented in beforeResolve.\n this.fastbootFiles = Object.fromEntries(\n [...fastbootFiles].map(name => [\n `./${name}`,\n {\n localFilename: `./_fastboot_/${name}`,\n shadowedFilename: appFiles.has(name) ? `./${name}` : undefined,\n },\n ])\n );\n }\n\n private handleClassicRouteFile(relativePath: string): boolean {\n let [prefix, ...rest] = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n if (!['controllers', 'templates', 'routes'].includes(prefix)) {\n return false;\n }\n let type = prefix.slice(0, -1) as 'controller' | 'template' | 'route';\n let cursor = this.perRoute;\n for (let part of rest) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type] = relativePath;\n return true;\n }\n\n private handlePodsRouteFile(relativePath: string, podModulePrefix: string): boolean {\n let parts = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n let type = parts.pop();\n if (!type || !['controller', 'template', 'route'].includes(type)) {\n return false;\n }\n let podParts = podModulePrefix.split('/');\n // The first part of podModulePrefix is the app's package name\n podParts.shift();\n\n for (let podPart of podParts) {\n if (parts.shift() !== podPart) {\n return false;\n }\n }\n\n let cursor = this.perRoute;\n for (let part of parts) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type as 'controller' | 'template' | 'route'] = relativePath;\n return true;\n }\n\n get routeFiles(): Readonly<RouteFiles> {\n return this.perRoute;\n }\n}\n\nexport interface Engine {\n // the engine's own package\n package: Package;\n // the set of active addons in the engine. For each one we keep track of a file that can resolve the addon, because we'll need that later.\n addons: Map<AddonPackage, string>;\n // is this the top-level engine?\n isApp: boolean;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // TODO: remove this after we remove the stage2 entrypoint\n appRelativePath: string;\n}\n"]}
@@ -84,7 +84,6 @@ export declare class Resolver {
84
84
  private handleFastbootSwitch;
85
85
  private handleImplicitModules;
86
86
  private handleEntrypoint;
87
- private handleTestEntrypoint;
88
87
  private handleRouteEntrypoint;
89
88
  private handleImplicitTestScripts;
90
89
  private handleTestSupportStyles;
@@ -15,7 +15,7 @@ const path_1 = require("path");
15
15
  const shared_internals_2 = require("@embroider/shared-internals");
16
16
  const debug_1 = __importDefault(require("debug"));
17
17
  const assert_never_1 = __importDefault(require("assert-never"));
18
- const reverse_exports_1 = __importDefault(require("@embroider/reverse-exports"));
18
+ const reverse_exports_1 = require("@embroider/reverse-exports");
19
19
  const resolve_exports_1 = require("resolve.exports");
20
20
  const virtual_content_1 = require("./virtual-content");
21
21
  const typescript_memoize_1 = require("typescript-memoize");
@@ -63,7 +63,7 @@ function logTransition(reason, before, after = before) {
63
63
  function isTerminal(request) {
64
64
  return request.isVirtual || request.isNotFound || Boolean(request.resolvedTo);
65
65
  }
66
- const compatPattern = /#embroider_compat\/(?<type>[^\/]+)\/(?<rest>.*)/;
66
+ const compatPattern = /@embroider\/virtual\/(?<type>[^\/]+)\/(?<rest>.*)/;
67
67
  class Resolver {
68
68
  constructor(options) {
69
69
  this.options = options;
@@ -86,7 +86,6 @@ class Resolver {
86
86
  request = this.handleVendorStyles(request);
87
87
  request = this.handleTestSupportStyles(request);
88
88
  request = this.handleEntrypoint(request);
89
- request = this.handleTestEntrypoint(request);
90
89
  request = this.handleRouteEntrypoint(request);
91
90
  request = this.handleRenaming(request);
92
91
  request = this.handleVendor(request);
@@ -267,6 +266,7 @@ class Resolver {
267
266
  }
268
267
  }
269
268
  handleEntrypoint(request) {
269
+ var _a;
270
270
  if (isTerminal(request)) {
271
271
  return request;
272
272
  }
@@ -292,26 +292,11 @@ class Resolver {
292
292
  else {
293
293
  pkg = requestingPkg;
294
294
  }
295
- return logTransition('entrypoint', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-entrypoint.js')));
296
- }
297
- handleTestEntrypoint(request) {
298
- if (isTerminal(request)) {
299
- return request;
300
- }
301
- //TODO move the extra forwardslash handling out into the vite plugin
302
- const candidates = [
303
- '@embroider/core/test-entrypoint',
304
- '/@embroider/core/test-entrypoint',
305
- './@embroider/core/test-entrypoint',
306
- ];
307
- if (!candidates.some(c => request.specifier === c)) {
308
- return request;
309
- }
310
- const pkg = this.packageCache.ownerOfFile(request.fromFile);
311
- if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember()) || !pkg.isV2App()) {
312
- throw new Error(`bug: found test entrypoint import from somewhere other than the top-level app engine: ${request.fromFile}`);
313
- }
314
- return logTransition('test-entrypoint', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-test-entrypoint.js')));
295
+ let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-entrypoint.js', {
296
+ browser: true,
297
+ conditions: ['default', 'imports'],
298
+ });
299
+ 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')));
315
300
  }
316
301
  handleRouteEntrypoint(request) {
317
302
  if (isTerminal(request)) {
@@ -325,7 +310,11 @@ class Resolver {
325
310
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
326
311
  throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
327
312
  }
328
- return logTransition('route entrypoint', request, request.virtualize((0, virtual_route_entrypoint_1.encodeRouteEntrypoint)(pkg.root, routeName)));
313
+ let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-route-entrypoint.js', {
314
+ browser: true,
315
+ conditions: ['default', 'imports'],
316
+ });
317
+ 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)));
329
318
  }
330
319
  handleImplicitTestScripts(request) {
331
320
  //TODO move the extra forwardslash handling out into the vite plugin
@@ -383,7 +372,7 @@ class Resolver {
383
372
  case 'ambiguous':
384
373
  return this.resolveHelperOrComponent(rest, engine, request);
385
374
  default:
386
- throw new Error(`bug: unexepected #embroider_compat specifier: ${request.specifier}`);
375
+ throw new Error(`bug: unexepected @embroider/virtual specifier: ${request.specifier}`);
387
376
  }
388
377
  }
389
378
  handleVendorStyles(request) {
@@ -423,6 +412,9 @@ class Resolver {
423
412
  let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from).withMeta({
424
413
  runtimeFallback: false,
425
414
  }));
415
+ if (resolution.type === 'ignored') {
416
+ return logTransition(`resolving to ignored component`, request, request.resolveTo(resolution));
417
+ }
426
418
  // .hbs is a resolvable extension for us, so we need to exclude it here.
427
419
  // It matches as a priority lower than .js, so finding an .hbs means
428
420
  // there's definitely not a .js.
@@ -449,7 +441,10 @@ class Resolver {
449
441
  let helperMatch = await this.resolve(request.alias(helperCandidate.specifier).rehome(helperCandidate.fromFile).withMeta({
450
442
  runtimeFallback: false,
451
443
  }));
452
- if (helperMatch.type === 'found') {
444
+ // for the case of 'ignored' that means that esbuild found this helper in an external
445
+ // package so it should be considered found in this case and we should not look for a
446
+ // component with this name
447
+ if (helperMatch.type === 'found' || helperMatch.type === 'ignored') {
453
448
  return logTransition('resolve to ambiguous case matched a helper', request, request.resolveTo(helperMatch));
454
449
  }
455
450
  // unlike resolveHelper, resolveComponent already does pre-resolution in
@@ -528,13 +523,17 @@ class Resolver {
528
523
  if (!inAddonName.startsWith('./')) {
529
524
  throw new Error(`addon ${addon.name} declares app-js in its package.json with the illegal name "${inAddonName}". It must start with "./" to make it clear that it's relative to the addon`);
530
525
  }
526
+ let specifier = (0, reverse_exports_1.externalName)(addon.packageJSON, inAddonName);
527
+ if (!specifier) {
528
+ throw new Error(`${addon.name}'s package.json app-js refers to ${inAddonName}, but that module is not accessible from outside the package`);
529
+ }
531
530
  let prevEntry = engineModules.get(inEngineName);
532
531
  switch (prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.type) {
533
532
  case undefined:
534
533
  engineModules.set(inEngineName, {
535
534
  type: 'app-only',
536
535
  'app-js': {
537
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
536
+ specifier,
538
537
  fromFile: addonConfig.canResolveFromFile,
539
538
  fromPackageName: addon.name,
540
539
  },
@@ -548,7 +547,7 @@ class Resolver {
548
547
  engineModules.set(inEngineName, {
549
548
  type: 'both',
550
549
  'app-js': {
551
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
550
+ specifier,
552
551
  fromFile: addonConfig.canResolveFromFile,
553
552
  fromPackageName: addon.name,
554
553
  },
@@ -567,13 +566,17 @@ class Resolver {
567
566
  if (!inAddonName.startsWith('./')) {
568
567
  throw new Error(`addon ${addon.name} declares fastboot-js in its package.json with the illegal name "${inAddonName}". It must start with "./" to make it clear that it's relative to the addon`);
569
568
  }
569
+ let specifier = (0, reverse_exports_1.externalName)(addon.packageJSON, inAddonName);
570
+ if (!specifier) {
571
+ throw new Error(`${addon.name}'s package.json fastboot-js refers to ${inAddonName}, but that module is not accessible from outside the package`);
572
+ }
570
573
  let prevEntry = engineModules.get(inEngineName);
571
574
  switch (prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.type) {
572
575
  case undefined:
573
576
  engineModules.set(inEngineName, {
574
577
  type: 'fastboot-only',
575
578
  'fastboot-js': {
576
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
579
+ specifier,
577
580
  fromFile: addonConfig.canResolveFromFile,
578
581
  fromPackageName: addon.name,
579
582
  },
@@ -587,7 +590,7 @@ class Resolver {
587
590
  engineModules.set(inEngineName, {
588
591
  type: 'both',
589
592
  'fastboot-js': {
590
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
593
+ specifier,
591
594
  fromFile: addonConfig.canResolveFromFile,
592
595
  fromPackageName: addon.name,
593
596
  },
@@ -678,6 +681,9 @@ class Resolver {
678
681
  // ember-source might provide backburner via module renaming, but if you
679
682
  // have an explicit dependency on backburner you should still get that real
680
683
  // copy.
684
+ // if (pkg.root === this.options.engines[0].root && request.specifier === `${pkg.name}/environment/config`) {
685
+ // return logTransition('legacy config location', request, request.alias(`${pkg.name}/app/environment/config`));
686
+ // }
681
687
  if (!pkg.hasDependency(packageName)) {
682
688
  for (let [candidate, replacement] of Object.entries(this.options.renameModules)) {
683
689
  if (candidate === request.specifier) {
@@ -702,26 +708,33 @@ class Resolver {
702
708
  // auto-upgraded packages always get automatically adjusted. They never
703
709
  // supported fancy package.json exports features so this direct mapping
704
710
  // to the root is always right.
705
- // "my-package/foo" -> "./foo"
706
- // "my-package" -> "./" (this can't be just "." because node's require.resolve doesn't reliable support that)
707
- let selfImportPath = request.specifier === pkg.name ? './' : request.specifier.replace(pkg.name, '.');
708
- return logTransition(`v1 self-import`, request, request.alias(selfImportPath).rehome((0, path_1.resolve)(pkg.root, 'package.json')));
711
+ // "my-app/foo" -> "./foo" from app's package.json
712
+ // "my-addon/foo" -> "my-addon/foo" from a package that's guaranteed to be able to resolve my-addon
713
+ let owningEngine = this.owningEngine(pkg);
714
+ let addonConfig = owningEngine.activeAddons.find(a => a.root === pkg.root);
715
+ if (addonConfig) {
716
+ // auto-upgraded addons get special support for self-resolving here.
717
+ return logTransition(`v1 addon self-import`, request, request.rehome(addonConfig.canResolveFromFile));
718
+ }
719
+ else {
720
+ // auto-upgraded apps will necessarily have packageJSON.exports
721
+ // because we insert them, so for that support we can fall through to
722
+ // that support below.
723
+ }
709
724
  }
710
- else {
711
- // v2 packages are supposed to use package.json `exports` to enable
712
- // self-imports, but not all build tools actually follow the spec. This
713
- // is a workaround for badly behaved packagers.
714
- //
715
- // Known upstream bugs this works around:
716
- // - https://github.com/vitejs/vite/issues/9731
717
- if (pkg.packageJSON.exports) {
718
- let found = (0, resolve_exports_1.exports)(pkg.packageJSON, request.specifier, {
719
- browser: true,
720
- conditions: ['default', 'imports'],
721
- });
722
- if (found === null || found === void 0 ? void 0 : found[0]) {
723
- return logTransition(`v2 self-import with package.json exports`, request, request.alias(found === null || found === void 0 ? void 0 : found[0]).rehome((0, path_1.resolve)(pkg.root, 'package.json')));
724
- }
725
+ // v2 packages are supposed to use package.json `exports` to enable
726
+ // self-imports, but not all build tools actually follow the spec. This
727
+ // is a workaround for badly behaved packagers.
728
+ //
729
+ // Known upstream bugs this works around:
730
+ // - https://github.com/vitejs/vite/issues/9731
731
+ if (pkg.packageJSON.exports) {
732
+ let found = (0, resolve_exports_1.exports)(pkg.packageJSON, request.specifier, {
733
+ browser: true,
734
+ conditions: ['default', 'imports'],
735
+ });
736
+ if (found === null || found === void 0 ? void 0 : found[0]) {
737
+ return logTransition(`v2 self-import with package.json exports`, request, request.alias(found === null || found === void 0 ? void 0 : found[0]).rehome((0, path_1.resolve)(pkg.root, 'package.json')));
725
738
  }
726
739
  }
727
740
  }
@@ -784,18 +797,10 @@ class Resolver {
784
797
  }
785
798
  // if the requesting file is in an addon's app-js, the relative request
786
799
  // should really be understood as a request for a module in the containing
787
- // engine
800
+ // engine.
788
801
  let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
789
802
  if (logicalLocation) {
790
- return logTransition('beforeResolve: relative import in app-js', request, request
791
- .alias('./' + path_1.posix.join((0, path_1.dirname)(logicalLocation.inAppName), request.specifier))
792
- // it's important that we're rehoming this to the root of the engine
793
- // (which we know really exists), and not to a subdir like
794
- // logicalLocation.inAppName (which might not physically exist),
795
- // because some environments (including node's require.resolve) will
796
- // refuse to do resolution from a notional path that doesn't
797
- // physically exist.
798
- .rehome((0, path_1.resolve)(logicalLocation.owningEngine.root, 'package.json')));
803
+ return logTransition('beforeResolve: relative import in app-js', request, request.alias(path_1.posix.join(logicalLocation.owningEngine.packageName, (0, path_1.dirname)(logicalLocation.inAppName), request.specifier)));
799
804
  }
800
805
  return request;
801
806
  }
@@ -836,12 +841,10 @@ class Resolver {
836
841
  }
837
842
  }
838
843
  // assertions on what native v2 addons can import
839
- if (!pkg.meta['auto-upgraded']) {
840
- if (!pkg.meta['auto-upgraded'] &&
841
- !appImportInAppTree(pkg, logicalPackage, packageName) &&
842
- !reliablyResolvable(pkg, packageName)) {
843
- throw new Error(`${pkg.name} is trying to import from ${packageName} but that is not one of its explicit dependencies`);
844
- }
844
+ if (!pkg.needsLooseResolving() &&
845
+ !appImportInAppTree(pkg, logicalPackage, packageName) &&
846
+ !reliablyResolvable(pkg, packageName)) {
847
+ throw new Error(`${pkg.name} is trying to import from ${packageName} but that is not one of its explicit dependencies`);
845
848
  }
846
849
  return request;
847
850
  }
@@ -872,7 +875,7 @@ class Resolver {
872
875
  entry = ['require', ['default', 'has']];
873
876
  }
874
877
  if (!entry) {
875
- throw new Error(`A module tried to resolve "${request.specifier}" and didn't find it (${label}).
878
+ throw new Error(`[${request.debugType}] A module tried to resolve "${request.specifier}" and didn't find it (${label}).
876
879
 
877
880
  - Maybe a dependency declaration is missing?
878
881
  - Remember that v1 addons can only import non-Ember-addon NPM dependencies if they include ember-auto-import in their dependencies.
@@ -907,14 +910,14 @@ class Resolver {
907
910
  }
908
911
  if (compatPattern.test(request.specifier)) {
909
912
  // Some kinds of compat requests get rewritten into other things
910
- // deterministically. For example, "#embroider_compat/helpers/whatever"
913
+ // deterministically. For example, "@embroider/virtual/helpers/whatever"
911
914
  // means only "the-current-engine/helpers/whatever", and if that doesn't
912
915
  // actually exist it's that path that will show up as a missing import.
913
916
  //
914
917
  // But others have an ambiguous meaning. For example,
915
- // #embroider_compat/components/whatever can mean several different
918
+ // @embroider/virtual/components/whatever can mean several different
916
919
  // things. If we're unable to find any of them, the actual
917
- // "#embroider_compat" request will fall through all the way to here.
920
+ // "@embroider/virtual" request will fall through all the way to here.
918
921
  //
919
922
  // In that case, we don't want to externalize that failure. We know it's
920
923
  // not a classic runtime thing. It's better to let it be a build error
@@ -947,7 +950,11 @@ class Resolver {
947
950
  if (withinEngine) {
948
951
  // it's a relative import inside an engine (which also means app), which
949
952
  // means we may need to satisfy the request via app tree merging.
950
- let appJSMatch = await this.searchAppTree(request, withinEngine, (0, shared_internals_2.explicitRelative)(pkg.root, (0, path_1.resolve)((0, path_1.dirname)(request.fromFile), request.specifier)));
953
+ let logicalName = engineRelativeName(pkg, (0, path_1.resolve)((0, path_1.dirname)(request.fromFile), request.specifier));
954
+ if (!logicalName) {
955
+ return logTransition('fallbackResolve: relative failure because this file is not externally accessible', request);
956
+ }
957
+ let appJSMatch = await this.searchAppTree(request, withinEngine, logicalName);
951
958
  if (appJSMatch) {
952
959
  return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
953
960
  }
@@ -961,7 +968,7 @@ class Resolver {
961
968
  }
962
969
  }
963
970
  // auto-upgraded packages can fall back to the set of known active addons
964
- if (pkg.meta['auto-upgraded']) {
971
+ if (pkg.needsLooseResolving()) {
965
972
  let addon = this.locateActiveAddon(packageName);
966
973
  if (addon) {
967
974
  const rehomed = request.rehome(addon.canResolveFromFile);
@@ -991,7 +998,7 @@ class Resolver {
991
998
  return logTransition('fallbackResolve: non-relative appJsMatch', request, appJSMatch);
992
999
  }
993
1000
  }
994
- if (pkg.meta['auto-upgraded'] && ((_c = (_b = request.meta) === null || _b === void 0 ? void 0 : _b.runtimeFallback) !== null && _c !== void 0 ? _c : true)) {
1001
+ if (pkg.needsLooseResolving() && ((_c = (_b = request.meta) === null || _b === void 0 ? void 0 : _b.runtimeFallback) !== null && _c !== void 0 ? _c : true)) {
995
1002
  // auto-upgraded packages can fall back to attempting to find dependencies at
996
1003
  // runtime. Native v2 packages can only get this behavior in the
997
1004
  // isExplicitlyExternal case above because they need to explicitly ask for
@@ -1081,14 +1088,10 @@ class Resolver {
1081
1088
  if (engineConfig) {
1082
1089
  // we're directly inside an engine, so we're potentially resolvable as a
1083
1090
  // global component
1084
- // this kind of mapping is not true in general for all packages, but it
1085
- // *is* true for all classical engines (which includes apps) since they
1086
- // don't support package.json `exports`. As for a future v2 engine or app:
1087
- // this whole method is only relevant for implementing packageRules, which
1088
- // should only be for classic stuff. v2 packages should do the right
1089
- // things from the beginning and not need packageRules about themselves.
1090
- let inAppName = (0, shared_internals_2.explicitRelative)(engineConfig.root, filename);
1091
- return this.tryReverseComponent(engineConfig.packageName, inAppName);
1091
+ let inAppName = engineRelativeName(owningPackage, filename);
1092
+ if (inAppName) {
1093
+ return this.tryReverseComponent(engineConfig.packageName, inAppName);
1094
+ }
1092
1095
  }
1093
1096
  let engineInfo = this.reverseSearchAppTree(owningPackage, filename);
1094
1097
  if (engineInfo) {
@@ -1136,4 +1139,10 @@ function reliablyResolvable(pkg, packageName) {
1136
1139
  function appImportInAppTree(inPackage, inLogicalPackage, importedPackageName) {
1137
1140
  return inPackage !== inLogicalPackage && importedPackageName === inLogicalPackage.name;
1138
1141
  }
1142
+ function engineRelativeName(pkg, filename) {
1143
+ let outsideName = (0, reverse_exports_1.externalName)(pkg.packageJSON, (0, shared_internals_2.explicitRelative)(pkg.root, filename));
1144
+ if (outsideName) {
1145
+ return '.' + outsideName.slice(pkg.name.length);
1146
+ }
1147
+ }
1139
1148
  //# sourceMappingURL=module-resolver.js.map