@embroider/core 3.4.10-unstable.3beedad → 3.4.10-unstable.6b85eb1
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 +6 -5
- package/src/app-files.d.ts +1 -1
- package/src/app-files.js +9 -2
- package/src/app-files.js.map +1 -1
- package/src/ember-html.js +1 -1
- package/src/ember-html.js.map +1 -1
- package/src/module-resolver.d.ts +6 -0
- package/src/module-resolver.js +65 -0
- package/src/module-resolver.js.map +1 -1
- package/src/virtual-content.js +15 -0
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +19 -0
- package/src/virtual-entrypoint.js +303 -0
- package/src/virtual-entrypoint.js.map +1 -0
- package/src/virtual-route-entrypoint.d.ts +15 -0
- package/src/virtual-route-entrypoint.js +102 -0
- package/src/virtual-route-entrypoint.js.map +1 -0
- package/src/virtual-test-entrypoint.d.ts +10 -0
- package/src/virtual-test-entrypoint.js +67 -0
- package/src/virtual-test-entrypoint.js.map +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@embroider/core",
|
3
|
-
"version": "3.4.10-unstable.
|
3
|
+
"version": "3.4.10-unstable.6b85eb1",
|
4
4
|
"private": false,
|
5
5
|
"description": "A build system for EmberJS applications.",
|
6
6
|
"repository": {
|
@@ -23,8 +23,9 @@
|
|
23
23
|
"@babel/core": "^7.14.5",
|
24
24
|
"@babel/parser": "^7.14.5",
|
25
25
|
"@babel/traverse": "^7.14.5",
|
26
|
-
"@embroider/macros": "1.16.2-unstable.
|
27
|
-
"@embroider/
|
26
|
+
"@embroider/macros": "1.16.2-unstable.6b85eb1",
|
27
|
+
"@embroider/reverse-exports": "0.1.1-unstable.6b85eb1",
|
28
|
+
"@embroider/shared-internals": "2.6.1-unstable.6b85eb1",
|
28
29
|
"assert-never": "^1.2.1",
|
29
30
|
"babel-plugin-ember-template-compilation": "^2.1.1",
|
30
31
|
"broccoli-node-api": "^1.7.0",
|
@@ -32,6 +33,7 @@
|
|
32
33
|
"broccoli-plugin": "^4.0.7",
|
33
34
|
"broccoli-source": "^3.0.1",
|
34
35
|
"debug": "^4.3.2",
|
36
|
+
"escape-string-regexp": "^4.0.0",
|
35
37
|
"fast-sourcemap-concat": "^1.4.0",
|
36
38
|
"filesize": "^10.0.7",
|
37
39
|
"fs-extra": "^9.1.0",
|
@@ -43,7 +45,6 @@
|
|
43
45
|
"resolve": "^1.20.0",
|
44
46
|
"resolve-package-path": "^4.0.1",
|
45
47
|
"resolve.exports": "^2.0.2",
|
46
|
-
"@embroider/reverse-exports": "0.1.1-unstable.3beedad",
|
47
48
|
"typescript-memoize": "^1.0.1",
|
48
49
|
"walk-sync": "^3.0.0"
|
49
50
|
},
|
@@ -56,8 +57,8 @@
|
|
56
57
|
"@types/babel__traverse": "^7.18.5",
|
57
58
|
"@types/debug": "^4.1.5",
|
58
59
|
"@types/fs-extra": "^9.0.12",
|
59
|
-
"@types/jsdom": "^16.2.11",
|
60
60
|
"@types/js-string-escape": "^1.0.0",
|
61
|
+
"@types/jsdom": "^16.2.11",
|
61
62
|
"@types/lodash": "^4.14.170",
|
62
63
|
"@types/node": "^15.12.2",
|
63
64
|
"@types/resolve": "^1.20.0",
|
package/src/app-files.d.ts
CHANGED
@@ -20,7 +20,7 @@ export declare class AppFiles {
|
|
20
20
|
shadowedFilename: string | undefined;
|
21
21
|
};
|
22
22
|
};
|
23
|
-
constructor(engine: Engine, appFiles: Set<string>, fastbootFiles: Set<string>, resolvableExtensions: RegExp, podModulePrefix?: string);
|
23
|
+
constructor(engine: Engine, appFiles: Set<string>, fastbootFiles: Set<string>, resolvableExtensions: RegExp, staticAppPathsPattern: RegExp | undefined, podModulePrefix?: string);
|
24
24
|
private handleClassicRouteFile;
|
25
25
|
private handlePodsRouteFile;
|
26
26
|
get routeFiles(): Readonly<RouteFiles>;
|
package/src/app-files.js
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppFiles = void 0;
|
4
4
|
const path_1 = require("path");
|
5
5
|
class AppFiles {
|
6
|
-
constructor(engine, appFiles, fastbootFiles, resolvableExtensions, podModulePrefix) {
|
6
|
+
constructor(engine, appFiles, fastbootFiles, resolvableExtensions, staticAppPathsPattern, podModulePrefix) {
|
7
7
|
this.engine = engine;
|
8
8
|
let tests = [];
|
9
9
|
let components = [];
|
@@ -79,7 +79,14 @@ class AppFiles {
|
|
79
79
|
this.handleClassicRouteFile(relativePath)) {
|
80
80
|
continue;
|
81
81
|
}
|
82
|
-
|
82
|
+
if (staticAppPathsPattern) {
|
83
|
+
if (!staticAppPathsPattern.test(relativePath)) {
|
84
|
+
otherAppFiles.push(relativePath);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
otherAppFiles.push(relativePath);
|
89
|
+
}
|
83
90
|
}
|
84
91
|
this.tests = tests;
|
85
92
|
this.components = components;
|
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,eAAwB;QAJf,WAAM,GAAN,MAAM,CAAQ;QAMvB,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,GAA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,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;AA7LD,4BA6LC","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 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 resolvable, but not when they're used via co-location.\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 if (!relativePath.endsWith('.hbs') || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\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 otherAppFiles.push(relativePath);\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;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,CAA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,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;AApMD,4BAoMC","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 resolvable, but not when they're used via co-location.\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 if (!relativePath.endsWith('.hbs') || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\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"]}
|
package/src/ember-html.js
CHANGED
@@ -53,7 +53,7 @@ class PreparedEmberHTML {
|
|
53
53
|
this.asset = asset;
|
54
54
|
this.dom = new jsdom_1.JSDOM((0, fs_1.readFileSync)(asset.sourcePath, 'utf8'));
|
55
55
|
let html = asset.prepare(this.dom);
|
56
|
-
this.javascript = Placeholder.
|
56
|
+
this.javascript = Placeholder.find(html.javascript);
|
57
57
|
this.styles = Placeholder.replacing(html.styles);
|
58
58
|
this.implicitScripts = Placeholder.find(html.implicitScripts);
|
59
59
|
this.testJavascript = html.testJavascript
|
package/src/ember-html.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ember-html.js","sourceRoot":"","sources":["ember-html.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2BAAkC;AAElC,yDAAiE;AAsBjE,MAAM,WAAW;IACf,MAAM,CAAC,IAAI,CAAC,IAAU;QACpB,IAAI,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAU;QACzB,IAAI,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,IAAU;QAChC,IAAI,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;QAEhC,IAAI,CAAC,QAAQ,IAAI,CAAC,MAA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nimport { readFileSync } from 'fs';\nimport type { EmberAsset } from './asset';\nimport { makeTag, normalizeStyleLink } from './html-placeholder';\n\nexport interface EmberHTML {\n // each of the Nodes in here points at where we should insert the\n // corresponding parts of the ember app. The Nodes themselves will be\n // replaced, so provide placeholders.\n\n // these are mandatory, the Ember app may need to put things into them.\n javascript: Node;\n styles: Node;\n implicitScripts: Node;\n\n // these are optional because you *may* choose to stick your implicit test\n // things into specific locations (which we need for backward-compat). But you\n // can leave these off and we will simply put them in the same places as the\n // non-test things.\n //\n // Do not confuse these with controlling whether or not we will insert tests.\n // That is separately controlled via `includeTests`.\n testJavascript?: Node;\n}\n\nclass Placeholder {\n static find(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n return placeholder;\n }\n\n static replacing(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n node.parentElement!.removeChild(node);\n return placeholder;\n }\n\n static immediatelyAfter(node: Node): Placeholder {\n let document = node.ownerDocument;\n let parent = node.parentElement;\n\n if (!document || !parent) {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n\n let nextSibling = node.nextSibling;\n let start = document.createTextNode('');\n let end = document.createTextNode('');\n\n parent.insertBefore(start, nextSibling);\n parent.insertBefore(end, nextSibling);\n return new Placeholder(start, end, node);\n }\n\n readonly parent: HTMLElement;\n\n constructor(readonly start: Node, readonly end: Node, readonly reference: Node) {\n if (start.parentElement && start.parentElement === end.parentElement) {\n this.parent = start.parentElement;\n } else {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n }\n\n clear() {\n let { start, end, parent } = this;\n while (start.nextSibling && start.nextSibling !== end) {\n parent.removeChild(start.nextSibling);\n }\n }\n\n insert(node: Node) {\n this.parent.insertBefore(node, this.end);\n }\n}\n\nexport class PreparedEmberHTML {\n dom: JSDOM;\n javascript: Placeholder;\n styles: Placeholder;\n implicitScripts: Placeholder;\n testJavascript: Placeholder;\n\n constructor(private asset: EmberAsset) {\n this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));\n let html = asset.prepare(this.dom);\n this.javascript = Placeholder.find(html.javascript);\n this.styles = Placeholder.replacing(html.styles);\n this.implicitScripts = Placeholder.find(html.implicitScripts);\n this.testJavascript = html.testJavascript\n ? Placeholder.replacing(html.testJavascript)\n : Placeholder.immediatelyAfter(this.javascript.end);\n }\n\n private placeholders(): Placeholder[] {\n return [this.javascript, this.styles, this.implicitScripts, this.testJavascript];\n }\n\n clear() {\n for (let range of this.placeholders()) {\n range.clear();\n }\n }\n\n // this takes the src relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertScriptTag(\n placeholder: Placeholder,\n relativeSrc: string,\n { type, tag = 'script' }: { type?: string; tag?: string } = {}\n ) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let src = this.asset.rootURL + relativeSrc;\n let attributes: Record<string, string> = type ? { src, type } : { src };\n let newTag = makeTag(document, { from, tag, attributes });\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n\n // this takes the href relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertStyleLink(placeholder: Placeholder, relativeHref: string) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let href = this.asset.rootURL + relativeHref;\n let newTag = makeTag(document, { from, tag: 'link', attributes: { href } });\n normalizeStyleLink(newTag);\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n}\n\nexport function insertNewline(at: Node) {\n at.parentElement!.insertBefore(at.ownerDocument!.createTextNode('\\n'), at);\n}\n"]}
|
package/src/module-resolver.d.ts
CHANGED
@@ -12,8 +12,11 @@ export interface Options {
|
|
12
12
|
appRoot: string;
|
13
13
|
engines: EngineConfig[];
|
14
14
|
modulePrefix: string;
|
15
|
+
splitAtRoutes?: (RegExp | string)[];
|
15
16
|
podModulePrefix?: string;
|
16
17
|
amdCompatibility: Required<UserOptions['amdCompatibility']>;
|
18
|
+
autoRun: boolean;
|
19
|
+
staticAppPaths: string[];
|
17
20
|
}
|
18
21
|
export interface EngineConfig {
|
19
22
|
packageName: string;
|
@@ -80,6 +83,9 @@ export declare class Resolver {
|
|
80
83
|
private generateFastbootSwitch;
|
81
84
|
private handleFastbootSwitch;
|
82
85
|
private handleImplicitModules;
|
86
|
+
private handleEntrypoint;
|
87
|
+
private handleTestEntrypoint;
|
88
|
+
private handleRouteEntrypoint;
|
83
89
|
private handleImplicitTestScripts;
|
84
90
|
private handleTestSupportStyles;
|
85
91
|
private handleGlobalsCompat;
|
package/src/module-resolver.js
CHANGED
@@ -22,6 +22,7 @@ const typescript_memoize_1 = require("typescript-memoize");
|
|
22
22
|
const describe_exports_1 = require("./describe-exports");
|
23
23
|
const fs_1 = require("fs");
|
24
24
|
const node_resolve_1 = require("./node-resolve");
|
25
|
+
const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
|
25
26
|
const debug = (0, debug_1.default)('embroider:resolver');
|
26
27
|
// Using a formatter makes this work lazy so nothing happens when we aren't
|
27
28
|
// logging. It is unfortunate that formatters are a globally mutable config and
|
@@ -84,6 +85,9 @@ class Resolver {
|
|
84
85
|
request = this.handleImplicitTestScripts(request);
|
85
86
|
request = this.handleVendorStyles(request);
|
86
87
|
request = this.handleTestSupportStyles(request);
|
88
|
+
request = this.handleEntrypoint(request);
|
89
|
+
request = this.handleTestEntrypoint(request);
|
90
|
+
request = this.handleRouteEntrypoint(request);
|
87
91
|
request = this.handleRenaming(request);
|
88
92
|
request = this.handleVendor(request);
|
89
93
|
// we expect the specifier to be app relative at this point - must be after handleRenaming
|
@@ -262,6 +266,67 @@ class Resolver {
|
|
262
266
|
return logTransition(`own implicit modules`, request, request.virtualize((0, path_1.resolve)(pkg.root, `-embroider-${im.type}.js`)));
|
263
267
|
}
|
264
268
|
}
|
269
|
+
handleEntrypoint(request) {
|
270
|
+
if (isTerminal(request)) {
|
271
|
+
return request;
|
272
|
+
}
|
273
|
+
//TODO move the extra forwardslash handling out into the vite plugin
|
274
|
+
const candidates = ['@embroider/core/entrypoint', '/@embroider/core/entrypoint', './@embroider/core/entrypoint'];
|
275
|
+
if (!candidates.some(c => request.specifier.startsWith(c + '/') || request.specifier === c)) {
|
276
|
+
return request;
|
277
|
+
}
|
278
|
+
const result = /\.?\/?@embroider\/core\/entrypoint(?:\/(?<packageName>.*))?/.exec(request.specifier);
|
279
|
+
if (!result) {
|
280
|
+
// TODO make a better error
|
281
|
+
throw new Error('entrypoint does not match pattern' + request.specifier);
|
282
|
+
}
|
283
|
+
const { packageName } = result.groups;
|
284
|
+
const requestingPkg = this.packageCache.ownerOfFile(request.fromFile);
|
285
|
+
if (!(requestingPkg === null || requestingPkg === void 0 ? void 0 : requestingPkg.isV2Ember())) {
|
286
|
+
throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
|
287
|
+
}
|
288
|
+
let pkg;
|
289
|
+
if (packageName) {
|
290
|
+
pkg = this.packageCache.resolve(packageName, requestingPkg);
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
pkg = requestingPkg;
|
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')));
|
315
|
+
}
|
316
|
+
handleRouteEntrypoint(request) {
|
317
|
+
if (isTerminal(request)) {
|
318
|
+
return request;
|
319
|
+
}
|
320
|
+
let routeName = (0, virtual_route_entrypoint_1.decodePublicRouteEntrypoint)(request.specifier);
|
321
|
+
if (!routeName) {
|
322
|
+
return request;
|
323
|
+
}
|
324
|
+
let pkg = this.packageCache.ownerOfFile(request.fromFile);
|
325
|
+
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
326
|
+
throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
|
327
|
+
}
|
328
|
+
return logTransition('route entrypoint', request, request.virtualize((0, virtual_route_entrypoint_1.encodeRouteEntrypoint)(pkg.root, routeName)));
|
329
|
+
}
|
265
330
|
handleImplicitTestScripts(request) {
|
266
331
|
//TODO move the extra forwardslash handling out into the vite plugin
|
267
332
|
const candidates = [
|