@embroider/core 3.4.10 → 3.4.11-unstable.0653f6d

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.
Files changed (55) hide show
  1. package/package.json +15 -12
  2. package/src/app-files.d.ts +3 -4
  3. package/src/app-files.js +10 -3
  4. package/src/app-files.js.map +1 -1
  5. package/src/describe-exports.js.map +1 -1
  6. package/src/html-entrypoint.js.map +1 -1
  7. package/src/html-placeholder.js.map +1 -1
  8. package/src/index.d.ts +1 -2
  9. package/src/index.js.map +1 -1
  10. package/src/messages.js.map +1 -1
  11. package/src/module-resolver.d.ts +31 -15
  12. package/src/module-resolver.js +346 -191
  13. package/src/module-resolver.js.map +1 -1
  14. package/src/node-resolve.d.ts +33 -0
  15. package/src/node-resolve.js +131 -0
  16. package/src/node-resolve.js.map +1 -0
  17. package/src/options.js.map +1 -1
  18. package/src/packager.js.map +1 -1
  19. package/src/portable-babel-config.js.map +1 -1
  20. package/src/portable-babel-launcher.js.map +1 -1
  21. package/src/portable.js.map +1 -1
  22. package/src/resolver-loader.js.map +1 -1
  23. package/src/to-broccoli-plugin.js.map +1 -1
  24. package/src/virtual-content.d.ts +6 -2
  25. package/src/virtual-content.js +119 -42
  26. package/src/virtual-content.js.map +1 -1
  27. package/src/virtual-entrypoint.d.ts +19 -0
  28. package/src/virtual-entrypoint.js +303 -0
  29. package/src/virtual-entrypoint.js.map +1 -0
  30. package/src/virtual-route-entrypoint.d.ts +15 -0
  31. package/src/virtual-route-entrypoint.js +102 -0
  32. package/src/virtual-route-entrypoint.js.map +1 -0
  33. package/src/virtual-test-entrypoint.d.ts +10 -0
  34. package/src/virtual-test-entrypoint.js +67 -0
  35. package/src/virtual-test-entrypoint.js.map +1 -0
  36. package/src/virtual-test-support-styles.d.ts +4 -0
  37. package/src/virtual-test-support-styles.js +65 -0
  38. package/src/virtual-test-support-styles.js.map +1 -0
  39. package/src/virtual-test-support.d.ts +4 -0
  40. package/src/virtual-test-support.js +69 -0
  41. package/src/virtual-test-support.js.map +1 -0
  42. package/src/virtual-vendor-styles.d.ts +4 -0
  43. package/src/virtual-vendor-styles.js +83 -0
  44. package/src/virtual-vendor-styles.js.map +1 -0
  45. package/src/virtual-vendor.d.ts +4 -0
  46. package/src/virtual-vendor.js +73 -0
  47. package/src/virtual-vendor.js.map +1 -0
  48. package/src/wait-for-trees.js.map +1 -1
  49. package/LICENSE +0 -21
  50. package/src/asset.d.ts +0 -33
  51. package/src/asset.js +0 -3
  52. package/src/asset.js.map +0 -1
  53. package/src/ember-html.d.ts +0 -43
  54. package/src/ember-html.js +0 -110
  55. package/src/ember-html.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/core",
3
- "version": "3.4.10",
3
+ "version": "3.4.11-unstable.0653f6d",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -16,10 +16,16 @@
16
16
  "src/**/*.d.ts",
17
17
  "src/**/*.js.map"
18
18
  ],
