@embroider/core 3.4.15-unstable.9372659 → 3.4.15-unstable.bd04b35

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.9372659",
3
+ "version": "3.4.15-unstable.bd04b35",
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.9372659",
45
- "@embroider/reverse-exports": "0.1.1-unstable.9372659",
46
- "@embroider/shared-internals": "2.6.3-unstable.9372659"
44
+ "@embroider/macros": "1.16.6-unstable.bd04b35",
45
+ "@embroider/reverse-exports": "0.1.1-unstable.bd04b35",
46
+ "@embroider/shared-internals": "2.6.3-unstable.bd04b35"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@glimmer/syntax": "^0.84.2",
@@ -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,CAAC,IAAI,aAAa,EAAE,CAAC;YAC5B,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QAED,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,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AO,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;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,EAA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/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");
@@ -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
@@ -534,13 +523,17 @@ class Resolver {
534
523
  if (!inAddonName.startsWith('./')) {
535
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`);
536
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
+ }
537
530
  let prevEntry = engineModules.get(inEngineName);
538
531
  switch (prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.type) {
539
532
  case undefined:
540
533
  engineModules.set(inEngineName, {
541
534
  type: 'app-only',
542
535
  'app-js': {
543
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
536
+ specifier,
544
537
  fromFile: addonConfig.canResolveFromFile,
545
538
  fromPackageName: addon.name,
546
539
  },
@@ -554,7 +547,7 @@ class Resolver {
554
547
  engineModules.set(inEngineName, {
555
548
  type: 'both',
556
549
  'app-js': {
557
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
550
+ specifier,
558
551
  fromFile: addonConfig.canResolveFromFile,
559
552
  fromPackageName: addon.name,
560
553
  },
@@ -573,13 +566,17 @@ class Resolver {
573
566
  if (!inAddonName.startsWith('./')) {
574
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`);
575
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
+ }
576
573
  let prevEntry = engineModules.get(inEngineName);
