@embroider/core 3.4.15-unstable.5063729 → 3.4.15-unstable.52687d4

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.52687d4",
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.52687d4",
45
+ "@embroider/reverse-exports": "0.1.1-unstable.52687d4",
46
+ "@embroider/shared-internals": "2.6.3-unstable.52687d4"
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,KAAK,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AI,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,EAAU,CAA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als';\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;
@@ -109,6 +108,9 @@ export declare class Resolver {
109
108
  private locateActiveAddon;
110
109
  private external;
111
110
  private fallbackResolve;
111
+ private restoreRehomedRequest;
112
+ private relativeFallbackResolve;
113
+ private maybeFallbackToActiveAddon;
112
114
  private getEntryFromMergeMap;
113
115
  private withResolvableExtensions;
114
116
  private searchAppTree;
@@ -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
  },
@@ -671,14 +674,11 @@ class Resolver {
671
674
  return request;
672
675
  }
673
676
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
674
- if (!pkg || !pkg.isV2Ember()) {
675
- return request;
676
- }
677
677
  // real deps take precedence over renaming rules. That is, a package like
678
678
  // ember-source might provide backburner via module renaming, but if you
679
679
  // have an explicit dependency on backburner you should still get that real
680
680
  // copy.
681
- if (!pkg.hasDependency(packageName)) {
681
+ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.hasDependency(packageName))) {
682
682
  for (let [candidate, replacement] of Object.entries(this.options.renameModules)) {
683
683
  if (candidate === request.specifier) {
684
684
  return logTransition(`renameModules`, request, request.alias(replacement));
@@ -696,32 +696,42 @@ class Resolver {
696
696
  return logTransition(`renamePackages`, request, request.alias(request.specifier.replace(packageName, this.options.renamePackages[packageName])));
697
697
  }
698
698
  }
699
+ if (!pkg || !pkg.isV2Ember()) {
700
+ return request;
701
+ }
699
702
  if (pkg.name === packageName) {
700
703
  // we found a self-import
701
704
  if (pkg.meta['auto-upgraded']) {
702
705
  // auto-upgraded packages always get automatically adjusted. They never
703
706
  // supported fancy package.json exports features so this direct mapping
704
707
  // 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')));
708
+ // "my-app/foo" -> "./foo" from app's package.json
709
+ // "my-addon/foo" -> "my-addon/foo" from a package that's guaranteed to be able to resolve my-addon
710
+ let owningEngine = this.owningEngine(pkg);
711
+ let addonConfig = owningEngine.activeAddons.find(a => a.root === pkg.root);
712
+ if (addonConfig) {
713
+ // auto-upgraded addons get special support for self-resolving here.
714
+ return logTransition(`v1 addon self-import`, request, request.rehome(addonConfig.canResolveFromFile));
715
+ }
716
+ else {
717
+ // auto-upgraded apps will necessarily have packageJSON.exports
718
+ // because we insert them, so for that support we can fall through to
719
+ // that support below.
720
+ }
709
721
  }
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
- }
722
+ // v2 packages are supposed to use package.json `exports` to enable
723
+ // self-imports, but not all build tools actually follow the spec. This
724
+ // is a workaround for badly behaved packagers.
725
+ //
726
+ // Known upstream bugs this works around:
727
+ // - https://github.com/vitejs/vite/issues/9731
728
+ if (pkg.packageJSON.exports) {
729
+ let found = (0, resolve_exports_1.exports)(pkg.packageJSON, request.specifier, {
730
+ browser: true,
731
+ conditions: ['default', 'imports'],
732
+ });
733
+ if (found === null || found === void 0 ? void 0 : found[0]) {
734
+ 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
735
  }
726
736
  }
727
737
  }
@@ -784,18 +794,10 @@ class Resolver {
784
794
  }
785
795
  // if the requesting file is in an addon's app-js, the relative request
786
796
  // should really be understood as a request for a module in the containing
787
- // engine
797
+ // engine.
788
798
  let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
789
799
  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')));
800
+ 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
801
  }
800
802
  return request;
801
803
  }
@@ -836,12 +838,10 @@ class Resolver {
836
838
  }
837
839
  }
838
840
  // 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
- }
841
+ if (!pkg.needsLooseResolving() &&
842
+ !appImportInAppTree(pkg, logicalPackage, packageName) &&
843
+ !reliablyResolvable(pkg, packageName)) {
844
+ throw new Error(`${pkg.name} is trying to import from ${packageName} but that is not one of its explicit dependencies`);
845
845
  }
846
846
  return request;
847
847
  }
@@ -872,7 +872,7 @@ class Resolver {
872
872
  entry = ['require', ['default', 'has']];
873
873
  }