19
+ "scripts": {
20
+ "test": "jest"
21
+ },
19
22
  "dependencies": {
20
23
  "@babel/core": "^7.14.5",
21
24
  "@babel/parser": "^7.14.5",
22
25
  "@babel/traverse": "^7.14.5",
26
+ "@embroider/macros": "1.16.3-unstable.0653f6d",
27
+ "@embroider/reverse-exports": "0.1.1-unstable.0653f6d",
28
+ "@embroider/shared-internals": "2.6.2-unstable.0653f6d",
23
29
  "assert-never": "^1.2.1",
24
30
  "babel-plugin-ember-template-compilation": "^2.1.1",
25
31
  "broccoli-node-api": "^1.7.0",
@@ -27,6 +33,7 @@
27
33
  "broccoli-plugin": "^4.0.7",
28
34
  "broccoli-source": "^3.0.1",
29
35
  "debug": "^4.3.2",
36
+ "escape-string-regexp": "^4.0.0",
30
37
  "fast-sourcemap-concat": "^1.4.0",
31
38
  "filesize": "^10.0.7",
32
39
  "fs-extra": "^9.1.0",
@@ -37,34 +44,30 @@
37
44
  "lodash": "^4.17.21",
38
45
  "resolve": "^1.20.0",
39
46
  "resolve-package-path": "^4.0.1",
47
+ "resolve.exports": "^2.0.2",
40
48
  "typescript-memoize": "^1.0.1",
41
- "walk-sync": "^3.0.0",
42
- "@embroider/macros": "1.16.2",
43
- "@embroider/shared-internals": "2.6.1"
49
+ "walk-sync": "^3.0.0"
44
50
  },
45
51
  "devDependencies": {
52
+ "@embroider/sample-transforms": "workspace:*",
53
+ "@embroider/test-support": "workspace:*",
46
54
  "@glimmer/syntax": "^0.84.2",
47
55
  "@glint/template": "^1.0.0",
48
56
  "@types/babel__core": "^7.1.14",
49
57
  "@types/babel__traverse": "^7.18.5",
50
58
  "@types/debug": "^4.1.5",
51
59
  "@types/fs-extra": "^9.0.12",
52
- "@types/jsdom": "^16.2.11",
53
60
  "@types/js-string-escape": "^1.0.0",
61
+ "@types/jsdom": "^16.2.11",
54
62
  "@types/lodash": "^4.14.170",
55
63
  "@types/node": "^15.12.2",
56
64
  "@types/resolve": "^1.20.0",
57
65
  "@types/tmp": "^0.1.0",
58
66
  "fixturify": "^2.1.1",
59
67
  "tmp": "^0.1.0",
60
- "typescript": "^5.1.6",
61
- "@embroider/sample-transforms": "0.0.0",
62
- "@embroider/test-support": "0.36.0"
68
+ "typescript": "^5.4.5"
63
69
  },
64
70
  "engines": {
65
71
  "node": "12.* || 14.* || >= 16"
66
- },
67
- "scripts": {
68
- "test": "jest"
69
72
  }
70
- }
73
+ }
@@ -20,16 +20,15 @@ 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>;
27
27
  }