577
574
  switch (prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.type) {
578
575
  case undefined:
579
576
  engineModules.set(inEngineName, {
580
577
  type: 'fastboot-only',
581
578
  'fastboot-js': {
582
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
579
+ specifier,
583
580
  fromFile: addonConfig.canResolveFromFile,
584
581
  fromPackageName: addon.name,
585
582
  },
@@ -593,7 +590,7 @@ class Resolver {
593
590
  engineModules.set(inEngineName, {
594
591
  type: 'both',
595
592
  'fastboot-js': {
596
- specifier: (0, reverse_exports_1.default)(addon.packageJSON, inAddonName),
593
+ specifier,
597
594
  fromFile: addonConfig.canResolveFromFile,
598
595
  fromPackageName: addon.name,
599
596
  },
@@ -684,6 +681,9 @@ class Resolver {
684
681
  // ember-source might provide backburner via module renaming, but if you
685
682
  // have an explicit dependency on backburner you should still get that real
686
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
+ // }
687
687
  if (!pkg.hasDependency(packageName)) {
688
688
  for (let [candidate, replacement] of Object.entries(this.options.renameModules)) {
689
689
  if (candidate === request.specifier) {
@@ -713,28 +713,28 @@ class Resolver {
713
713
  let owningEngine = this.owningEngine(pkg);
714
714
  let addonConfig = owningEngine.activeAddons.find(a => a.root === pkg.root);
715
715
  if (addonConfig) {
716
+ // auto-upgraded addons get special support for self-resolving here.
716
717
  return logTransition(`v1 addon self-import`, request, request.rehome(addonConfig.canResolveFromFile));
717
718
  }
718
719
  else {
719
- let selfImportPath = request.specifier === pkg.name ? './' : request.specifier.replace(pkg.name, '.');
720
- return logTransition(`v1 app self-import`, request, request.alias(selfImportPath).rehome((0, path_1.resolve)(pkg.root, 'package.json')));
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.
721
723
  }
722
724
  }
723
- else {
724
- // v2 packages are supposed to use package.json `exports` to enable
725
- // self-imports, but not all build tools actually follow the spec. This
726
- // is a workaround for badly behaved packagers.
727
- //
728
- // Known upstream bugs this works around:
729
- // - https://github.com/vitejs/vite/issues/9731
730
- if (pkg.packageJSON.exports) {
731
- let found = (0, resolve_exports_1.exports)(pkg.packageJSON, request.specifier, {
732
- browser: true,
733
- conditions: ['default', 'imports'],
734
- });
735
- if (found === null || found === void 0 ? void 0 : found[0]) {
736
- 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')));
737
- }
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')));
738
738
  }
739
739
  }
740
740
  }
@@ -797,18 +797,10 @@ class Resolver {
797
797
  }
798
798
  // if the requesting file is in an addon's app-js, the relative request
799
799
  // should really be understood as a request for a module in the containing
800
- // engine
800
+ // engine.
801
801
  let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
802
802
  if (logicalLocation) {
803
- return logTransition('beforeResolve: relative import in app-js', request, request
804
- .alias('./' + path_1.posix.join((0, path_1.dirname)(logicalLocation.inAppName), request.specifier))
805
- // it's important that we're rehoming this to the root of the engine
806
- // (which we know really exists), and not to a subdir like
807
- // logicalLocation.inAppName (which might not physically exist),
808
- // because some environments (including node's require.resolve) will
809
- // refuse to do resolution from a notional path that doesn't
810
- // physically exist.
811
- .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)));
812
804
  }
813
805
  return request;
814
806
  }
@@ -849,12 +841,10 @@ class Resolver {
849
841
  }
850
842
  }
851
843
  // assertions on what native v2 addons can import
852
- if (!pkg.meta['auto-upgraded']) {
853
- if (!pkg.meta['auto-upgraded'] &&
854
- !appImportInAppTree(pkg, logicalPackage, packageName) &&
855
- !reliablyResolvable(pkg, packageName)) {
856
- throw new Error(`${pkg.name} is trying to import from ${packageName} but that is not one of its explicit dependencies`);
857
- }
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`);
858
848
  }
859
849
  return request;
860
850
  }
@@ -960,7 +950,11 @@ class Resolver {
960
950
  if (withinEngine) {
961
951
  // it's a relative import inside an engine (which also means app), which
962
952
  // means we may need to satisfy the request via app tree merging.
963
- 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);
964
958
  if (appJSMatch) {
965
959
  return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
966
960
  }
@@ -974,7 +968,7 @@ class Resolver {
974
968
  }
975
969
  }
976
970
  // auto-upgraded packages can fall back to the set of known active addons
977
- if (pkg.meta['auto-upgraded']) {
971
+ if (pkg.needsLooseResolving()) {
978
972
  let addon = this.locateActiveAddon(packageName);
979
973
  if (addon) {
980
974
  const rehomed = request.rehome(addon.canResolveFromFile);
@@ -1004,7 +998,7 @@ class Resolver {
1004
998
  return logTransition('fallbackResolve: non-relative appJsMatch', request, appJSMatch);
1005
999
  }
1006
1000
  }
1007
- 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)) {
1008
1002
  // auto-upgraded packages can fall back to attempting to find dependencies at
1009
1003
  // runtime. Native v2 packages can only get this behavior in the
1010
1004
  // isExplicitlyExternal case above because they need to explicitly ask for
@@ -1094,14 +1088,10 @@ class Resolver {
1094
1088
  if (engineConfig) {
1095
1089
  // we're directly inside an engine, so we're potentially resolvable as a
1096
1090
  // global component
1097
- // this kind of mapping is not true in general for all packages, but it
1098
- // *is* true for all classical engines (which includes apps) since they
1099
- // don't support package.json `exports`. As for a future v2 engine or app:
1100
- // this whole method is only relevant for implementing packageRules, which
1101
- // should only be for classic stuff. v2 packages should do the right
1102
- // things from the beginning and not need packageRules about themselves.
1103
- let inAppName = (0, shared_internals_2.explicitRelative)(engineConfig.root, filename);
1104
- return this.tryReverseComponent(engineConfig.packageName, inAppName);
1091
+ let inAppName = engineRelativeName(owningPackage, filename);
1092
+ if (inAppName) {
1093
+ return this.tryReverseComponent(engineConfig.packageName, inAppName);
1094
+ }
1105
1095
  }
1106
1096
  let engineInfo = this.reverseSearchAppTree(owningPackage, filename);
1107
1097
  if (engineInfo) {
@@ -1149,4 +1139,10 @@ function reliablyResolvable(pkg, packageName) {
1149
1139
  function appImportInAppTree(inPackage, inLogicalPackage, importedPackageName) {
1150
1140
  return inPackage !== inLogicalPackage && importedPackageName === inLogicalPackage.name;
1151
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
+ }
1152
1148
  //# sourceMappingURL=module-resolver.js.map