@embroider/core 4.4.7 → 4.5.0
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/dist/src/app-files.js +8 -0
- package/dist/src/app-files.js.map +1 -1
- package/dist/src/html-entrypoint.js +10 -5
- package/dist/src/html-entrypoint.js.map +1 -1
- package/dist/src/html-placeholder.js +4 -1
- package/dist/src/html-placeholder.js.map +1 -1
- package/dist/src/measure-concat.js +4 -1
- package/dist/src/measure-concat.js.map +1 -1
- package/dist/src/module-request.js +25 -38
- package/dist/src/module-request.js.map +1 -1
- package/dist/src/module-resolver-options.js +2 -3
- package/dist/src/module-resolver-options.js.map +1 -1
- package/dist/src/module-resolver.js +26 -32
- package/dist/src/module-resolver.js.map +1 -1
- package/dist/src/node-resolve.js +13 -12
- package/dist/src/node-resolve.js.map +1 -1
- package/dist/src/options.js +3 -3
- package/dist/src/options.js.map +1 -1
- package/dist/src/portable.js +1 -0
- package/dist/src/portable.js.map +1 -1
- package/dist/src/resolver-loader.js +15 -29
- package/dist/src/resolver-loader.js.map +1 -1
- package/dist/src/virtual-content.js +1 -1
- package/dist/src/virtual-content.js.map +1 -1
- package/dist/src/virtual-entrypoint.js +2 -3
- package/dist/src/virtual-entrypoint.js.map +1 -1
- package/dist/src/virtual-route-entrypoint.js +1 -1
- package/dist/src/virtual-route-entrypoint.js.map +1 -1
- package/dist/src/wait-for-trees.js +2 -0
- package/dist/src/wait-for-trees.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/src/app-files.js
CHANGED
|
@@ -3,6 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppFiles = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
class AppFiles {
|
|
6
|
+
engine;
|
|
7
|
+
components;
|
|
8
|
+
helpers;
|
|
9
|
+
modifiers;
|
|
10
|
+
perRoute;
|
|
11
|
+
otherAppFiles;
|
|
12
|
+
isFastbootOnly;
|
|
13
|
+
fastbootFiles;
|
|
6
14
|
constructor(engine, appFiles, fastbootFiles, resolvableExtensions, staticAppPathsPattern, podModulePrefix) {
|
|
7
15
|
this.engine = engine;
|
|
8
16
|
let components = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["../../src/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,EAAkB,CAAC;QAC9C,IAAI,wBAAwB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEzD,SAAS,GAAG,CAAC,GAAwB,EAAE,QAAgB;YACrD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACzC,OAAO;YACT,CAAC;YAED,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,oEAAoE;gBACpE,4DAA4D;gBAC5D,OAAO;YACT,CAAC;YAED,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEzC,IAAI,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;YAC/D,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAA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AC,QAAQ,CAAC;IACvB,CAAC;CACF;AA9ND,4BA8NC","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 Map<string, string>();\n let combinedNonFastbootFiles = new Map<string, string>();\n\n function add(map: Map<string, string>, filename: string): void {\n if (!resolvableExtensions.test(filename)) {\n return;\n }\n\n if (/\\.d\\.ts$/.test(filename)) {\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 return;\n }\n\n filename = filename.split(sep).join('/');\n\n let extensionless = filename.replace(resolvableExtensions, '');\n let prior = map.get(extensionless);\n\n if (!prior) {\n // no prior, so we win\n map.set(extensionless, filename);\n } else if (prior.startsWith('components/') && prior.endsWith('.hbs') && !prior.endsWith('/template.hbs')) {\n // The prior entry in combinedFiles is a colocated hbs component. The\n // name \"template.hbs\" is special in the template colocation rules due\n // to earlier pods patterns.\n //\n // colocated hbs never wins over the corresponding other resolvable js\n // or ts.\n map.set(extensionless, filename);\n }\n }\n\n for (let f of appFiles) {\n add(combinedFiles, f);\n add(combinedNonFastbootFiles, f);\n }\n for (let f of fastbootFiles) {\n add(combinedFiles, 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 add(combinedFiles, filename);\n add(combinedNonFastbootFiles, 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 add(combinedFiles, filename);\n }\n }\n }\n\n let isFastbootOnly = new Map<string, boolean>();\n for (let [extensionless, relativePath] of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(extensionless));\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 components.push(jsPath);\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"]}
|
|
1
|
+
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["../../src/app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAU3B,MAAa,QAAQ;IAUR;IATF,UAAU,CAAwB;IAClC,OAAO,CAAwB;IAC/B,SAAS,CAAwB;IAClC,QAAQ,CAAa;IACpB,aAAa,CAAwB;IACrC,cAAc,CAAuB;IACrC,aAAa,CAAyF;IAE/G,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,EAAkB,CAAC;QAC9C,IAAI,wBAAwB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEzD,SAAS,GAAG,CAAC,GAAwB,EAAE,QAAgB;YACrD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACzC,OAAO;YACT,CAAC;YAED,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,oEAAoE;gBACpE,4DAA4D;gBAC5D,OAAO;YACT,CAAC;YAED,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAG,CA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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;AA9ND,4BA8NC","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 Map<string, string>();\n let combinedNonFastbootFiles = new Map<string, string>();\n\n function add(map: Map<string, string>, filename: string): void {\n if (!resolvableExtensions.test(filename)) {\n return;\n }\n\n if (/\\.d\\.ts$/.test(filename)) {\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 return;\n }\n\n filename = filename.split(sep).join('/');\n\n let extensionless = filename.replace(resolvableExtensions, '');\n let prior = map.get(extensionless);\n\n if (!prior) {\n // no prior, so we win\n map.set(extensionless, filename);\n } else if (prior.startsWith('components/') && prior.endsWith('.hbs') && !prior.endsWith('/template.hbs')) {\n // The prior entry in combinedFiles is a colocated hbs component. The\n // name \"template.hbs\" is special in the template colocation rules due\n // to earlier pods patterns.\n //\n // colocated hbs never wins over the corresponding other resolvable js\n // or ts.\n map.set(extensionless, filename);\n }\n }\n\n for (let f of appFiles) {\n add(combinedFiles, f);\n add(combinedNonFastbootFiles, f);\n }\n for (let f of fastbootFiles) {\n add(combinedFiles, 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 add(combinedFiles, filename);\n add(combinedNonFastbootFiles, 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 add(combinedFiles, filename);\n }\n }\n }\n\n let isFastbootOnly = new Map<string, boolean>();\n for (let [extensionless, relativePath] of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(extensionless));\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 components.push(jsPath);\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"]}
|
|
@@ -12,15 +12,20 @@ const partition_1 = __importDefault(require("lodash/partition"));
|
|
|
12
12
|
const zip_1 = __importDefault(require("lodash/zip"));
|
|
13
13
|
const html_placeholder_1 = __importDefault(require("./html-placeholder"));
|
|
14
14
|
class HTMLEntrypoint {
|
|
15
|
+
pathToVanillaApp;
|
|
16
|
+
rootURL;
|
|
17
|
+
publicAssetURL;
|
|
18
|
+
filename;
|
|
19
|
+
dom;
|
|
20
|
+
placeholders = new Map();
|
|
21
|
+
modules = [];
|
|
22
|
+
scripts = [];
|
|
23
|
+
styles = [];
|
|
15
24
|
constructor(pathToVanillaApp, rootURL, publicAssetURL, filename) {
|
|
16
25
|
this.pathToVanillaApp = pathToVanillaApp;
|
|
17
26
|
this.rootURL = rootURL;
|
|
18
27
|
this.publicAssetURL = publicAssetURL;
|
|
19
28
|
this.filename = filename;
|
|
20
|
-
this.placeholders = new Map();
|
|
21
|
-
this.modules = [];
|
|
22
|
-
this.scripts = [];
|
|
23
|
-
this.styles = [];
|
|
24
29
|
this.dom = new jsdom_1.JSDOM((0, fs_extra_1.readFileSync)((0, path_1.join)(this.pathToVanillaApp, this.filename), 'utf8'));
|
|
25
30
|
for (let tag of this.handledStyles()) {
|
|
26
31
|
let styleTag = tag;
|
|
@@ -100,7 +105,7 @@ class HTMLEntrypoint {
|
|
|
100
105
|
// fastboot always loads scripts from. If there's no
|
|
101
106
|
// fastboot-specific variant, fastboot loads the base variant, but
|
|
102
107
|
// still from rootURL rather than publicAssetURL.
|
|
103
|
-
fastboot = this.rootURL + (fastboot
|
|
108
|
+
fastboot = this.rootURL + (fastboot ?? base);
|
|
104
109
|
}
|
|
105
110
|
if (base) {
|
|
106
111
|
// the browser version gets prefixed with the publicAssetURL
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-entrypoint.js","sourceRoot":"","sources":["../../src/html-entrypoint.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0D;AAC1D,uCAAwC;AACxC,+BAA4B;AAC5B,iCAA8B;AAC9B,iEAAyC;AACzC,qDAA6B;AAC7B,0EAA6C;AAG7C,MAAa,cAAc;IAOzB,YACU,gBAAwB,EACxB,OAAe,EACf,cAAsB,EACvB,QAAgB;QAHf,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,YAAO,GAAP,OAAO,CAAQ;QACf,mBAAc,GAAd,cAAc,CAAQ;QACvB,aAAQ,GAAR,QAAQ,CAAQ;QATjB,iBAAY,GAA+B,IAAI,GAAG,EAAE,CAAC;QAC7D,YAAO,GAAa,EAAE,CAAC;QACvB,YAAO,GAAa,EAAE,CAAC;QACvB,WAAM,GAAa,EAAE,CAAC;QAQpB,IAAI,CAAC,GAAG,GAAG,IAAI,aAAK,CAAC,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAEvF,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACrC,IAAI,QAAQ,GAAG,GAAsB,CAAC;YACtC,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,IAAI,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,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AAK,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACpE,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC;YACtD,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAC1C,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5B,WAAW,CAAC,aAAa,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { getOrCreate } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { join } from 'path';\nimport { JSDOM } from 'jsdom';\nimport partition from 'lodash/partition';\nimport zip from 'lodash/zip';\nimport Placeholder from './html-placeholder';\nimport type { Variant } from './packager';\n\nexport class HTMLEntrypoint {\n private dom: JSDOM;\n private placeholders: Map<string, Placeholder[]> = new Map();\n modules: string[] = [];\n scripts: string[] = [];\n styles: string[] = [];\n\n constructor(\n private pathToVanillaApp: string,\n private rootURL: string,\n private publicAssetURL: string,\n public filename: string\n ) {\n this.dom = new JSDOM(readFileSync(join(this.pathToVanillaApp, this.filename), 'utf8'));\n\n for (let tag of this.handledStyles()) {\n let styleTag = tag as HTMLLinkElement;\n let href = styleTag.href;\n if (!isAbsoluteURL(href)) {\n let url = this.relativeToApp(href);\n this.styles.push(url);\n let placeholder = new Placeholder(styleTag);\n let list = getOrCreate(this.placeholders, url, () => []);\n list.push(placeholder);\n }\n }\n\n for (let scriptTag of this.handledScripts()) {\n // scriptTag.src include rootURL. Convert it to be relative to the app.\n let src = this.relativeToApp(scriptTag.src);\n\n if (scriptTag.type === 'module') {\n this.modules.push(src);\n } else {\n this.scripts.push(src);\n }\n\n let placeholder = new Placeholder(scriptTag);\n let list = getOrCreate(this.placeholders, src, () => []);\n list.push(placeholder);\n }\n }\n\n private relativeToApp(rootRelativeURL: string) {\n return rootRelativeURL.replace(this.rootURL, '');\n }\n\n private handledScripts() {\n let scriptTags = [...this.dom.window.document.querySelectorAll('script')] as HTMLScriptElement[];\n let [ignoredScriptTags, handledScriptTags] = partition(scriptTags, scriptTag => {\n return !scriptTag.src || scriptTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(scriptTag.src);\n });\n for (let scriptTag of ignoredScriptTags) {\n scriptTag.removeAttribute('data-embroider-ignore');\n }\n return handledScriptTags;\n }\n\n private handledStyles() {\n let styleTags = [...this.dom.window.document.querySelectorAll('link[rel*=\"stylesheet\"]')] as HTMLLinkElement[];\n let [ignoredStyleTags, handledStyleTags] = partition(styleTags, styleTag => {\n return !styleTag.href || styleTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(styleTag.href);\n });\n for (let styleTag of ignoredStyleTags) {\n styleTag.removeAttribute('data-embroider-ignore');\n }\n return handledStyleTags;\n }\n\n // bundles maps from input asset to a per-variant map of output assets\n render(stats: BundleSummary): string {\n let insertedLazy = new Set<string>();\n let fastbootVariant = stats.variants.findIndex(v => Boolean(v.runtime === 'fastboot'));\n let supportsFastboot = stats.variants.some(v => v.runtime === 'fastboot' || v.runtime === 'all');\n\n for (let [src, placeholders] of this.placeholders) {\n let match = stats.entrypoints.get(src);\n if (match) {\n let firstVariant = stats.variants.findIndex((_, index) => Boolean(match!.get(index)));\n let matchingBundles = match.get(firstVariant)!;\n let matchingFastbootBundles = fastbootVariant >= 0 ? match.get(fastbootVariant) || [] : [];\n\n for (let placeholder of placeholders) {\n placeholder.clear();\n if (supportsFastboot && placeholder.isScript()) {\n // if there is any fastboot involved, we will emit the lazy bundles\n // right before our first script.\n\n let lazyMatch = stats.lazyBundles.get(src);\n if (lazyMatch && !insertedLazy.has(src)) {\n insertLazyJavascript(lazyMatch, placeholder, this.rootURL);\n insertLazyStyles(lazyMatch, placeholder, this.publicAssetURL);\n insertedLazy.add(src);\n }\n }\n for (let [base, fastboot] of zip(matchingBundles, matchingFastbootBundles)) {\n if (supportsFastboot) {\n // the fastboot version gets prefixed with the rootURL, which\n // points to our local build directory, because that's where\n // fastboot always loads scripts from. If there's no\n // fastboot-specific variant, fastboot loads the base variant, but\n // still from rootURL rather than publicAssetURL.\n fastboot = this.rootURL + (fastboot ?? base);\n }\n\n if (base) {\n // the browser version gets prefixed with the publicAssetURL\n // because that's where browsers will load it from\n base = this.publicAssetURL + base;\n }\n\n if (!base) {\n // this bundle only exists in the fastboot variant\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n element.setAttribute('src', fastboot!);\n placeholder.insert(element);\n placeholder.insertNewline();\n } else if (!fastboot) {\n // no fastboot variant\n placeholder.insertURL(base);\n } else if (fastboot === base) {\n // fastboot variant happens to be exactly the same bundle as base\n // (and publicAssetURL===rootURL), so a plain script tag covers\n // both\n placeholder.insertURL(base);\n } else {\n // we have both and they differ\n let element = placeholder.insertURL(base);\n if (element) {\n element.setAttribute('data-fastboot-src', fastboot);\n }\n }\n }\n }\n } else {\n // no match means keep the original HTML content for this placeholder.\n // (If we really wanted it empty instead, there would be matchingBundles\n // and it would be an empty list.)\n for (let placeholder of placeholders) {\n placeholder.reset();\n }\n }\n }\n return this.dom.serialize();\n }\n}\n\nexport interface BundleSummary {\n // entrypoints.get(inputAsset).get(variantIndex) === outputAssets\n //\n // these are the output assets that are needed eagerly to boot the given input\n // asset\n entrypoints: Map<string, Map<number, string[]>>;\n\n // lazyBundles.get(inputAsset) === lazyOutputAssets\n //\n // these are the output assets that might be loaded lazyily at runtime by the\n // given input asset.\n //\n // These are tracked specifically for the fastboot variant, because that's\n // where we need to be responsble for them.\n lazyBundles: Map<string, string[]>;\n\n variants: Variant[];\n}\n\nfunction isAbsoluteURL(url: string) {\n return /^(?:[a-z]+:)?\\/\\//i.test(url);\n}\n\n// we (somewhat arbitrarily) decide to put the lazy javascript bundles before\n// the very first <script> that we have rewritten\nfunction insertLazyJavascript(lazyBundles: string[], placeholder: Placeholder, rootURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.js')) {\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n // we're using rootURL instead of publicAssetURL here because\n // <fastboot-script> is executed by fastboot, which always loads them from\n // the local build directory. NOT from the publicAssetURL that browsers\n // will use, which could be a CDN.\n element.setAttribute('src', rootURL + bundle);\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n\nfunction insertLazyStyles(lazyBundles: string[], placeholder: Placeholder, publicAssetURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.css')) {\n let element = placeholder.start.ownerDocument.createElement('link');\n element.setAttribute('href', publicAssetURL + bundle);\n element.setAttribute('rel', 'stylesheet');\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"html-entrypoint.js","sourceRoot":"","sources":["../../src/html-entrypoint.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0D;AAC1D,uCAAwC;AACxC,+BAA4B;AAC5B,iCAA8B;AAC9B,iEAAyC;AACzC,qDAA6B;AAC7B,0EAA6C;AAG7C,MAAa,cAAc;IAQf;IACA;IACA;IACD;IAVD,GAAG,CAAQ;IACX,YAAY,GAA+B,IAAI,GAAG,EAAE,CAAC;IAC7D,OAAO,GAAa,EAAE,CAAC;IACvB,OAAO,GAAa,EAAE,CAAC;IACvB,MAAM,GAAa,EAAE,CAAC;IAEtB,YACU,gBAAwB,EACxB,OAAe,EACf,cAAsB,EACvB,QAAgB;QAHf,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,YAAO,GAAP,OAAO,CAAQ;QACf,mBAAc,GAAd,cAAc,CAAQ;QACvB,aAAQ,GAAR,QAAQ,CAAQ;QAEvB,IAAI,CAAC,GAAG,GAAG,IAAI,aAAK,CAAC,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAEvF,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACrC,IAAI,QAAQ,GAAG,GA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IAAI,MAAM,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACpE,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC;YACtD,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAC1C,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5B,WAAW,CAAC,aAAa,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { getOrCreate } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { join } from 'path';\nimport { JSDOM } from 'jsdom';\nimport partition from 'lodash/partition';\nimport zip from 'lodash/zip';\nimport Placeholder from './html-placeholder';\nimport type { Variant } from './packager';\n\nexport class HTMLEntrypoint {\n private dom: JSDOM;\n private placeholders: Map<string, Placeholder[]> = new Map();\n modules: string[] = [];\n scripts: string[] = [];\n styles: string[] = [];\n\n constructor(\n private pathToVanillaApp: string,\n private rootURL: string,\n private publicAssetURL: string,\n public filename: string\n ) {\n this.dom = new JSDOM(readFileSync(join(this.pathToVanillaApp, this.filename), 'utf8'));\n\n for (let tag of this.handledStyles()) {\n let styleTag = tag as HTMLLinkElement;\n let href = styleTag.href;\n if (!isAbsoluteURL(href)) {\n let url = this.relativeToApp(href);\n this.styles.push(url);\n let placeholder = new Placeholder(styleTag);\n let list = getOrCreate(this.placeholders, url, () => []);\n list.push(placeholder);\n }\n }\n\n for (let scriptTag of this.handledScripts()) {\n // scriptTag.src include rootURL. Convert it to be relative to the app.\n let src = this.relativeToApp(scriptTag.src);\n\n if (scriptTag.type === 'module') {\n this.modules.push(src);\n } else {\n this.scripts.push(src);\n }\n\n let placeholder = new Placeholder(scriptTag);\n let list = getOrCreate(this.placeholders, src, () => []);\n list.push(placeholder);\n }\n }\n\n private relativeToApp(rootRelativeURL: string) {\n return rootRelativeURL.replace(this.rootURL, '');\n }\n\n private handledScripts() {\n let scriptTags = [...this.dom.window.document.querySelectorAll('script')] as HTMLScriptElement[];\n let [ignoredScriptTags, handledScriptTags] = partition(scriptTags, scriptTag => {\n return !scriptTag.src || scriptTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(scriptTag.src);\n });\n for (let scriptTag of ignoredScriptTags) {\n scriptTag.removeAttribute('data-embroider-ignore');\n }\n return handledScriptTags;\n }\n\n private handledStyles() {\n let styleTags = [...this.dom.window.document.querySelectorAll('link[rel*=\"stylesheet\"]')] as HTMLLinkElement[];\n let [ignoredStyleTags, handledStyleTags] = partition(styleTags, styleTag => {\n return !styleTag.href || styleTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(styleTag.href);\n });\n for (let styleTag of ignoredStyleTags) {\n styleTag.removeAttribute('data-embroider-ignore');\n }\n return handledStyleTags;\n }\n\n // bundles maps from input asset to a per-variant map of output assets\n render(stats: BundleSummary): string {\n let insertedLazy = new Set<string>();\n let fastbootVariant = stats.variants.findIndex(v => Boolean(v.runtime === 'fastboot'));\n let supportsFastboot = stats.variants.some(v => v.runtime === 'fastboot' || v.runtime === 'all');\n\n for (let [src, placeholders] of this.placeholders) {\n let match = stats.entrypoints.get(src);\n if (match) {\n let firstVariant = stats.variants.findIndex((_, index) => Boolean(match!.get(index)));\n let matchingBundles = match.get(firstVariant)!;\n let matchingFastbootBundles = fastbootVariant >= 0 ? match.get(fastbootVariant) || [] : [];\n\n for (let placeholder of placeholders) {\n placeholder.clear();\n if (supportsFastboot && placeholder.isScript()) {\n // if there is any fastboot involved, we will emit the lazy bundles\n // right before our first script.\n\n let lazyMatch = stats.lazyBundles.get(src);\n if (lazyMatch && !insertedLazy.has(src)) {\n insertLazyJavascript(lazyMatch, placeholder, this.rootURL);\n insertLazyStyles(lazyMatch, placeholder, this.publicAssetURL);\n insertedLazy.add(src);\n }\n }\n for (let [base, fastboot] of zip(matchingBundles, matchingFastbootBundles)) {\n if (supportsFastboot) {\n // the fastboot version gets prefixed with the rootURL, which\n // points to our local build directory, because that's where\n // fastboot always loads scripts from. If there's no\n // fastboot-specific variant, fastboot loads the base variant, but\n // still from rootURL rather than publicAssetURL.\n fastboot = this.rootURL + (fastboot ?? base);\n }\n\n if (base) {\n // the browser version gets prefixed with the publicAssetURL\n // because that's where browsers will load it from\n base = this.publicAssetURL + base;\n }\n\n if (!base) {\n // this bundle only exists in the fastboot variant\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n element.setAttribute('src', fastboot!);\n placeholder.insert(element);\n placeholder.insertNewline();\n } else if (!fastboot) {\n // no fastboot variant\n placeholder.insertURL(base);\n } else if (fastboot === base) {\n // fastboot variant happens to be exactly the same bundle as base\n // (and publicAssetURL===rootURL), so a plain script tag covers\n // both\n placeholder.insertURL(base);\n } else {\n // we have both and they differ\n let element = placeholder.insertURL(base);\n if (element) {\n element.setAttribute('data-fastboot-src', fastboot);\n }\n }\n }\n }\n } else {\n // no match means keep the original HTML content for this placeholder.\n // (If we really wanted it empty instead, there would be matchingBundles\n // and it would be an empty list.)\n for (let placeholder of placeholders) {\n placeholder.reset();\n }\n }\n }\n return this.dom.serialize();\n }\n}\n\nexport interface BundleSummary {\n // entrypoints.get(inputAsset).get(variantIndex) === outputAssets\n //\n // these are the output assets that are needed eagerly to boot the given input\n // asset\n entrypoints: Map<string, Map<number, string[]>>;\n\n // lazyBundles.get(inputAsset) === lazyOutputAssets\n //\n // these are the output assets that might be loaded lazyily at runtime by the\n // given input asset.\n //\n // These are tracked specifically for the fastboot variant, because that's\n // where we need to be responsble for them.\n lazyBundles: Map<string, string[]>;\n\n variants: Variant[];\n}\n\nfunction isAbsoluteURL(url: string) {\n return /^(?:[a-z]+:)?\\/\\//i.test(url);\n}\n\n// we (somewhat arbitrarily) decide to put the lazy javascript bundles before\n// the very first <script> that we have rewritten\nfunction insertLazyJavascript(lazyBundles: string[], placeholder: Placeholder, rootURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.js')) {\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n // we're using rootURL instead of publicAssetURL here because\n // <fastboot-script> is executed by fastboot, which always loads them from\n // the local build directory. NOT from the publicAssetURL that browsers\n // will use, which could be a CDN.\n element.setAttribute('src', rootURL + bundle);\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n\nfunction insertLazyStyles(lazyBundles: string[], placeholder: Placeholder, publicAssetURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.css')) {\n let element = placeholder.start.ownerDocument.createElement('link');\n element.setAttribute('href', publicAssetURL + bundle);\n element.setAttribute('rel', 'stylesheet');\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n"]}
|
|
@@ -11,7 +11,7 @@ function makeTag(document, { from, tag, attributes } = {}) {
|
|
|
11
11
|
throw new Error('Must supply one of `options.from` or `options.tag`');
|
|
12
12
|
}
|
|
13
13
|
let cloned = document.createElement(tag);
|
|
14
|
-
let overrides = new Map(Object.entries(attributes
|
|
14
|
+
let overrides = new Map(Object.entries(attributes ?? {}));
|
|
15
15
|
if (from) {
|
|
16
16
|
for (let { name, value: originalValue } of from.attributes) {
|
|
17
17
|
let value = overrides.has(name) ? overrides.get(name) : originalValue;
|
|
@@ -47,6 +47,9 @@ function normalizeStyleLink(tag) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
class Placeholder {
|
|
50
|
+
target;
|
|
51
|
+
end;
|
|
52
|
+
start;
|
|
50
53
|
// remove the target Element from the DOM, and track where it was so we can
|
|
51
54
|
// update that location later.
|
|
52
55
|
constructor(target) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-placeholder.js","sourceRoot":"","sources":["../../src/html-placeholder.ts"],"names":[],"mappings":";;AAQA,0BAmCC;AAED,gDAKC;AAED,gDAQC;AApDD,SAAgB,OA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AAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACtF,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,MAAmB,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa,CAAC,OAAkB,IAAI,CAAC,GAAG;QACtC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;CACF;AA1FD,8BA0FC","sourcesContent":["export function makeTag(\n document: Document,\n options: { from: HTMLElement; tag?: string; attributes?: { [name: string]: string | null } }\n): HTMLElement;\nexport function makeTag(\n document: Document,\n options: { from?: HTMLElement; tag: string; attributes?: { [name: string]: string | null } }\n): HTMLElement;\nexport function makeTag(\n document: Document,\n { from, tag, attributes }: { from?: HTMLElement; tag?: string; attributes?: { [name: string]: string | null } } = {}\n): HTMLElement {\n if (!tag && from) {\n tag = from.tagName;\n }\n\n if (!tag) {\n throw new Error('Must supply one of `options.from` or `options.tag`');\n }\n\n let cloned = document.createElement(tag);\n let overrides = new Map(Object.entries(attributes ?? {}));\n\n if (from) {\n for (let { name, value: originalValue } of from.attributes) {\n let value = overrides.has(name) ? overrides.get(name)! : originalValue;\n overrides.delete(name);\n\n if (value === null) {\n continue;\n } else {\n cloned.setAttribute(name, value);\n }\n }\n }\n\n for (let [name, value] of overrides) {\n if (value !== null) {\n cloned.setAttribute(name, value);\n }\n }\n\n return cloned;\n}\n\nexport function normalizeScriptTag(tag: HTMLElement): void {\n if (tag.getAttribute('type') === 'module') {\n // we always convert modules to scripts, dropping\n tag.removeAttribute('type');\n }\n}\n\nexport function normalizeStyleLink(tag: HTMLElement): void {\n let rel = tag.getAttribute('rel');\n\n if (rel === null) {\n tag.setAttribute('rel', 'stylesheet');\n } else if (!rel.includes('stylesheet')) {\n tag.setAttribute('rel', `${rel} stylesheet`);\n }\n}\n\nexport default class Placeholder {\n end: InDOMNode;\n start: StartNode;\n\n // remove the target Element from the DOM, and track where it was so we can\n // update that location later.\n constructor(private target: HTMLElement) {\n if (!target.ownerDocument || !target.parentElement) {\n throw new Error('can only construct a placeholder for an element that is in DOM');\n }\n let start = target.ownerDocument.createTextNode('');\n target.parentElement.insertBefore(start, target);\n let endNode = target.ownerDocument.createTextNode('');\n target.replaceWith(endNode);\n\n // Type cast is justified because start always has a nextSibling (it's\n // \"end\") and because we know we already inserted the node.\n this.start = start as StartNode;\n\n // Type cast is justified because we know we already inserted the node.\n this.end = endNode as InDOMNode;\n }\n\n reset() {\n this.clear();\n this.insert(this.target);\n }\n\n clear() {\n while (this.start.nextSibling !== this.end) {\n this.start.parentElement.removeChild(this.start.nextSibling);\n }\n }\n\n insert(node: Node): void {\n this.end.parentElement.insertBefore(node, this.end);\n }\n\n appendToHead(node: Node): void {\n this.end.ownerDocument.head.appendChild(node);\n }\n\n isScript(): boolean {\n return this.target.tagName === 'SCRIPT';\n }\n\n insertURL(url: string) {\n if (url.endsWith('.js')) {\n return this.insertScriptTag(url);\n }\n if (url.endsWith('.css')) {\n return this.insertStyleLink(url);\n }\n throw new Error(`don't know how to insertURL ${url}`);\n }\n\n insertScriptTag(src: string) {\n let newTag = makeTag(this.end.ownerDocument, { from: this.target, attributes: { src } });\n normalizeScriptTag(newTag);\n\n this.insert(newTag);\n this.insertNewline();\n return newTag;\n }\n\n insertStyleLink(href: string) {\n let newTag: HTMLElement;\n\n if (this.isScript()) {\n // Add dynamic styles from scripts to the bottom of the head, and not to where the script was,\n // to prevent FOUC when pre-rendering (FastBoot)\n newTag = makeTag(this.end.ownerDocument, {\n from: this.target,\n tag: 'link',\n attributes: { href, type: null, src: null },\n });\n normalizeStyleLink(newTag);\n this.appendToHead(newTag);\n } else {\n // Keep the new style in the same place as the original one\n newTag = makeTag(this.end.ownerDocument, { from: this.target, attributes: { href } });\n normalizeStyleLink(newTag);\n this.insert(newTag);\n }\n this.insertNewline(newTag as InDOMNode);\n }\n\n insertNewline(node: InDOMNode = this.end): void {\n node.parentElement.insertBefore(node.ownerDocument.createTextNode('\\n'), node);\n }\n}\n\n// an html node that's definitely inserted into the DOM\ninterface InDOMNode extends Node {\n parentElement: HTMLElement;\n ownerDocument: Document;\n}\n\n// an html node that definitely has a next sibling.\ninterface StartNode extends InDOMNode {\n nextSibling: InDOMNode & ChildNode;\n}\n"]}
|
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const path_1 = require("path");
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
class MeasureConcat {
|
|
6
|
+
name;
|
|
7
|
+
concat;
|
|
8
|
+
baseDir;
|
|
9
|
+
stats = {};
|
|
6
10
|
constructor(name, concat, baseDir) {
|
|
7
11
|
this.name = name;
|
|
8
12
|
this.concat = concat;
|
|
9
13
|
this.baseDir = baseDir;
|
|
10
|
-
this.stats = {};
|
|
11
14
|
}
|
|
12
15
|
addFile(filename) {
|
|
13
16
|
this.stats[filename] = (0, fs_1.statSync)((0, path_1.join)(this.baseDir, filename)).size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure-concat.js","sourceRoot":"","sources":["../../src/measure-concat.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAC5B,2BAA8B;AAE9B,MAAqB,aAAa;
|
|
1
|
+
{"version":3,"file":"measure-concat.js","sourceRoot":"","sources":["../../src/measure-concat.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAC5B,2BAA8B;AAE9B,MAAqB,aAAa;IAEZ;IAAsB;IAAiC;IAD3E,KAAK,GAAmC,EAAE,CAAC;IAC3C,YAAoB,IAAY,EAAU,MAAuB,EAAU,OAAe;QAAtE,SAAI,GAAJ,IAAI,CAAQ;QAAU,WAAM,GAAN,MAAM,CAAiB;QAAU,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAC9F,OAAO,CAAC,QAAgB;QACtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAA,aAAQ,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;QACnE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,CAAC,QAAgB;QACvB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC3E,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CACT,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;aACvB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3B,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,KAAK,KAAK,QAAQ,CAAC;aACnD,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;QACF,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;CACF;AArBD,gCAqBC","sourcesContent":["import type SourceMapConcat from 'fast-sourcemap-concat';\nimport { join } from 'path';\nimport { statSync } from 'fs';\n\nexport default class MeasureConcat {\n stats: { [filename: string]: number } = {};\n constructor(private name: string, private concat: SourceMapConcat, private baseDir: string) {}\n addFile(filename: string) {\n this.stats[filename] = statSync(join(this.baseDir, filename)).size;\n return this.concat.addFile(filename);\n }\n addSpace(contents: string) {\n this.stats['in-memory'] = (this.stats['in-memory'] || 0) + contents.length;\n return this.concat.addSpace(contents);\n }\n async end() {\n console.log(`Concatenated ${this.name}:`);\n console.log(\n Object.entries(this.stats)\n .sort((a, b) => b[1] - a[1])\n .map(([name, bytes]) => ` ${name}: ${bytes} bytes`)\n .join('\\n')\n );\n return await this.concat.end();\n }\n}\n"]}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _ModuleRequest_adapter, _ModuleRequest_specifier, _ModuleRequest_fromFile, _ModuleRequest_meta, _ModuleRequest_resolvedTo;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.ModuleRequest = void 0;
|
|
16
4
|
exports.extractResolution = extractResolution;
|
|
@@ -21,74 +9,73 @@ class ModuleRequest {
|
|
|
21
9
|
return new ModuleRequest(result.adapter, result.initialState);
|
|
22
10
|
}
|
|
23
11
|
}
|
|
12
|
+
#adapter;
|
|
13
|
+
#specifier;
|
|
14
|
+
#fromFile;
|
|
15
|
+
#meta;
|
|
16
|
+
#resolvedTo;
|
|
24
17
|
constructor(adapter, initialize) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_ModuleRequest_resolvedTo.set(this, void 0);
|
|
30
|
-
__classPrivateFieldSet(this, _ModuleRequest_adapter, adapter, "f");
|
|
31
|
-
__classPrivateFieldSet(this, _ModuleRequest_specifier, initialize.specifier, "f");
|
|
32
|
-
__classPrivateFieldSet(this, _ModuleRequest_fromFile, initialize.fromFile, "f");
|
|
33
|
-
__classPrivateFieldSet(this, _ModuleRequest_meta, initialize.meta, "f");
|
|
18
|
+
this.#adapter = adapter;
|
|
19
|
+
this.#specifier = initialize.specifier;
|
|
20
|
+
this.#fromFile = initialize.fromFile;
|
|
21
|
+
this.#meta = initialize.meta;
|
|
34
22
|
}
|
|
35
23
|
get specifier() {
|
|
36
|
-
return
|
|
24
|
+
return this.#specifier;
|
|
37
25
|
}
|
|
38
26
|
get fromFile() {
|
|
39
|
-
return
|
|
27
|
+
return this.#fromFile;
|
|
40
28
|
}
|
|
41
29
|
get debugType() {
|
|
42
|
-
return
|
|
30
|
+
return this.#adapter.debugType;
|
|
43
31
|
}
|
|
44
32
|
get meta() {
|
|
45
|
-
return
|
|
33
|
+
return this.#meta;
|
|
46
34
|
}
|
|
47
35
|
get resolvedTo() {
|
|
48
|
-
return
|
|
36
|
+
return this.#resolvedTo;
|
|
49
37
|
}
|
|
50
38
|
alias(newSpecifier) {
|
|
51
|
-
if (
|
|
39
|
+
if (this.#specifier === newSpecifier) {
|
|
52
40
|
return this;
|
|
53
41
|
}
|
|
54
42
|
let result = this.clone();
|
|
55
|
-
|
|
43
|
+
result.#specifier = newSpecifier;
|
|
56
44
|
return result;
|
|
57
45
|
}
|
|
58
46
|
rehome(newFromFile) {
|
|
59
|
-
if (
|
|
47
|
+
if (this.#fromFile === newFromFile) {
|
|
60
48
|
return this;
|
|
61
49
|
}
|
|
62
50
|
let result = this.clone();
|
|
63
|
-
|
|
51
|
+
result.#fromFile = newFromFile;
|
|
64
52
|
return result;
|
|
65
53
|
}
|
|
66
54
|
virtualize(virtualResponse) {
|
|
67
|
-
return this.resolveTo(
|
|
55
|
+
return this.resolveTo(this.#adapter.virtualResponse(this, virtualResponse));
|
|
68
56
|
}
|
|
69
57
|
withMeta(meta) {
|
|
70
58
|
let result = this.clone();
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
result.#meta = meta;
|
|
60
|
+
result.#resolvedTo = this.#resolvedTo;
|
|
73
61
|
return result;
|
|
74
62
|
}
|
|
75
63
|
notFound() {
|
|
76
|
-
return this.resolveTo(
|
|
64
|
+
return this.resolveTo(this.#adapter.notFoundResponse(this));
|
|
77
65
|
}
|
|
78
66
|
resolveTo(res) {
|
|
79
67
|
let result = this.clone();
|
|
80
|
-
|
|
68
|
+
result.#resolvedTo = res;
|
|
81
69
|
return result;
|
|
82
70
|
}
|
|
83
71
|
defaultResolve() {
|
|
84
|
-
return
|
|
72
|
+
return this.#adapter.resolve(this);
|
|
85
73
|
}
|
|
86
74
|
clone() {
|
|
87
|
-
return new ModuleRequest(
|
|
75
|
+
return new ModuleRequest(this.#adapter, this);
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
exports.ModuleRequest = ModuleRequest;
|
|
91
|
-
_ModuleRequest_adapter = new WeakMap(), _ModuleRequest_specifier = new WeakMap(), _ModuleRequest_fromFile = new WeakMap(), _ModuleRequest_meta = new WeakMap(), _ModuleRequest_resolvedTo = new WeakMap();
|
|
92
79
|
async function extractResolution(res) {
|
|
93
80
|
if (typeof res === 'function') {
|
|
94
81
|
return await res();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-request.js","sourceRoot":"","sources":["../../src/module-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-request.js","sourceRoot":"","sources":["../../src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C;SAAM,CAAC;QACN,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["import type { VirtualResponse } from './virtual-content';\n\n// This is generic because different build systems have different ways of\n// representing a found module, and we just pass those values through.\nexport type Resolution<T = unknown, E = unknown> =\n | { type: 'found'; filename: string; virtual: VirtualResponse | false; result: T }\n\n // the important thing about this Resolution is that embroider should do its\n // fallback behaviors here.\n | { type: 'not_found'; err: E };\n\nexport type RequestAdapterCreate<Init, Res extends Resolution> = (\n params: Init\n) => { initialState: InitialRequestState; adapter: RequestAdapter<Res> } | undefined;\n\nexport interface RequestAdapter<Res extends Resolution> {\n readonly debugType: string;\n resolve(request: ModuleRequest<Res>): Promise<Res>;\n\n // the function-returning variants of both of these are only because webpack\n // plugins are a pain in the butt. Integrators are encouraged to use the plain\n // Response-returning variants in all sane build environments.\n notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);\n virtualResponse(request: ModuleRequest<Res>, response: VirtualResponse): Res | (() => Promise<Res>);\n}\n\nexport interface InitialRequestState {\n readonly specifier: string;\n readonly fromFile: string;\n readonly meta: Record<string, unknown> | undefined;\n}\n\nexport class ModuleRequest<Res extends Resolution = Resolution> implements ModuleRequest<Res> {\n static create<Init, Res extends Resolution>(\n createAdapter: RequestAdapterCreate<Init, Res>,\n params: Init\n ): ModuleRequest<Res> | undefined {\n let result = createAdapter(params);\n if (result) {\n return new ModuleRequest(result.adapter, result.initialState);\n }\n }\n\n #adapter: RequestAdapter<Res>;\n #specifier: string;\n #fromFile: string;\n #meta: Record<string, unknown> | undefined;\n #resolvedTo: Res | (() => Promise<Res>) | undefined;\n\n private constructor(adapter: RequestAdapter<Res>, initialize: InitialRequestState) {\n this.#adapter = adapter;\n this.#specifier = initialize.specifier;\n this.#fromFile = initialize.fromFile;\n this.#meta = initialize.meta;\n }\n\n get specifier(): string {\n return this.#specifier;\n }\n\n get fromFile(): string {\n return this.#fromFile;\n }\n\n get debugType(): string {\n return this.#adapter.debugType;\n }\n\n get meta(): Record<string, unknown> | undefined {\n return this.#meta;\n }\n\n get resolvedTo(): Res | (() => Promise<Res>) | undefined {\n return this.#resolvedTo;\n }\n\n alias(newSpecifier: string): this {\n if (this.#specifier === newSpecifier) {\n return this;\n }\n let result = this.clone();\n result.#specifier = newSpecifier;\n return result;\n }\n\n rehome(newFromFile: string): this {\n if (this.#fromFile === newFromFile) {\n return this;\n }\n let result = this.clone();\n result.#fromFile = newFromFile;\n return result;\n }\n\n virtualize(virtualResponse: VirtualResponse): this {\n return this.resolveTo(this.#adapter.virtualResponse(this, virtualResponse));\n }\n\n withMeta(meta: Record<string, any> | undefined): this {\n let result = this.clone();\n result.#meta = meta;\n result.#resolvedTo = this.#resolvedTo;\n return result;\n }\n\n notFound(): this {\n return this.resolveTo(this.#adapter.notFoundResponse(this));\n }\n\n resolveTo(res: Res | (() => Promise<Res>)): this {\n let result = this.clone();\n result.#resolvedTo = res;\n return result;\n }\n\n defaultResolve(): Promise<Res> {\n return this.#adapter.resolve(this);\n }\n\n clone(): this {\n return new ModuleRequest(this.#adapter, this) as this;\n }\n}\n\nexport async function extractResolution<Res extends Resolution = Resolution>(\n res: Res | (() => Promise<Res>)\n): Promise<Res> {\n if (typeof res === 'function') {\n return await res();\n } else {\n return res;\n }\n}\n"]}
|
|
@@ -10,7 +10,6 @@ const path_1 = require("path");
|
|
|
10
10
|
const fs_extra_1 = require("fs-extra");
|
|
11
11
|
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
12
12
|
function buildResolverOptions(inputs) {
|
|
13
|
-
var _a, _b;
|
|
14
13
|
let appPackage;
|
|
15
14
|
if (inputs.appPackage) {
|
|
16
15
|
appPackage = inputs.appPackage;
|
|
@@ -19,7 +18,7 @@ function buildResolverOptions(inputs) {
|
|
|
19
18
|
let packageCache = shared_internals_1.RewrittenPackageCache.shared('embroider', process.cwd());
|
|
20
19
|
appPackage = packageCache.get(packageCache.appRoot);
|
|
21
20
|
}
|
|
22
|
-
let extraDeps =
|
|
21
|
+
let extraDeps = inputs.extraDeps ?? new Map();
|
|
23
22
|
let allActiveAddons = findAllActiveAddons(appPackage, extraDeps);
|
|
24
23
|
let renamePackages = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
25
24
|
let renameModules = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
@@ -32,7 +31,7 @@ function buildResolverOptions(inputs) {
|
|
|
32
31
|
appRoot: appPackage.root,
|
|
33
32
|
engines,
|
|
34
33
|
modulePrefix,
|
|
35
|
-
staticAppPaths:
|
|
34
|
+
staticAppPaths: inputs.staticAppPaths ?? [],
|
|
36
35
|
emberVersion: appPackage.dependencies.find(d => d.name === 'ember-source').version,
|
|
37
36
|
splitAtRoutes: inputs.splitAtRoutes,
|
|
38
37
|
podModulePrefix: inputs.podModulePrefix,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-resolver-options.js","sourceRoot":"","sources":["../../src/module-resolver-options.ts"],"names":[],"mappings":";;;;;AAgCA,oDA0CC;AA1ED,kEAAuH;AAEvH,mEAA+D;AAC/D,+BAA8C;AAC9C,uCAAwC;AACxC,6DAAqC;AA2BrC,SAAgB,oBAAoB,CAAoB,MAQvD;;IACC,IAAI,UAAmB,CAAC;IACxB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,IAAI,YAAY,GAAG,wCAAqB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5E,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAI,GAAG,EAAE,CAAC;IAE9C,IAAI,eAAe,GAAmB,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;I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,CAAC,UAAmB,EAAE,SAAsC;IACtF,IAAI,MAAM,GAAG,UAAU,CAAC,eAAe,CAAC,aAAa,CAAmB,CAAC;IACzE,IAAI,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,gBAAgB,GAAG,IAAA,iBAAO,EAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,CAAC,CAAmB,CAAC;QACpG,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { explicitRelative, RewrittenPackageCache, type AddonPackage, type Package } from '@embroider/shared-internals';\nimport type { Engine } from './app-files';\nimport { resolvableExtensions } from './resolvable-extensions';\nimport { resolve as resolvePath } from 'path';\nimport { realpathSync } from 'fs-extra';\nimport flatMap from 'lodash/flatMap';\n\nexport interface Options {\n renamePackages: {\n [fromName: string]: string;\n };\n renameModules: {\n [fromName: string]: string;\n };\n resolvableExtensions: string[];\n appRoot: string;\n engines: EngineConfig[];\n modulePrefix: string;\n splitAtRoutes?: (RegExp | string)[];\n podModulePrefix?: string;\n staticAppPaths: string[];\n emberVersion: string;\n}\n\nexport interface EngineConfig {\n packageName: string;\n activeAddons: { name: string; root: string; canResolveFromFile: string }[];\n fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n root: string;\n isLazy: boolean;\n}\n\nexport function buildResolverOptions<T extends Options>(inputs: {\n appPackage?: Package;\n extraDeps?: Map<string, AddonPackage[]>;\n modulePrefix?: string;\n podModulePrefix?: string;\n splitAtRoutes?: (RegExp | string)[];\n staticAppPaths?: string[];\n extend?: (opts: T, allActiveAddons: AddonPackage[]) => T;\n}): T {\n let appPackage: Package;\n if (inputs.appPackage) {\n appPackage = inputs.appPackage;\n } else {\n let packageCache = RewrittenPackageCache.shared('embroider', process.cwd());\n appPackage = packageCache.get(packageCache.appRoot);\n }\n\n let extraDeps = inputs.extraDeps ?? new Map();\n\n let allActiveAddons: AddonPackage[] = findAllActiveAddons(appPackage, extraDeps);\n let renamePackages = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-packages']));\n let renameModules = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-modules']));\n let modulePrefix = appPackage.name;\n let engines = partitionEngines(appPackage, modulePrefix, extraDeps);\n\n let output: Options = {\n renamePackages,\n renameModules,\n resolvableExtensions: resolvableExtensions(),\n appRoot: appPackage.root,\n engines,\n modulePrefix,\n staticAppPaths: inputs.staticAppPaths ?? [],\n emberVersion: appPackage.dependencies.find(d => d.name === 'ember-source')!.version,\n splitAtRoutes: inputs.splitAtRoutes,\n podModulePrefix: inputs.podModulePrefix,\n };\n\n if (inputs.extend) {\n return inputs.extend(output as T, allActiveAddons);\n }\n return output as T;\n}\n\nfunction partitionEngines(\n appPackage: Package,\n modulePrefix: string,\n extraDeps: Map<string, AddonPackage[]>\n): EngineConfig[] {\n let queue: Engine[] = [\n {\n package: appPackage,\n addons: new Map(),\n isApp: true,\n modulePrefix,\n appRelativePath: '.',\n },\n ];\n let done: Engine[] = [];\n let seenEngines: Set<Package> = new Set();\n while (true) {\n let current = queue.shift();\n if (!current) {\n break;\n }\n findActiveAddons(current.package, current, extraDeps);\n // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)\n current.addons = new Map(\n [...current.addons].sort(([a], [b]) => {\n return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);\n })\n );\n\n for (let addon of current.addons.keys()) {\n if (addon.isEngine() && !seenEngines.has(addon)) {\n seenEngines.add(addon);\n queue.push({\n package: addon,\n addons: new Map(),\n isApp: !current,\n modulePrefix: addon.name,\n appRelativePath: explicitRelative(appPackage.root, addon.root),\n });\n }\n }\n done.push(current);\n }\n\n return done.map(engine => ({\n packageName: engine.package.name,\n // we need to use the real path here because webpack requests always use the real path i.e. follow symlinks\n root: realpathSync(engine.package.root),\n fastbootFiles: {},\n activeAddons: [...engine.addons]\n .map(([addon, canResolveFromFile]) => ({\n name: addon.name,\n root: addon.root,\n canResolveFromFile,\n }))\n // the traditional order is the order in which addons will run, such\n // that the last one wins. Our resolver's order is the order to\n // search, so first one wins.\n .reverse(),\n isLazy: engine.package.isLazyEngine(),\n }));\n}\n\n// recurse to find all active addons that don't cross an engine boundary.\n// Inner engines themselves will be returned, but not those engines' children.\n// The output set's insertion order is the proper ember-cli compatible\n// ordering of the addons.\nfunction findActiveAddons(pkg: Package, engine: Engine, extraDeps: Map<string, AddonPackage[]>): void {\n for (let child of activeAddonChildren(pkg, extraDeps)) {\n if (engine.addons.has(child)) continue;\n if (!child.isEngine()) {\n findActiveAddons(child, engine, extraDeps);\n }\n let canResolveFrom = resolvePath(pkg.root, 'package.json');\n engine.addons.set(child, canResolveFrom);\n }\n}\n\nfunction activeAddonChildren(pkg: Package, extraDeps: Map<string, AddonPackage[]>): AddonPackage[] {\n let result = (pkg.dependencies.filter(isActiveAddon) as AddonPackage[]).filter(\n // When looking for child addons, we want to ignore 'peerDependencies' of\n // a given package, to align with how ember-cli resolves addons. So here\n // we only include dependencies that are definitely active due to one of\n // the other sections.\n addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies'\n );\n let extras = extraDeps.get(pkg.root);\n if (extras) {\n result = [...result, ...extras];\n }\n return result.sort(orderAddons);\n}\n\nfunction isActiveAddon(pkg: Package): boolean {\n // stage1 already took care of converting everything that's actually active\n // into v2 addons. If it's not a v2 addon, we don't want it.\n //\n // We can encounter v1 addons here when there is inactive stuff floating\n // around in the node_modules that accidentally satisfy something like an\n // optional peer dep.\n return pkg.isV2Addon();\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nfunction findAllActiveAddons(appPackage: Package, extraDeps: Map<string, AddonPackage[]>): AddonPackage[] {\n let result = appPackage.findDescendants(isActiveAddon) as AddonPackage[];\n let extras = extraDeps.get(appPackage.root);\n if (extras) {\n let extraDescendants = flatMap(extras, dep => dep.findDescendants(isActiveAddon)) as AddonPackage[];\n result = [...result, ...extras, ...extraDescendants];\n }\n return result.sort(orderAddons);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"module-resolver-options.js","sourceRoot":"","sources":["../../src/module-resolver-options.ts"],"names":[],"mappings":";;;;;AAgCA,oDA0CC;AA1ED,kEAAuH;AAEvH,mEAA+D;AAC/D,+BAA8C;AAC9C,uCAAwC;AACxC,6DAAqC;AA2BrC,SAAgB,oBAAoB,CAAoB,MAQvD;IACC,IAAI,UAAmB,CAAC;IACxB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,IAAI,YAAY,GAAG,wCAAqB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5E,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,IAAI,GAAG,EAAE,CAAC;IAE9C,IAAI,eAAe,GAAmB,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACjF,IAAI,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACpG,IAAI,aAAa,G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E,CAAC;QACX,IAAI,gBAAgB,GAAG,IAAA,iBAAO,EAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,CAAC,CAAmB,CAAC;QACpG,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { explicitRelative, RewrittenPackageCache, type AddonPackage, type Package } from '@embroider/shared-internals';\nimport type { Engine } from './app-files';\nimport { resolvableExtensions } from './resolvable-extensions';\nimport { resolve as resolvePath } from 'path';\nimport { realpathSync } from 'fs-extra';\nimport flatMap from 'lodash/flatMap';\n\nexport interface Options {\n renamePackages: {\n [fromName: string]: string;\n };\n renameModules: {\n [fromName: string]: string;\n };\n resolvableExtensions: string[];\n appRoot: string;\n engines: EngineConfig[];\n modulePrefix: string;\n splitAtRoutes?: (RegExp | string)[];\n podModulePrefix?: string;\n staticAppPaths: string[];\n emberVersion: string;\n}\n\nexport interface EngineConfig {\n packageName: string;\n activeAddons: { name: string; root: string; canResolveFromFile: string }[];\n fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n root: string;\n isLazy: boolean;\n}\n\nexport function buildResolverOptions<T extends Options>(inputs: {\n appPackage?: Package;\n extraDeps?: Map<string, AddonPackage[]>;\n modulePrefix?: string;\n podModulePrefix?: string;\n splitAtRoutes?: (RegExp | string)[];\n staticAppPaths?: string[];\n extend?: (opts: T, allActiveAddons: AddonPackage[]) => T;\n}): T {\n let appPackage: Package;\n if (inputs.appPackage) {\n appPackage = inputs.appPackage;\n } else {\n let packageCache = RewrittenPackageCache.shared('embroider', process.cwd());\n appPackage = packageCache.get(packageCache.appRoot);\n }\n\n let extraDeps = inputs.extraDeps ?? new Map();\n\n let allActiveAddons: AddonPackage[] = findAllActiveAddons(appPackage, extraDeps);\n let renamePackages = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-packages']));\n let renameModules = Object.assign({}, ...allActiveAddons.map(dep => dep.meta['renamed-modules']));\n let modulePrefix = appPackage.name;\n let engines = partitionEngines(appPackage, modulePrefix, extraDeps);\n\n let output: Options = {\n renamePackages,\n renameModules,\n resolvableExtensions: resolvableExtensions(),\n appRoot: appPackage.root,\n engines,\n modulePrefix,\n staticAppPaths: inputs.staticAppPaths ?? [],\n emberVersion: appPackage.dependencies.find(d => d.name === 'ember-source')!.version,\n splitAtRoutes: inputs.splitAtRoutes,\n podModulePrefix: inputs.podModulePrefix,\n };\n\n if (inputs.extend) {\n return inputs.extend(output as T, allActiveAddons);\n }\n return output as T;\n}\n\nfunction partitionEngines(\n appPackage: Package,\n modulePrefix: string,\n extraDeps: Map<string, AddonPackage[]>\n): EngineConfig[] {\n let queue: Engine[] = [\n {\n package: appPackage,\n addons: new Map(),\n isApp: true,\n modulePrefix,\n appRelativePath: '.',\n },\n ];\n let done: Engine[] = [];\n let seenEngines: Set<Package> = new Set();\n while (true) {\n let current = queue.shift();\n if (!current) {\n break;\n }\n findActiveAddons(current.package, current, extraDeps);\n // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)\n current.addons = new Map(\n [...current.addons].sort(([a], [b]) => {\n return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);\n })\n );\n\n for (let addon of current.addons.keys()) {\n if (addon.isEngine() && !seenEngines.has(addon)) {\n seenEngines.add(addon);\n queue.push({\n package: addon,\n addons: new Map(),\n isApp: !current,\n modulePrefix: addon.name,\n appRelativePath: explicitRelative(appPackage.root, addon.root),\n });\n }\n }\n done.push(current);\n }\n\n return done.map(engine => ({\n packageName: engine.package.name,\n // we need to use the real path here because webpack requests always use the real path i.e. follow symlinks\n root: realpathSync(engine.package.root),\n fastbootFiles: {},\n activeAddons: [...engine.addons]\n .map(([addon, canResolveFromFile]) => ({\n name: addon.name,\n root: addon.root,\n canResolveFromFile,\n }))\n // the traditional order is the order in which addons will run, such\n // that the last one wins. Our resolver's order is the order to\n // search, so first one wins.\n .reverse(),\n isLazy: engine.package.isLazyEngine(),\n }));\n}\n\n// recurse to find all active addons that don't cross an engine boundary.\n// Inner engines themselves will be returned, but not those engines' children.\n// The output set's insertion order is the proper ember-cli compatible\n// ordering of the addons.\nfunction findActiveAddons(pkg: Package, engine: Engine, extraDeps: Map<string, AddonPackage[]>): void {\n for (let child of activeAddonChildren(pkg, extraDeps)) {\n if (engine.addons.has(child)) continue;\n if (!child.isEngine()) {\n findActiveAddons(child, engine, extraDeps);\n }\n let canResolveFrom = resolvePath(pkg.root, 'package.json');\n engine.addons.set(child, canResolveFrom);\n }\n}\n\nfunction activeAddonChildren(pkg: Package, extraDeps: Map<string, AddonPackage[]>): AddonPackage[] {\n let result = (pkg.dependencies.filter(isActiveAddon) as AddonPackage[]).filter(\n // When looking for child addons, we want to ignore 'peerDependencies' of\n // a given package, to align with how ember-cli resolves addons. So here\n // we only include dependencies that are definitely active due to one of\n // the other sections.\n addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies'\n );\n let extras = extraDeps.get(pkg.root);\n if (extras) {\n result = [...result, ...extras];\n }\n return result.sort(orderAddons);\n}\n\nfunction isActiveAddon(pkg: Package): boolean {\n // stage1 already took care of converting everything that's actually active\n // into v2 addons. If it's not a v2 addon, we don't want it.\n //\n // We can encounter v1 addons here when there is inactive stuff floating\n // around in the node_modules that accidentally satisfy something like an\n // optional peer dep.\n return pkg.isV2Addon();\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nfunction findAllActiveAddons(appPackage: Package, extraDeps: Map<string, AddonPackage[]>): AddonPackage[] {\n let result = appPackage.findDescendants(isActiveAddon) as AddonPackage[];\n let extras = extraDeps.get(appPackage.root);\n if (extras) {\n let extraDescendants = flatMap(extras, dep => dep.findDescendants(isActiveAddon)) as AddonPackage[];\n result = [...result, ...extras, ...extraDescendants];\n }\n return result.sort(orderAddons);\n}\n"]}
|