@embroider/core 3.4.15-unstable.d9fc688 → 3.4.15-unstable.e1733ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/app-files.d.ts +0 -1
- package/src/app-files.js +1 -3
- package/src/app-files.js.map +1 -1
- package/src/module-resolver.d.ts +0 -1
- package/src/module-resolver.js +48 -58
- package/src/module-resolver.js.map +1 -1
- package/src/virtual-content.js +0 -5
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +3 -3
- package/src/virtual-entrypoint.js +4 -6
- package/src/virtual-entrypoint.js.map +1 -1
- package/src/virtual-route-entrypoint.d.ts +4 -4
- package/src/virtual-route-entrypoint.js +7 -6
- package/src/virtual-route-entrypoint.js.map +1 -1
- package/src/virtual-test-entrypoint.d.ts +0 -10
- package/src/virtual-test-entrypoint.js +0 -66
- package/src/virtual-test-entrypoint.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@embroider/core",
|
3
|
-
"version": "3.4.15-unstable.
|
3
|
+
"version": "3.4.15-unstable.e1733ef",
|
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.
|
45
|
-
"@embroider/reverse-exports": "0.1.1-unstable.
|
46
|
-
"@embroider/shared-internals": "2.6.3-unstable.
|
44
|
+
"@embroider/macros": "1.16.6-unstable.e1733ef",
|
45
|
+
"@embroider/reverse-exports": "0.1.1-unstable.e1733ef",
|
46
|
+
"@embroider/shared-internals": "2.6.3-unstable.e1733ef"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@glimmer/syntax": "^0.84.2",
|
package/src/app-files.d.ts
CHANGED
@@ -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
|
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;
|
package/src/app-files.js.map
CHANGED
@@ -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,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AG,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,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,EAAE,CAAC;gBAC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,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;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"]}
|
package/src/module-resolver.d.ts
CHANGED
@@ -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;
|
package/src/module-resolver.js
CHANGED
@@ -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
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
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
|
-
|
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
|
@@ -692,6 +681,9 @@ class Resolver {
|
|
692
681
|
// ember-source might provide backburner via module renaming, but if you
|
693
682
|
// have an explicit dependency on backburner you should still get that real
|
694
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
|
+
// }
|
695
687
|
if (!pkg.hasDependency(packageName)) {
|
696
688
|
for (let [candidate, replacement] of Object.entries(this.options.renameModules)) {
|
697
689
|
if (candidate === request.specifier) {
|
@@ -721,28 +713,28 @@ class Resolver {
|
|
721
713
|
let owningEngine = this.owningEngine(pkg);
|
722
714
|
let addonConfig = owningEngine.activeAddons.find(a => a.root === pkg.root);
|
723
715
|
if (addonConfig) {
|
716
|
+
// auto-upgraded addons get special support for self-resolving here.
|
724
717
|
return logTransition(`v1 addon self-import`, request, request.rehome(addonConfig.canResolveFromFile));
|
725
718
|
}
|
726
719
|
else {
|
727
|
-
|
728
|
-
|
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.
|
729
723
|
}
|
730
724
|
}
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
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')));
|
745
|
-
}
|
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')));
|
746
738
|
}
|
747
739
|
}
|
748
740
|
}
|
@@ -805,18 +797,10 @@ class Resolver {
|
|
805
797
|
}
|
806
798
|
// if the requesting file is in an addon's app-js, the relative request
|
807
799
|
// should really be understood as a request for a module in the containing
|
808
|
-
// engine
|
800
|
+
// engine.
|
809
801
|
let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
|
810
802
|
if (logicalLocation) {
|
811
|
-
return logTransition('beforeResolve: relative import in app-js', request, request
|
812
|
-
.alias('./' + path_1.posix.join((0, path_1.dirname)(logicalLocation.inAppName), request.specifier))
|
813
|
-
// it's important that we're rehoming this to the root of the engine
|
814
|
-
// (which we know really exists), and not to a subdir like
|
815
|
-
// logicalLocation.inAppName (which might not physically exist),
|
816
|
-
// because some environments (including node's require.resolve) will
|
817
|
-
// refuse to do resolution from a notional path that doesn't
|
818
|
-
// physically exist.
|
819
|
-
.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)));
|
820
804
|
}
|
821
805
|
return request;
|
822
806
|
}
|
@@ -966,7 +950,11 @@ class Resolver {
|
|
966
950
|
if (withinEngine) {
|
967
951
|
// it's a relative import inside an engine (which also means app), which
|
968
952
|
// means we may need to satisfy the request via app tree merging.
|
969
|
-
let
|
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);
|
970
958
|
if (appJSMatch) {
|
971
959
|
return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
|
972
960
|
}
|
@@ -1100,14 +1088,10 @@ class Resolver {
|
|
1100
1088
|
if (engineConfig) {
|
1101
1089
|
// we're directly inside an engine, so we're potentially resolvable as a
|
1102
1090
|
// global component
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
// should only be for classic stuff. v2 packages should do the right
|
1108
|
-
// things from the beginning and not need packageRules about themselves.
|
1109
|
-
let inAppName = (0, shared_internals_2.explicitRelative)(engineConfig.root, filename);
|
1110
|
-
return this.tryReverseComponent(engineConfig.packageName, inAppName);
|
1091
|
+
let inAppName = engineRelativeName(owningPackage, filename);
|
1092
|
+
if (inAppName) {
|
1093
|
+
return this.tryReverseComponent(engineConfig.packageName, inAppName);
|
1094
|
+
}
|
1111
1095
|
}
|
1112
1096
|
let engineInfo = this.reverseSearchAppTree(owningPackage, filename);
|
1113
1097
|
if (engineInfo) {
|
@@ -1155,4 +1139,10 @@ function reliablyResolvable(pkg, packageName) {
|
|
1155
1139
|
function appImportInAppTree(inPackage, inLogicalPackage, importedPackageName) {
|
1156
1140
|
return inPackage !== inLogicalPackage && importedPackageName === inLogicalPackage.name;
|
1157
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
|
+
}
|
1158
1148
|
//# sourceMappingURL=module-resolver.js.map
|