28
28
  export interface Engine {
29
29
  package: Package;
30
- addons: Set<AddonPackage>;
31
- parent: Engine | undefined;
32
- sourcePath: string;
30
+ addons: Map<AddonPackage, string>;
31
+ isApp: boolean;
33
32
  modulePrefix: string;
34
33
  appRelativePath: string;
35
34
  }
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 = [];
@@ -21,7 +21,7 @@ class AppFiles {
21
21
  for (let f of fastbootFiles) {
22
22
  combinedFiles.add(f);
23
23
  }
24
- for (let addon of engine.addons) {
24
+ for (let addon of engine.addons.keys()) {
25
25
  let appJS = addon.meta['app-js'];
26
26
  if (appJS) {
27
27
  for (let filename of Object.keys(appJS)) {
@@ -79,7 +79,14 @@ class AppFiles {
79
79
  this.handleClassicRouteFile(relativePath)) {
80
80
  continue;
81
81
  }
82
- otherAppFiles.push(relativePath);
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;
@@ -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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;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,KAAK,CAAC;aAChB;iBAAM;gBACL,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;aACnB;SACF;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) {\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\n addons: Set<AddonPackage>;\n // the parent engine, if any\n parent: Engine | undefined;\n // where the engine's own V2 code comes from\n sourcePath: string;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // this is destPath but relative to the app itself\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,CAAC;YACvC,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC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AAK,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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"describe-exports.js","sourceRoot":"","sources":["describe-exports.ts"],"names":[],"mappings":";;;;;;AACA,sCAAoC;AAEpC,+DAAuC;AACvC,sCAAyC;AACzC,gEAAuC;AAEvC,SAAgB,eAAe,CAAC,IAAY,EAAE,iBAAmC;IAC/E,IAAI,GAAG,GAAG,IAAA,YAAK,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC3D;IACD,IAAI,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEnC,IAAA,kBAAQ,EAAC,GAAG,EAAE;QACZ,sBAAsB,CAAC,IAAwC;YAC7D,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACrC,QAAQ,IAAI,CAAC,IAAI,EAAE;oBACjB,KAAK,iBAAiB,CAAC;oBACvB,KAAK,0BAA0B;wBAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;wBAE5F,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBAChB,MAAM;oBACR,KAAK,wBAAwB;wBAC3B,kDAAkD;wBAClD,MAAM;oBACR;wBACE,IAAA,sBAAW,EAAC,IAAI,CAAC,CAAC;iBACrB;aACF;YACD,IAAI,YAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBAClD,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE;oBAClD,IAAI,YAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;wBAC1B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;qBACxB;iBACF;aACF;YACD,IAAI,YAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,YAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBACjG,IAAI,YAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;oBAC5C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;iBAC1C;aACF;QACH,CAAC;QACD,wBAAwB,CAAC,KAA2C;YAClE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AA1CD,0CA0CC","sourcesContent":["import type { TransformOptions } from '@babel/core';\nimport { parse } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport { types as t } from '@babel/core';\nimport assertNever from 'assert-never';\n\nexport function describeExports(code: string, babelParserConfig: TransformOptions): { names: Set<string> } {\n let ast = parse(code, babelParserConfig);\n if (!ast || ast.type !== 'File') {\n throw new Error(`bug in embroider/core describe-exports`);\n }\n let names: Set<string> = new Set();\n\n traverse(ast, {\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n for (let spec of path.node.specifiers) {\n switch (spec.type) {\n case 'ExportSpecifier':\n case 'ExportNamespaceSpecifier':\n const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;\n\n names.add(name);\n break;\n case 'ExportDefaultSpecifier':\n // this is in the types but was never standardized\n break;\n default:\n assertNever(spec);\n }\n }\n if (t.isVariableDeclaration(path.node.declaration)) {\n for (let dec of path.node.declaration.declarations) {\n if (t.isIdentifier(dec.id)) {\n names.add(dec.id.name);\n }\n }\n }\n if (t.isFunctionDeclaration(path.node.declaration) || t.isClassDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n names.add(path.node.declaration.id.name);\n }\n }\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n names.add('default');\n },\n });\n return { names };\n}\n"]}
1
+ {"version":3,"file":"describe-exports.js","sourceRoot":"","sources":["describe-exports.ts"],"names":[],"mappings":";;;;;;AACA,sCAAoC;AAEpC,+DAAuC;AACvC,sCAAyC;AACzC,gEAAuC;AAEvC,SAAgB,eAAe,CAAC,IAAY,EAAE,iBAAmC;IAC/E,IAAI,GAAG,GAAG,IAAA,YAAK,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEnC,IAAA,kBAAQ,EAAC,GAAG,EAAE;QACZ,sBAAsB,CAAC,IAAwC;YAC7D,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACtC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;oBAClB,KAAK,iBAAiB,CAAC;oBACvB,KAAK,0BAA0B;wBAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;wBAE5F,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBAChB,MAAM;oBACR,KAAK,wBAAwB;wBAC3B,kDAAkD;wBAClD,MAAM;oBACR;wBACE,IAAA,sBAAW,EAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,IAAI,YAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnD,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;oBACnD,IAAI,YAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;wBAC3B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,YAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,YAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClG,IAAI,YAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC7C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC;QACD,wBAAwB,CAAC,KAA2C;YAClE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AA1CD,0CA0CC","sourcesContent":["import type { TransformOptions } from '@babel/core';\nimport { parse } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport { types as t } from '@babel/core';\nimport assertNever from 'assert-never';\n\nexport function describeExports(code: string, babelParserConfig: TransformOptions): { names: Set<string> } {\n let ast = parse(code, babelParserConfig);\n if (!ast || ast.type !== 'File') {\n throw new Error(`bug in embroider/core describe-exports`);\n }\n let names: Set<string> = new Set();\n\n traverse(ast, {\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n for (let spec of path.node.specifiers) {\n switch (spec.type) {\n case 'ExportSpecifier':\n case 'ExportNamespaceSpecifier':\n const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;\n\n names.add(name);\n break;\n case 'ExportDefaultSpecifier':\n // this is in the types but was never standardized\n break;\n default:\n assertNever(spec);\n }\n }\n if (t.isVariableDeclaration(path.node.declaration)) {\n for (let dec of path.node.declaration.declarations) {\n if (t.isIdentifier(dec.id)) {\n names.add(dec.id.name);\n }\n }\n }\n if (t.isFunctionDeclaration(path.node.declaration) || t.isClassDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n names.add(path.node.declaration.id.name);\n }\n }\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n names.add('default');\n },\n });\n return { names };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"html-entrypoint.js","sourceRoot":"","sources":["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,EAA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/F,KAAK,IAAI,MAAM,IAAI,WAAW,EAAE;QAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YAC3B,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;SAC7B;KACF;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":["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,GA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CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,WAAqB,EAAE,WAAwB,EAAE,cAAsB;IAC/F,KAAK,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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"html-placeholder.js","sourceRoot":"","sources":["html-placeholder.ts"],"names":[],"mappings":";;;AAQA,SAAgB,OAAO,CACrB,QAAkB,EAClB,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,KAA2F,EAAE;IAEpH,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE;QAChB,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;KACpB;IAED,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACvE;IAED,IAAI,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC,CAAC,CAAC;IAE1D,IAAI,IAAI,EAAE;QACR,KAAK,IAAI,EAAE,IAAI,EAAE,KAAK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CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACtF,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACrB;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"]}
1
+ {"version":3,"file":"html-placeholder.js","sourceRoot":"","sources":["html-placeholder.ts"],"names":[],"mappings":";;;AAQA,SAAgB,OAAO,CACrB,QAAkB,EAClB,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,KAA2F,EAAE;IAEpH,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC,CAAC,CAAC;IAE1D,IAAI,IAAI,EAAE,CAAC;QACT,KAAK,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3D,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,aAAa,CAAC;YACvE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEvB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,S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AAC,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"]}
package/src/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  export { Packager, PackagerConstructor, Variant, applyVariantToBabelConfig, getAppMeta, getPackagerCacheDir, } from './packager';
2
2
  export { HTMLEntrypoint, BundleSummary } from './html-entrypoint';
3
3
  export { default as Stage } from './stage';
4
- export { Asset, EmberAsset, ImplicitAssetPaths } from './asset';
5
4
  export { default as Options, optionsWithDefaults } from './options';
6
5
  export { default as toBroccoliPlugin } from './to-broccoli-plugin';
7
6
  export { default as WaitForTrees, OutputPaths } from './wait-for-trees';
8
7
  export { compile as jsHandlebarsCompile } from './js-handlebars';
9
8
  export { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';
10
- export { Resolver, Options as ResolverOptions, ModuleRequest, Resolution, ResolverFunction, SyncResolverFunction, } from './module-resolver';
9
+ export { Resolver, Options as ResolverOptions, ModuleRequest, Resolution } from './module-resolver';
11
10
  export { ResolverLoader } from './resolver-loader';
12
11
  export { virtualContent } from './virtual-content';
13
12
  export type { Engine } from './app-files';
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uCAOoB;AAHlB,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,+GAAA,mBAAmB,OAAA;AAErB,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAGvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,2DAAmE;AAA1D,uIAAA,OAAO,OAAoB;AACpC,mDAAwE;AAA/D,+HAAA,OAAO,OAAgB;AAChC,iDAAiE;AAAxD,oHAAA,OAAO,OAAuB;AACvC,uCAA4F;AAAnF,gGAAA,IAAI,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,iGAAA,KAAK,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA;AACvE,qDAO2B;AANzB,2GAAA,QAAQ,OAAA;AAOV,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAGvB,8EAA8E;AAC9E,+DAA+D;AAC/D,8DAA4C","sourcesContent":["export {\n Packager,\n PackagerConstructor,\n Variant,\n applyVariantToBabelConfig,\n getAppMeta,\n getPackagerCacheDir,\n} from './packager';\nexport { HTMLEntrypoint, BundleSummary } from './html-entrypoint';\nexport { default as Stage } from './stage';\nexport { Asset, EmberAsset, ImplicitAssetPaths } from './asset';\nexport { default as Options, optionsWithDefaults } from './options';\nexport { default as toBroccoliPlugin } from './to-broccoli-plugin';\nexport { default as WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport {\n Resolver,\n Options as ResolverOptions,\n ModuleRequest,\n Resolution,\n ResolverFunction,\n SyncResolverFunction,\n} from './module-resolver';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent } from './virtual-content';\nexport type { Engine } from './app-files';\n\n// this is reexported because we already make users manage a peerDep from some\n// other packages (like embroider/webpack and @embroider/compat\nexport * from '@embroider/shared-internals';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uCAOoB;AAHlB,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,+GAAA,mBAAmB,OAAA;AAErB,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAEvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,2DAAmE;AAA1D,uIAAA,OAAO,OAAoB;AACpC,mDAAwE;AAA/D,+HAAA,OAAO,OAAgB;AAChC,iDAAiE;AAAxD,oHAAA,OAAO,OAAuB;AACvC,uCAA4F;AAAnF,gGAAA,IAAI,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,iGAAA,KAAK,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA;AACvE,qDAAoG;AAA3F,2GAAA,QAAQ,OAAA;AACjB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAGvB,8EAA8E;AAC9E,+DAA+D;AAC/D,8DAA4C","sourcesContent":["export {\n Packager,\n PackagerConstructor,\n Variant,\n applyVariantToBabelConfig,\n getAppMeta,\n getPackagerCacheDir,\n} from './packager';\nexport { HTMLEntrypoint, BundleSummary } from './html-entrypoint';\nexport { default as Stage } from './stage';\nexport { default as Options, optionsWithDefaults } from './options';\nexport { default as toBroccoliPlugin } from './to-broccoli-plugin';\nexport { default as WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport { Resolver, Options as ResolverOptions, ModuleRequest, Resolution } from './module-resolver';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent } from './virtual-content';\nexport type { Engine } from './app-files';\n\n// this is reexported because we already make users manage a peerDep from some\n// other packages (like embroider/webpack and @embroider/compat\nexport * from '@embroider/shared-internals';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["messages.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA8B;AAC9B,+BAA8B;AAE9B,MAAM,IAAI,GAAG,IAAA,eAAS,EAAC,gBAAgB,CAAC,CAAC;AA8DhC,oBAAI;AA7Db,MAAM,WAAW,GAAG,IAAA,eAAS,EAAC,u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AAK,CAAC,MAAM,CAAC,GAAG,EAAE;YAChB,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE;YACf,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,YAAY;QACZ,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;QAChC,QAAQ,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;KAChC;AACH,CAAC;AAdD,0CAcC;AAED,SAAgB,aAAa,CAAC,OAAe,EAAE,EAAc;IAC3D,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI;QACF,EAAE,EAAE,CAAC;KACN;YAAS;QACR,WAAW,CAAC,GAAG,EAAE,CAAC;KACnB;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AARD,sCAQC","sourcesContent":["import makeDebug from 'debug';\nimport { format } from 'util';\n\nconst todo = makeDebug('embroider:todo');\nconst unsupported = makeDebug('embroider:unsupported');\nconst debug = makeDebug('embroider:debug');\n\nfunction realWarn(message: string, params: any[]) {\n if (hardFailMode > 0) {\n throw new Error(`Unexpected warning in test suite: ${format(message, ...params)}`);\n } else {\n console.log('WARNING: ' + format(message, ...params));\n }\n}\n\nlet expectStack = [] as RegExp[];\nlet handled: WeakSet<RegExp> = new WeakSet();\n\nfunction expectedWarn(message: string, params: any[]) {\n let formattedMessage = format(message, ...params);\n for (let pattern of expectStack) {\n if (pattern.test(formattedMessage)) {\n handled.add(pattern);\n return;\n }\n }\n realWarn(message, params);\n}\n\nexport function warn(message: string, ...params: any[]) {\n if (expectStack.length === 0) {\n realWarn(message, params);\n } else {\n expectedWarn(message, params);\n }\n}\n\n// for use in our test suites\nlet hardFailMode = 0;\nexport function throwOnWarnings(hooks?: NestedHooks) {\n if (hooks) {\n // qunit mode\n hooks.before(() => {\n hardFailMode++;\n });\n hooks.after(() => {\n hardFailMode--;\n });\n } else {\n // Jest mode\n beforeAll(() => hardFailMode++);\n afterAll(() => hardFailMode--);\n }\n}\n\nexport function expectWarning(pattern: RegExp, fn: () => void) {\n expectStack.push(pattern);\n try {\n fn();\n } finally {\n expectStack.pop();\n }\n return handled.has(pattern);\n}\n\nexport { todo, unsupported, debug };\n"]}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["messages.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA8B;AAC9B,+BAA8B;AAE9B,MAAM,IAAI,GAAG,IAAA,eAAS,EAAC,gBAAgB,CAAC,CAAC;AA8DhC,oBAAI;AA7Db,MAAM,WAAW,GAAG,IAAA,eAAS,EAAC,uBAAuB,CAAC,CAAC;AA6DxC,kCAAW;AA5D1B,MAAM,KAAK,GAAG,IAAA,eAAS,EAAC,iBAAiB,CAAC,CAAC;AA4Df,sBAAK;AA1DjC,SAAS,QAAQ,CAAC,OAAe,EAAE,MAAa;IAC9C,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAA,aAAM,EAAC,OAAO,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAA,aAAM,EAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,IAAI,WAAW,GAAG,EAAc,CAAC;AACjC,IAAI,OAAO,GAAoB,IAAI,OAAO,EAAE,CAAC;AAE7C,SAAS,YAAY,CAAC,OAAe,EAAE,MAAa;IAClD,IAAI,gBAAgB,GAAG,IAAA,aAAM,EAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;IAClD,KAAK,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACnC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:todo');\nconst unsupported = makeDebug('embroider:unsupported');\nconst debug = makeDebug('embroider:debug');\n\nfunction realWarn(message: string, params: any[]) {\n if (hardFailMode > 0) {\n throw new Error(`Unexpected warning in test suite: ${format(message, ...params)}`);\n } else {\n console.log('WARNING: ' + format(message, ...params));\n }\n}\n\nlet expectStack = [] as RegExp[];\nlet handled: WeakSet<RegExp> = new WeakSet();\n\nfunction expectedWarn(message: string, params: any[]) {\n let formattedMessage = format(message, ...params);\n for (let pattern of expectStack) {\n if (pattern.test(formattedMessage)) {\n handled.add(pattern);\n return;\n }\n }\n realWarn(message, params);\n}\n\nexport function warn(message: string, ...params: any[]) {\n if (expectStack.length === 0) {\n realWarn(message, params);\n } else {\n expectedWarn(message, params);\n }\n}\n\n// for use in our test suites\nlet hardFailMode = 0;\nexport function throwOnWarnings(hooks?: NestedHooks) {\n if (hooks) {\n // qunit mode\n hooks.before(() => {\n hardFailMode++;\n });\n hooks.after(() => {\n hardFailMode--;\n });\n } else {\n // Jest mode\n beforeAll(() => hardFailMode++);\n afterAll(() => hardFailMode--);\n }\n}\n\nexport function expectWarning(pattern: RegExp, fn: () => void) {\n expectStack.push(pattern);\n try {\n fn();\n } finally {\n expectStack.pop();\n }\n return handled.has(pattern);\n}\n\nexport { todo, unsupported, debug };\n"]}
@@ -8,21 +8,22 @@ export interface Options {
8
8
  renameModules: {
9
9
  [fromName: string]: string;
10
10
  };
11
- activeAddons: {
12
- [packageName: string]: string;
13
- };
14
11
  resolvableExtensions: string[];
15
12
  appRoot: string;
16
13
  engines: EngineConfig[];
17
14
  modulePrefix: string;
15
+ splitAtRoutes?: (RegExp | string)[];
18
16
  podModulePrefix?: string;
19
17
  amdCompatibility: Required<UserOptions['amdCompatibility']>;
18
+ autoRun: boolean;
19
+ staticAppPaths: string[];
20
20
  }
21
- interface EngineConfig {
21
+ export interface EngineConfig {
22
22
  packageName: string;
23
23
  activeAddons: {
24
24
  name: string;
25
25
  root: string;
26
+ canResolveFromFile: string;
26
27
  }[];
27
28
  fastbootFiles: {
28
29
  [appName: string]: {
@@ -31,34 +32,42 @@ interface EngineConfig {
31
32
  };
32
33
  };
33
34
  root: string;
35
+ isLazy: boolean;
34
36
  }
35
- export interface ModuleRequest {
37
+ export interface ModuleRequest<Res extends Resolution = Resolution> {
36
38
  readonly specifier: string;
37
39
  readonly fromFile: string;
38
40
  readonly isVirtual: boolean;
39
41
  readonly meta: Record<string, unknown> | undefined;
42
+ readonly debugType: string;
43
+ readonly isNotFound: boolean;
44
+ readonly resolvedTo: Res | undefined;
40
45
  alias(newSpecifier: string): this;
41
46
  rehome(newFromFile: string): this;
42
47
  virtualize(virtualFilename: string): this;
43
48
  withMeta(meta: Record<string, any> | undefined): this;
49
+ notFound(): this;
50
+ defaultResolve(): Promise<Res>;
51
+ resolveTo(resolution: Res): this;
44
52
  }
45
53
  export type Resolution<T = unknown, E = unknown> = {
46
54
  type: 'found';
55
+ filename: string;
56
+ isVirtual: boolean;
57
+ result: T;
58
+ } | {
59
+ type: 'ignored';
47
60
  result: T;
48
61
  } | {
49
62
  type: 'not_found';
50
63
  err: E;
51
64
  };
52
- export type ResolverFunction<R extends ModuleRequest = ModuleRequest, Res extends Resolution = Resolution> = (request: R) => Promise<Res>;
53
- export type SyncResolverFunction<R extends ModuleRequest = ModuleRequest, Res extends Resolution = Resolution> = (request: R) => Res;
54
65
  export declare class Resolver {
55
66
  readonly options: Options;
56
67
  constructor(options: Options);
57
- beforeResolve<R extends ModuleRequest>(request: R): R;
58
- resolve<Req extends ModuleRequest, Res extends Resolution>(request: Req, defaultResolve: ResolverFunction<Req, Res>): Promise<Res>;
59
- resolveSync<Req extends ModuleRequest, Res extends Resolution>(request: Req, defaultResolve: SyncResolverFunction<Req, Res>): Res;
60
- private internalResolve;
61
- nodeResolve(specifier: string, fromFile: string): {
68
+ private beforeResolve;
69
+ resolve<ResolveResolution extends Resolution>(request: ModuleRequest<ResolveResolution>): Promise<ResolveResolution>;
70
+ nodeResolve(specifier: string, fromFile: string): Promise<{
62
71
  type: 'virtual';
63
72
  filename: string;
64
73
  content: string;
@@ -68,13 +77,19 @@ export declare class Resolver {
68
77
  } | {
69
78
  type: 'not_found';
70
79
  err: Error;
71
- };
80
+ }>;
72
81
  get packageCache(): RewrittenPackageCache;
73
82
  private logicalPackage;
74
83
  private generateFastbootSwitch;
75
84
  private handleFastbootSwitch;
76
85
  private handleImplicitModules;
86
+ private handleEntrypoint;
87
+ private handleTestEntrypoint;
88
+ private handleRouteEntrypoint;
89
+ private handleImplicitTestScripts;
90
+ private handleTestSupportStyles;
77
91
  private handleGlobalsCompat;
92
+ private handleVendorStyles;
78
93
  private resolveHelper;
79
94
  private resolveComponent;
80
95
  private resolveHelperOrComponent;
@@ -88,10 +103,12 @@ export declare class Resolver {
88
103
  owningEngine(pkg: Package): EngineConfig;
89
104
  private handleRewrittenPackages;
90
105
  private handleRenaming;
106
+ private handleVendor;
91
107
  private resolveWithinMovedPackage;
92
108
  private preHandleExternal;
109
+ private locateActiveAddon;
93
110
  private external;
94
- fallbackResolve<R extends ModuleRequest>(request: R): R;
111
+ private fallbackResolve;
95
112
  private getEntryFromMergeMap;
96
113
  private withResolvableExtensions;
97
114
  private searchAppTree;
@@ -99,4 +116,3 @@ export declare class Resolver {
99
116
  reverseComponentLookup(filename: string): string | undefined;
100
117
  private tryReverseComponent;
101
118
  }
102
- export {};