874
874
  if (!entry) {
875
- throw new Error(`A module tried to resolve "${request.specifier}" and didn't find it (${label}).
875
+ throw new Error(`[${request.debugType}] A module tried to resolve "${request.specifier}" and didn't find it (${label}).
876
876
 
877
877
  - Maybe a dependency declaration is missing?
878
878
  - Remember that v1 addons can only import non-Ember-addon NPM dependencies if they include ember-auto-import in their dependencies.
@@ -894,7 +894,7 @@ class Resolver {
894
894
  }
895
895
  }
896
896
  async fallbackResolve(request) {
897
- var _a, _b, _c;
897
+ var _a, _b;
898
898
  if (request.isVirtual) {
899
899
  throw new Error('Build tool bug detected! Fallback resolve should never see a virtual request. It is expected that the defaultResolve for your bundler has already resolved this request');
900
900
  }
@@ -907,14 +907,14 @@ class Resolver {
907
907
  }
908
908
  if (compatPattern.test(request.specifier)) {
909
909
  // Some kinds of compat requests get rewritten into other things
910
- // deterministically. For example, "#embroider_compat/helpers/whatever"
910
+ // deterministically. For example, "@embroider/virtual/helpers/whatever"
911
911
  // means only "the-current-engine/helpers/whatever", and if that doesn't
912
912
  // actually exist it's that path that will show up as a missing import.
913
913
  //
914
914
  // But others have an ambiguous meaning. For example,
915
- // #embroider_compat/components/whatever can mean several different
915
+ // @embroider/virtual/components/whatever can mean several different
916
916
  // things. If we're unable to find any of them, the actual
917
- // "#embroider_compat" request will fall through all the way to here.
917
+ // "@embroider/virtual" request will fall through all the way to here.
918
918
  //
919
919
  // In that case, we don't want to externalize that failure. We know it's
920
920
  // not a classic runtime thing. It's better to let it be a build error
@@ -922,52 +922,33 @@ class Resolver {
922
922
  return request;
923
923
  }
924
924
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
925
- if (!pkg) {
926
- return logTransition('no identifiable owningPackage', request);
925
+ if (pkg) {
926
+ ({ pkg, request } = this.restoreRehomedRequest(pkg, request));
927
927
  }
928
- // meta.originalFromFile gets set when we want to try to rehome a request
929
- // but then come back to the original location here in the fallback when the
930
- // rehomed request fails
931
- let movedPkg = this.packageCache.maybeMoved(pkg);
932
- if (movedPkg !== pkg) {
933
- let originalFromFile = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.originalFromFile;
934
- if (typeof originalFromFile !== 'string') {
935
- throw new Error(`bug: embroider resolver's meta is not propagating`);
928
+ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
929
+ // this request is coming from a file that appears to be owned by no ember
930
+ // package. We offer one fallback behavior for such files. They're allowed
931
+ // to resolve from the app's namespace.
932
+ //
933
+ // This makes it possible for integrations like vite to leave references
934
+ // to the app in their pre-bundled dependencies, which will end up in an
935
+ // arbitrary cache that is not inside any particular package.
936
+ let description = pkg ? 'non-ember package' : 'unowned module';
937
+ let packageName = (0, shared_internals_1.packageName)(request.specifier);
938
+ if (packageName === this.options.modulePrefix) {
939
+ return logTransition(`fallbackResolver: ${description} resolved app namespace`, request, request.rehome(this.packageCache.maybeMoved(this.packageCache.get(this.options.appRoot)).root));
936
940
  }
937
- request = request.rehome(originalFromFile);
938
- pkg = movedPkg;
939
- }
940
- if (!pkg.isV2Ember()) {
941
- return logTransition('fallbackResolve: not in an ember package', request);
941
+ return logTransition(`fallbackResolver: ${description}`, request);
942
942
  }
943
943
  let packageName = (0, shared_internals_1.packageName)(request.specifier);
944
944
  if (!packageName) {
945
945
  // this is a relative import
946
- let withinEngine = this.engineConfig(pkg.name);
947
- if (withinEngine) {
948
- // it's a relative import inside an engine (which also means app), which
949
- // 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)));
951
- if (appJSMatch) {
952
- return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
953
- }
954
- else {
955
- return logTransition('fallbackResolve: relative appJs search failure', request);
956
- }
957
- }
958
- else {
959
- // nothing else to do for relative imports
960
- return logTransition('fallbackResolve: relative failure', request);
961
- }
946
+ return this.relativeFallbackResolve(pkg, request);
962
947
  }
963
- // auto-upgraded packages can fall back to the set of known active addons
964
- if (pkg.meta['auto-upgraded']) {
965
- let addon = this.locateActiveAddon(packageName);
966
- if (addon) {
967
- const rehomed = request.rehome(addon.canResolveFromFile);
968
- if (rehomed !== request) {
969
- return logTransition(`activeAddons`, request, rehomed);
970
- }
948
+ if (pkg.needsLooseResolving()) {
949
+ let activeAddon = this.maybeFallbackToActiveAddon(request, packageName);
950
+ if (activeAddon) {
951
+ return activeAddon;
971
952
  }
972
953
  }
973
954
  let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
@@ -991,7 +972,7 @@ class Resolver {
991
972
  return logTransition('fallbackResolve: non-relative appJsMatch', request, appJSMatch);
992
973
  }
993
974
  }
994
- if (pkg.meta['auto-upgraded'] && ((_c = (_b = request.meta) === null || _b === void 0 ? void 0 : _b.runtimeFallback) !== null && _c !== void 0 ? _c : true)) {
975
+ if (pkg.needsLooseResolving() && ((_b = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.runtimeFallback) !== null && _b !== void 0 ? _b : true)) {
995
976
  // auto-upgraded packages can fall back to attempting to find dependencies at
996
977
  // runtime. Native v2 packages can only get this behavior in the
997
978
  // isExplicitlyExternal case above because they need to explicitly ask for
@@ -1010,6 +991,54 @@ class Resolver {
1010
991
  // non-resolvable, which will presumably cause a static build error in stage3.
1011
992
  return logTransition('fallbackResolve final exit', request);
1012
993
  }
994
+ restoreRehomedRequest(pkg, request) {
995
+ var _a;
996
+ // meta.originalFromFile gets set when we want to try to rehome a request
997
+ // but then come back to the original location here in the fallback when the
998
+ // rehomed request fails
999
+ let movedPkg = this.packageCache.maybeMoved(pkg);
1000
+ if (movedPkg !== pkg) {
1001
+ let originalFromFile = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.originalFromFile;
1002
+ if (typeof originalFromFile !== 'string') {
1003
+ throw new Error(`bug: embroider resolver's meta is not propagating`);
1004
+ }
1005
+ request = request.rehome(originalFromFile);
1006
+ pkg = movedPkg;
1007
+ }
1008
+ return { pkg, request };
1009
+ }
1010
+ async relativeFallbackResolve(pkg, request) {
1011
+ let withinEngine = this.engineConfig(pkg.name);
1012
+ if (withinEngine) {
1013
+ // it's a relative import inside an engine (which also means app), which
1014
+ // means we may need to satisfy the request via app tree merging.
1015
+ let logicalName = engineRelativeName(pkg, (0, path_1.resolve)((0, path_1.dirname)(request.fromFile), request.specifier));
1016
+ if (!logicalName) {
1017
+ return logTransition('fallbackResolve: relative failure because this file is not externally accessible', request);
1018
+ }
1019
+ let appJSMatch = await this.searchAppTree(request, withinEngine, logicalName);
1020
+ if (appJSMatch) {
1021
+ return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
1022
+ }
1023
+ else {
1024
+ return logTransition('fallbackResolve: relative appJs search failure', request);
1025
+ }
1026
+ }
1027
+ else {
1028
+ // nothing else to do for relative imports
1029
+ return logTransition('fallbackResolve: relative failure', request);
1030
+ }
1031
+ }
1032
+ maybeFallbackToActiveAddon(request, requestedPackageName) {
1033
+ // auto-upgraded packages can fall back to the set of known active addons
1034
+ let addon = this.locateActiveAddon(requestedPackageName);
1035
+ if (addon) {
1036
+ const rehomed = request.rehome(addon.canResolveFromFile);
1037
+ if (rehomed !== request) {
1038
+ return logTransition(`activeAddons`, request, rehomed);
1039
+ }
1040
+ }
1041
+ }
1013
1042
  getEntryFromMergeMap(inEngineSpecifier, root) {
1014
1043
  var _a;
1015
1044
  let entry;
@@ -1081,14 +1110,10 @@ class Resolver {
1081
1110
  if (engineConfig) {
1082
1111
  // we're directly inside an engine, so we're potentially resolvable as a
1083
1112
  // 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);
1113
+ let inAppName = engineRelativeName(owningPackage, filename);
1114
+ if (inAppName) {
1115
+ return this.tryReverseComponent(engineConfig.packageName, inAppName);
1116
+ }
1092
1117
  }
1093
1118
  let engineInfo = this.reverseSearchAppTree(owningPackage, filename);
1094
1119
  if (engineInfo) {
@@ -1136,4 +1161,10 @@ function reliablyResolvable(pkg, packageName) {
1136
1161
  function appImportInAppTree(inPackage, inLogicalPackage, importedPackageName) {
1137
1162
  return inPackage !== inLogicalPackage && importedPackageName === inLogicalPackage.name;
1138
1163
  }
1164
+ function engineRelativeName(pkg, filename) {
1165
+ let outsideName = (0, reverse_exports_1.externalName)(pkg.packageJSON, (0, shared_internals_2.explicitRelative)(pkg.root, filename));
1166
+ if (outsideName) {
1167
+ return '.' + outsideName.slice(pkg.name.length);
1168
+ }
1169
+ }
1139
1170
  //# sourceMappingURL=module-resolver.js.map