@embroider/core 3.4.20-unstable.e6197c7 → 3.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.
Files changed (64) hide show
  1. package/package.json +9 -19
  2. package/src/app-files.d.ts +5 -3
  3. package/src/app-files.js +8 -25
  4. package/src/app-files.js.map +1 -1
  5. package/src/asset.d.ts +32 -0
  6. package/src/asset.js +3 -0
  7. package/src/asset.js.map +1 -0
  8. package/src/ember-html.d.ts +43 -0
  9. package/src/ember-html.js +110 -0
  10. package/src/ember-html.js.map +1 -0
  11. package/src/index.d.ts +4 -4
  12. package/src/index.js +3 -3
  13. package/src/index.js.map +1 -1
  14. package/src/measure-concat.js +2 -1
  15. package/src/measure-concat.js.map +1 -1
  16. package/src/module-resolver.d.ts +60 -17
  17. package/src/module-resolver.js +311 -402
  18. package/src/module-resolver.js.map +1 -1
  19. package/src/options.d.ts +60 -1
  20. package/src/options.js +1 -3
  21. package/src/options.js.map +1 -1
  22. package/src/portable-babel-config.d.ts +11 -0
  23. package/src/portable-babel-config.js +132 -0
  24. package/src/portable-babel-config.js.map +1 -0
  25. package/src/portable-babel-launcher.d.ts +6 -0
  26. package/src/portable-babel-launcher.js +75 -0
  27. package/src/portable-babel-launcher.js.map +1 -0
  28. package/src/resolver-loader.js +1 -8
  29. package/src/resolver-loader.js.map +1 -1
  30. package/src/to-broccoli-plugin.d.ts +8 -0
  31. package/src/to-broccoli-plugin.js +30 -0
  32. package/src/to-broccoli-plugin.js.map +1 -0
  33. package/src/virtual-content.d.ts +4 -29
  34. package/src/virtual-content.js +112 -74
  35. package/src/virtual-content.js.map +1 -1
  36. package/src/module-request.d.ts +0 -43
  37. package/src/module-request.js +0 -91
  38. package/src/module-request.js.map +0 -1
  39. package/src/module-resolver-options.d.ts +0 -42
  40. package/src/module-resolver-options.js +0 -164
  41. package/src/module-resolver-options.js.map +0 -1
  42. package/src/node-resolve.d.ts +0 -30
  43. package/src/node-resolve.js +0 -112
  44. package/src/node-resolve.js.map +0 -1
  45. package/src/virtual-entrypoint.d.ts +0 -23
  46. package/src/virtual-entrypoint.js +0 -327
  47. package/src/virtual-entrypoint.js.map +0 -1
  48. package/src/virtual-route-entrypoint.d.ts +0 -16
  49. package/src/virtual-route-entrypoint.js +0 -100
  50. package/src/virtual-route-entrypoint.js.map +0 -1
  51. package/src/virtual-test-support-styles.d.ts +0 -4
  52. package/src/virtual-test-support-styles.js +0 -64
  53. package/src/virtual-test-support-styles.js.map +0 -1
  54. package/src/virtual-test-support.d.ts +0 -4
  55. package/src/virtual-test-support.js +0 -68
  56. package/src/virtual-test-support.js.map +0 -1
  57. package/src/virtual-vendor-styles.d.ts +0 -4
  58. package/src/virtual-vendor-styles.js +0 -82
  59. package/src/virtual-vendor-styles.js.map +0 -1
  60. package/src/virtual-vendor.d.ts +0 -4
  61. package/src/virtual-vendor.js +0 -57
  62. package/src/virtual-vendor.js.map +0 -1
  63. package/types/virtual/index.d.ts +0 -9
  64. package/types/virtual/index.js +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/core",
3
- "version": "3.4.20-unstable.e6197c7",
3
+ "version": "3.5.0",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -11,32 +11,24 @@
11
11
  "license": "MIT",
12
12
  "author": "Edward Faulkner",
13
13
  "main": "src/index.js",
14
- "typesVersions": {
15
- "*": {
16
- "virtual": [
17
- "types/virtual"
18
- ]
19
- }
20
- },
21
14
  "files": [
22
15
  "src/**/*.js",
23
16
  "src/**/*.d.ts",
24
- "src/**/*.js.map",
25
- "types"
17
+ "src/**/*.js.map"
26
18
  ],
27
19
  "dependencies": {
28
20
  "@babel/core": "^7.14.5",
29
21
  "@babel/parser": "^7.14.5",
30
22
  "@babel/traverse": "^7.14.5",
31
23
  "assert-never": "^1.2.1",
32
- "babel-plugin-ember-template-compilation": "^2.3.0",
24
+ "babel-plugin-ember-template-compilation": "^2.1.1",
33
25
  "broccoli-node-api": "^1.7.0",
34
26
  "broccoli-persistent-filter": "^3.1.2",
35
27
  "broccoli-plugin": "^4.0.7",
36
28
  "broccoli-source": "^3.0.1",
37
29
  "debug": "^4.3.2",
38
- "escape-string-regexp": "^4.0.0",
39
30
  "fast-sourcemap-concat": "^2.1.1",
31
+ "filesize": "^10.0.7",
40
32
  "fs-extra": "^9.1.0",
41
33
  "fs-tree-diff": "^2.0.1",
42
34
  "handlebars": "^4.7.7",
@@ -45,13 +37,11 @@
45
37
  "lodash": "^4.17.21",
46
38
  "resolve": "^1.20.0",
47
39
  "resolve-package-path": "^4.0.1",
48
- "resolve.exports": "^2.0.2",
49
40
  "semver": "^7.3.5",
50
41
  "typescript-memoize": "^1.0.1",
51
42
  "walk-sync": "^3.0.0",
52
- "@embroider/macros": "1.16.10-unstable.e6197c7",
53
- "@embroider/reverse-exports": "0.1.1-unstable.e6197c7",
54
- "@embroider/shared-internals": "2.8.2-unstable.e6197c7"
43
+ "@embroider/macros": "1.16.10",
44
+ "@embroider/shared-internals": "2.8.1"
55
45
  },
56
46
  "devDependencies": {
57
47
  "@glimmer/syntax": "^0.84.2",
@@ -60,16 +50,16 @@
60
50
  "@types/babel__traverse": "^7.18.5",
61
51
  "@types/debug": "^4.1.5",
62
52
  "@types/fs-extra": "^9.0.12",
63
- "@types/js-string-escape": "^1.0.0",
64
53
  "@types/jsdom": "^16.2.11",
54
+ "@types/js-string-escape": "^1.0.0",
65
55
  "@types/lodash": "^4.14.170",
66
- "@types/node": "^22.9.3",
56
+ "@types/node": "^15.12.2",
67
57
  "@types/resolve": "^1.20.0",
68
58
  "@types/semver": "^7.3.5",
69
59
  "@types/tmp": "^0.1.0",
70
60
  "fixturify": "^2.1.1",
71
61
  "tmp": "^0.1.0",
72
- "typescript": "^5.4.5",
62
+ "typescript": "^5.1.6",
73
63
  "@embroider/test-support": "0.36.0",
74
64
  "@embroider/sample-transforms": "0.0.0"
75
65
  },
@@ -7,6 +7,7 @@ export interface RouteFiles {
7
7
  }
8
8
  export declare class AppFiles {
9
9
  readonly engine: Engine;
10
+ readonly tests: ReadonlyArray<string>;
10
11
  readonly components: ReadonlyArray<string>;
11
12
  readonly helpers: ReadonlyArray<string>;
12
13
  readonly modifiers: ReadonlyArray<string>;
@@ -19,15 +20,16 @@ export declare class AppFiles {
19
20
  shadowedFilename: string | undefined;
20
21
  };
21
22
  };
22
- constructor(engine: Engine, appFiles: Set<string>, fastbootFiles: Set<string>, resolvableExtensions: RegExp, staticAppPathsPattern: RegExp | undefined, podModulePrefix?: string);
23
+ constructor(engine: Engine, appFiles: Set<string>, fastbootFiles: Set<string>, resolvableExtensions: RegExp, podModulePrefix?: string);
23
24
  private handleClassicRouteFile;
24
25
  private handlePodsRouteFile;
25
26
  get routeFiles(): Readonly<RouteFiles>;
26
27
  }
27
28
  export interface Engine {
28
29
  package: Package;
29
- addons: Map<AddonPackage, string>;
30
- isApp: boolean;
30
+ addons: Set<AddonPackage>;
31
+ parent: Engine | undefined;
32
+ sourcePath: string;
31
33
  modulePrefix: string;
32
34
  appRelativePath: string;
33
35
  }
package/src/app-files.js CHANGED
@@ -3,8 +3,9 @@ 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, staticAppPathsPattern, podModulePrefix) {
6
+ constructor(engine, appFiles, fastbootFiles, resolvableExtensions, podModulePrefix) {
7
7
  this.engine = engine;
8
+ let tests = [];
8
9
  let components = [];
9
10
  let helpers = [];
10
11
  let modifiers = [];
@@ -20,7 +21,7 @@ class AppFiles {
20
21
  for (let f of fastbootFiles) {
21
22
  combinedFiles.add(f);
22
23
  }
23
- for (let addon of engine.addons.keys()) {
24
+ for (let addon of engine.addons) {
24
25
  let appJS = addon.meta['app-js'];
25
26
  if (appJS) {
26
27
  for (let filename of Object.keys(appJS)) {
@@ -49,29 +50,17 @@ class AppFiles {
49
50
  continue;
50
51
  }
51
52
  if (relativePath.startsWith('tests/')) {
52
- // skip tests because they are dealt with separately
53
+ tests.push(relativePath);
53
54
  continue;
54
55
  }
55
56
  if (relativePath.startsWith('components/')) {
56
- // hbs files are not resolvable when they're used via co-location with
57
- // an associated js file because it's the js that is resolvable.
57
+ // hbs files are resolvable, but not when they're used via co-location.
58
58
  // An hbs file is used via colocation when it's inside the components
59
59
  // directory, and also not named "template.hbs" (because that is an
60
60
  // older pattern used with pods-like layouts).
61
- let isHbs = relativePath.endsWith('.hbs');
62
- if (!isHbs || relativePath.endsWith('/template.hbs')) {
61
+ if (!relativePath.endsWith('.hbs') || relativePath.endsWith('/template.hbs')) {
63
62
  components.push(relativePath);
64
63
  }
65
- else if (isHbs) {
66
- // template-only components will be compiled as js files during the
67
- // build process, so we push a virtual path to js in the list of files
68
- // because the resolver will be able to recognize a template-only and
69
- // give a correct answer in the end.
70
- let jsPath = relativePath.replace(/\.hbs$/, '.js');
71
- if (!combinedFiles.has(jsPath)) {
72
- components.push(jsPath);
73
- }
74
- }
75
64
  continue;
76
65
  }
77
66
  if (relativePath.startsWith('templates/components/')) {
@@ -90,15 +79,9 @@ class AppFiles {
90
79
  this.handleClassicRouteFile(relativePath)) {
91
80
  continue;
92
81
  }
93
- if (staticAppPathsPattern) {
94
- if (!staticAppPathsPattern.test(relativePath)) {
95
- otherAppFiles.push(relativePath);
96
- }
97
- }
98
- else {
99
- otherAppFiles.push(relativePath);
100
- }
82
+ otherAppFiles.push(relativePath);
101
83
  }
84
+ this.tests = tests;
102
85
  this.components = components;
103
86
  this.helpers = helpers;
104
87
  this.modifiers = modifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAU3B,MAAa,QAAQ;IASnB,YACW,MAAc,EACvB,QAAqB,EACrB,aAA0B,EAC1B,oBAA4B,EAC5B,qBAAyC,EACzC,eAAwB;QALf,WAAM,G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M,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACpC,MAAM,GAAG,QAAQ,CAAC;YACpB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAA2C,CAAC,GAAG,YAAY,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA5MD,4BA4MC","sourcesContent":["import { sep } from 'path';\nimport type { Package, AddonPackage } from '@embroider/shared-internals';\n\nexport interface RouteFiles {\n route?: string;\n template?: string;\n controller?: string;\n children: Map<string, RouteFiles>;\n}\n\nexport class AppFiles {\n readonly components: ReadonlyArray<string>;\n readonly helpers: ReadonlyArray<string>;\n readonly modifiers: ReadonlyArray<string>;\n private perRoute: RouteFiles;\n readonly otherAppFiles: ReadonlyArray<string>;\n readonly isFastbootOnly: Map<string, boolean>;\n readonly fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n\n constructor(\n readonly engine: Engine,\n appFiles: Set<string>,\n fastbootFiles: Set<string>,\n resolvableExtensions: RegExp,\n staticAppPathsPattern: RegExp | undefined,\n podModulePrefix?: string\n ) {\n let components: string[] = [];\n let helpers: string[] = [];\n let modifiers: string[] = [];\n let otherAppFiles: string[] = [];\n this.perRoute = { children: new Map() };\n\n let combinedFiles = new Set<string>();\n let combinedNonFastbootFiles = new Set<string>();\n let isFastbootOnly = new Map<string, boolean>();\n\n for (let f of appFiles) {\n combinedFiles.add(f);\n combinedNonFastbootFiles.add(f);\n }\n for (let f of fastbootFiles) {\n combinedFiles.add(f);\n }\n\n for (let addon of engine.addons.keys()) {\n let appJS = addon.meta['app-js'];\n if (appJS) {\n for (let filename of Object.keys(appJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n combinedNonFastbootFiles.add(filename);\n }\n }\n\n let fastbootJS = addon.meta['fastboot-js'];\n if (fastbootJS) {\n for (let filename of Object.keys(fastbootJS)) {\n filename = filename.replace(/^\\.\\//, '');\n combinedFiles.add(filename);\n }\n }\n }\n\n for (let relativePath of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(relativePath));\n relativePath = relativePath.split(sep).join('/');\n if (!resolvableExtensions.test(relativePath)) {\n continue;\n }\n\n if (/\\.d\\.ts$/.test(relativePath)) {\n // .d.ts files are technically \"*.ts\" files but aren't really and we\n // don't want to include them when we crawl through the app.\n continue;\n }\n\n if (relativePath.startsWith('tests/')) {\n // skip tests because they are dealt with separately\n continue;\n }\n\n if (relativePath.startsWith('components/')) {\n // hbs files are not resolvable when they're used via co-location with\n // an associated js file because it's the js that is resolvable.\n // An hbs file is used via colocation when it's inside the components\n // directory, and also not named \"template.hbs\" (because that is an\n // older pattern used with pods-like layouts).\n let isHbs = relativePath.endsWith('.hbs');\n if (!isHbs || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\n } else if (isHbs) {\n // template-only components will be compiled as js files during the\n // build process, so we push a virtual path to js in the list of files\n // because the resolver will be able to recognize a template-only and\n // give a correct answer in the end.\n let jsPath = relativePath.replace(/\\.hbs$/, '.js');\n if (!combinedFiles.has(jsPath)) {\n components.push(jsPath);\n }\n }\n continue;\n }\n\n if (relativePath.startsWith('templates/components/')) {\n components.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('helpers/')) {\n helpers.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('modifiers/')) {\n modifiers.push(relativePath);\n continue;\n }\n\n if (\n (podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix)) ||\n this.handleClassicRouteFile(relativePath)\n ) {\n continue;\n }\n\n if (staticAppPathsPattern) {\n if (!staticAppPathsPattern.test(relativePath)) {\n otherAppFiles.push(relativePath);\n }\n } else {\n otherAppFiles.push(relativePath);\n }\n }\n this.components = components;\n this.helpers = helpers;\n this.modifiers = modifiers;\n this.otherAppFiles = otherAppFiles;\n this.isFastbootOnly = isFastbootOnly;\n\n // this deliberately only describes the app's fastboot files. Not the full\n // merge from all the addons. This is because they need different handling\n // in the module resolver -- addon fastboot files can always be a\n // fallbackResolve, because if the app happens to define the same name\n // (whether fastboot-specific or just browser) that wins over the addon.\n // Whereas if the app itself defines a fastbot-specific version of a file,\n // that must take precedence over the *normal* resolution, and must be\n // implemented in beforeResolve.\n this.fastbootFiles = Object.fromEntries(\n [...fastbootFiles].map(name => [\n `./${name}`,\n {\n localFilename: `./_fastboot_/${name}`,\n shadowedFilename: appFiles.has(name) ? `./${name}` : undefined,\n },\n ])\n );\n }\n\n private handleClassicRouteFile(relativePath: string): boolean {\n let [prefix, ...rest] = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n if (!['controllers', 'templates', 'routes'].includes(prefix)) {\n return false;\n }\n let type = prefix.slice(0, -1) as 'controller' | 'template' | 'route';\n let cursor = this.perRoute;\n for (let part of rest) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type] = relativePath;\n return true;\n }\n\n private handlePodsRouteFile(relativePath: string, podModulePrefix: string): boolean {\n let parts = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n let type = parts.pop();\n if (!type || !['controller', 'template', 'route'].includes(type)) {\n return false;\n }\n let podParts = podModulePrefix.split('/');\n // The first part of podModulePrefix is the app's package name\n podParts.shift();\n\n for (let podPart of podParts) {\n if (parts.shift() !== podPart) {\n return false;\n }\n }\n\n let cursor = this.perRoute;\n for (let part of parts) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type as 'controller' | 'template' | 'route'] = relativePath;\n return true;\n }\n\n get routeFiles(): Readonly<RouteFiles> {\n return this.perRoute;\n }\n}\n\nexport interface Engine {\n // the engine's own package\n package: Package;\n // the set of active addons in the engine. For each one we keep track of a file that can resolve the addon, because we'll need that later.\n addons: Map<AddonPackage, string>;\n // is this the top-level engine?\n isApp: boolean;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // TODO: remove this after we remove the stage2 entrypoint\n appRelativePath: string;\n}\n"]}
1
+ {"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAU3B,MAAa,QAAQ;IAUnB,YACW,MAAc,EACvB,QAAqB,EACrB,aAA0B,EAC1B,oBAA4B,EAC5B,eAAwB;QAJf,WAAM,GAAN,MAAM,CAAQ;QAMvB,IAAI,KAAK,GAAa,EAAE,CAAC;QACzB,IAAI,UAAU,GAAa,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAa,EAAE,CAAC;QAC3B,IAAI,SAAS,GAAa,EAAE,CAAC;QAC7B,IAAI,aAAa,GAAa,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QAExC,IAAI,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;QACtC,IAAI,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;QACjD,IAAI,cAAc,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,EAAE,CAAC;YAChC,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,IAAI,QAAQ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,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"]}
package/src/asset.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { JSDOM } from 'jsdom';
2
+ import type { EmberHTML } from './ember-html';
3
+ export interface ImplicitAssetPaths {
4
+ 'implicit-scripts': string[];
5
+ 'implicit-test-scripts': string[];
6
+ 'implicit-styles': string[];
7
+ 'implicit-test-styles': string[];
8
+ }
9
+ interface BaseAsset {
10
+ relativePath: string;
11
+ }
12
+ export interface OnDiskAsset extends BaseAsset {
13
+ kind: 'on-disk';
14
+ sourcePath: string;
15
+ mtime: number;
16
+ size: number;
17
+ }
18
+ export interface InMemoryAsset extends BaseAsset {
19
+ kind: 'in-memory';
20
+ source: string | Buffer;
21
+ }
22
+ export interface EmberAsset extends BaseAsset {
23
+ kind: 'ember';
24
+ sourcePath: string;
25
+ mtime: number;
26
+ size: number;
27
+ includeTests: boolean;
28
+ rootURL: string;
29
+ prepare(dom: JSDOM): EmberHTML;
30
+ }
31
+ export type Asset = OnDiskAsset | InMemoryAsset | EmberAsset;
32
+ export {};
package/src/asset.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.js","sourceRoot":"","sources":["asset.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSDOM } from 'jsdom';\nimport type { EmberHTML } from './ember-html';\n\nexport interface ImplicitAssetPaths {\n 'implicit-scripts': string[];\n 'implicit-test-scripts': string[];\n 'implicit-styles': string[];\n 'implicit-test-styles': string[];\n}\n\ninterface BaseAsset {\n // where this asset should be placed, relative to the app's root\n relativePath: string;\n}\n\nexport interface OnDiskAsset extends BaseAsset {\n kind: 'on-disk';\n\n // absolute path to where we will find it\n sourcePath: string;\n mtime: number;\n size: number;\n}\n\nexport interface InMemoryAsset extends BaseAsset {\n kind: 'in-memory';\n\n // the actual bits\n source: string | Buffer;\n}\n\n// This represents an HTML entrypoint to the Ember app\nexport interface EmberAsset extends BaseAsset {\n kind: 'ember';\n\n // absolute path to where we will find the html file\n sourcePath: string;\n\n // these describe the file at sourcePath so we can avoid rebuilding when it\n // hasn't changed\n mtime: number;\n size: number;\n\n // whether we should include the test suite (in addition to the ember app)\n includeTests: boolean;\n\n // the rootURL at which this Ember app expects to be hosted.\n rootURL: string;\n\n // This will receive the parsed document. It may optionally modify the\n // document. And it must return a description of the locations where we're\n // supposed to insert the parts of the Ember app.\n prepare(dom: JSDOM): EmberHTML;\n}\n\nexport type Asset = OnDiskAsset | InMemoryAsset | EmberAsset;\n"]}
@@ -0,0 +1,43 @@
1
+ import { JSDOM } from 'jsdom';
2
+ import type { EmberAsset } from './asset';
3
+ export interface EmberHTML {
4
+ javascript: Node;
5
+ styles: Node;
6
+ implicitScripts: Node;
7
+ implicitStyles: Node;
8
+ testJavascript?: Node;
9
+ implicitTestScripts?: Node;
10
+ implicitTestStyles?: Node;
11
+ }
12
+ declare class Placeholder {
13
+ readonly start: Node;
14
+ readonly end: Node;
15
+ readonly reference: Node;
16
+ static replacing(node: Node): Placeholder;
17
+ static immediatelyAfter(node: Node): Placeholder;
18
+ readonly parent: HTMLElement;
19
+ constructor(start: Node, end: Node, reference: Node);
20
+ clear(): void;
21
+ insert(node: Node): void;
22
+ }
23
+ export declare class PreparedEmberHTML {
24
+ private asset;
25
+ dom: JSDOM;
26
+ javascript: Placeholder;
27
+ styles: Placeholder;
28
+ implicitScripts: Placeholder;
29
+ implicitStyles: Placeholder;
30
+ testJavascript: Placeholder;
31
+ implicitTestScripts: Placeholder;
32
+ implicitTestStyles: Placeholder;
33
+ constructor(asset: EmberAsset);
34
+ private placeholders;
35
+ clear(): void;
36
+ insertScriptTag(placeholder: Placeholder, relativeSrc: string, { type, tag }?: {
37
+ type?: string;
38
+ tag?: string;
39
+ }): void;
40
+ insertStyleLink(placeholder: Placeholder, relativeHref: string): void;
41
+ }
42
+ export declare function insertNewline(at: Node): void;
43
+ export {};
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreparedEmberHTML = void 0;
4
+ exports.insertNewline = insertNewline;
5
+ const jsdom_1 = require("jsdom");
6
+ const fs_1 = require("fs");
7
+ const html_placeholder_1 = require("./html-placeholder");
8
+ class Placeholder {
9
+ static replacing(node) {
10
+ let placeholder = this.immediatelyAfter(node);
11
+ node.parentElement.removeChild(node);
12
+ return placeholder;
13
+ }
14
+ static immediatelyAfter(node) {
15
+ let document = node.ownerDocument;
16
+ let parent = node.parentElement;
17
+ if (!document || !parent) {
18
+ throw new Error('Cannot make Placeholder out of detached node');
19
+ }
20
+ let nextSibling = node.nextSibling;
21
+ let start = document.createTextNode('');
22
+ let end = document.createTextNode('');
23
+ parent.insertBefore(start, nextSibling);
24
+ parent.insertBefore(end, nextSibling);
25
+ return new Placeholder(start, end, node);
26
+ }
27
+ constructor(start, end, reference) {
28
+ this.start = start;
29
+ this.end = end;
30
+ this.reference = reference;
31
+ if (start.parentElement && start.parentElement === end.parentElement) {
32
+ this.parent = start.parentElement;
33
+ }
34
+ else {
35
+ throw new Error('Cannot make Placeholder out of detached node');
36
+ }
37
+ }
38
+ clear() {
39
+ let { start, end, parent } = this;
40
+ while (start.nextSibling && start.nextSibling !== end) {
41
+ parent.removeChild(start.nextSibling);
42
+ }
43
+ }
44
+ insert(node) {
45
+ this.parent.insertBefore(node, this.end);
46
+ }
47
+ }
48
+ class PreparedEmberHTML {
49
+ constructor(asset) {
50
+ this.asset = asset;
51
+ this.dom = new jsdom_1.JSDOM((0, fs_1.readFileSync)(asset.sourcePath, 'utf8'));
52
+ let html = asset.prepare(this.dom);
53
+ this.javascript = Placeholder.replacing(html.javascript);
54
+ this.styles = Placeholder.replacing(html.styles);
55
+ this.implicitScripts = Placeholder.replacing(html.implicitScripts);
56
+ this.implicitStyles = Placeholder.replacing(html.implicitStyles);
57
+ this.testJavascript = html.testJavascript
58
+ ? Placeholder.replacing(html.testJavascript)
59
+ : Placeholder.immediatelyAfter(this.javascript.end);
60
+ this.implicitTestScripts = html.implicitTestScripts
61
+ ? Placeholder.replacing(html.implicitTestScripts)
62
+ : Placeholder.immediatelyAfter(this.implicitScripts.end);
63
+ this.implicitTestStyles = html.implicitTestStyles
64
+ ? Placeholder.replacing(html.implicitTestStyles)
65
+ : Placeholder.immediatelyAfter(this.implicitStyles.end);
66
+ }
67
+ placeholders() {
68
+ return [
69
+ this.javascript,
70
+ this.styles,
71
+ this.implicitScripts,
72
+ this.implicitStyles,
73
+ this.implicitTestScripts,
74
+ this.implicitTestStyles,
75
+ this.testJavascript,
76
+ ];
77
+ }
78
+ clear() {
79
+ for (let range of this.placeholders()) {
80
+ range.clear();
81
+ }
82
+ }
83
+ // this takes the src relative to the application root, we adjust it so it's
84
+ // root-relative via the configured rootURL
85
+ insertScriptTag(placeholder, relativeSrc, { type, tag = 'script' } = {}) {
86
+ let document = this.dom.window.document;
87
+ let from = placeholder.reference.nodeType === 1 ? placeholder.reference : undefined;
88
+ let src = this.asset.rootURL + relativeSrc;
89
+ let attributes = type ? { src, type } : { src };
90
+ let newTag = (0, html_placeholder_1.makeTag)(document, { from, tag, attributes });
91
+ placeholder.insert(this.dom.window.document.createTextNode('\n'));
92
+ placeholder.insert(newTag);
93
+ }
94
+ // this takes the href relative to the application root, we adjust it so it's
95
+ // root-relative via the configured rootURL
96
+ insertStyleLink(placeholder, relativeHref) {
97
+ let document = this.dom.window.document;
98
+ let from = placeholder.reference.nodeType === 1 ? placeholder.reference : undefined;
99
+ let href = this.asset.rootURL + relativeHref;
100
+ let newTag = (0, html_placeholder_1.makeTag)(document, { from, tag: 'link', attributes: { href } });
101
+ (0, html_placeholder_1.normalizeStyleLink)(newTag);
102
+ placeholder.insert(this.dom.window.document.createTextNode('\n'));
103
+ placeholder.insert(newTag);
104
+ }
105
+ }
106
+ exports.PreparedEmberHTML = PreparedEmberHTML;
107
+ function insertNewline(at) {
108
+ at.parentElement.insertBefore(at.ownerDocument.createTextNode('\n'), at);
109
+ }
110
+ //# sourceMappingURL=ember-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ember-html.js","sourceRoot":"","sources":["ember-html.ts"],"names":[],"mappings":";;;AAqJA,sCAEC;AAvJD,iCAA8B;AAC9B,2BAAkC;AAElC,yDAAiE;AAyBjE,MAAM,WAAW;IACf,MAAM,CAAC,SAAS,CAAC,IAAU;QACzB,IAAI,WAAW,GAAG,IAAI,CAAC,g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IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1D,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,6EAA6E;IAC7E,2CAA2C;IAC3C,eAAe,CAAC,WAAwB,EAAE,YAAoB;QAC5D,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QACxC,IAAI,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAE,WAAW,CAAC,SAAyB,CAAC,CAAC,CAAC,SAAS,CAAC;QACrG,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC;QAC7C,IAAI,MAAM,GAAG,IAAA,0BAAO,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5E,IAAA,qCAAkB,EAAC,MAAM,CAAC,CAAC;QAC3B,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF;AAzED,8CAyEC;AAED,SAAgB,aAAa,CAAC,EAAQ;IACpC,EAAE,CAAC,aAAc,CAAC,YAAY,CAAC,EAAE,CAAC,aAAc,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { JSDOM } from 'jsdom';\nimport { readFileSync } from 'fs';\nimport type { EmberAsset } from './asset';\nimport { makeTag, normalizeStyleLink } from './html-placeholder';\n\nexport interface EmberHTML {\n // each of the Nodes in here points at where we should insert the\n // corresponding parts of the ember app. The Nodes themselves will be\n // replaced, so provide placeholders.\n\n // these are mandatory, the Ember app may need to put things into them.\n javascript: Node;\n styles: Node;\n implicitScripts: Node;\n implicitStyles: Node;\n\n // these are optional because you *may* choose to stick your implicit test\n // things into specific locations (which we need for backward-compat). But you\n // can leave these off and we will simply put them in the same places as the\n // non-test things.\n //\n // Do not confuse these with controlling whether or not we will insert tests.\n // That is separately controlled via `includeTests`.\n testJavascript?: Node;\n implicitTestScripts?: Node;\n implicitTestStyles?: Node;\n}\n\nclass Placeholder {\n static replacing(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n node.parentElement!.removeChild(node);\n return placeholder;\n }\n\n static immediatelyAfter(node: Node): Placeholder {\n let document = node.ownerDocument;\n let parent = node.parentElement;\n\n if (!document || !parent) {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n\n let nextSibling = node.nextSibling;\n let start = document.createTextNode('');\n let end = document.createTextNode('');\n\n parent.insertBefore(start, nextSibling);\n parent.insertBefore(end, nextSibling);\n return new Placeholder(start, end, node);\n }\n\n readonly parent: HTMLElement;\n\n constructor(readonly start: Node, readonly end: Node, readonly reference: Node) {\n if (start.parentElement && start.parentElement === end.parentElement) {\n this.parent = start.parentElement;\n } else {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n }\n\n clear() {\n let { start, end, parent } = this;\n while (start.nextSibling && start.nextSibling !== end) {\n parent.removeChild(start.nextSibling);\n }\n }\n\n insert(node: Node) {\n this.parent.insertBefore(node, this.end);\n }\n}\n\nexport class PreparedEmberHTML {\n dom: JSDOM;\n javascript: Placeholder;\n styles: Placeholder;\n implicitScripts: Placeholder;\n implicitStyles: Placeholder;\n testJavascript: Placeholder;\n implicitTestScripts: Placeholder;\n implicitTestStyles: Placeholder;\n\n constructor(private asset: EmberAsset) {\n this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));\n let html = asset.prepare(this.dom);\n this.javascript = Placeholder.replacing(html.javascript);\n this.styles = Placeholder.replacing(html.styles);\n this.implicitScripts = Placeholder.replacing(html.implicitScripts);\n this.implicitStyles = Placeholder.replacing(html.implicitStyles);\n this.testJavascript = html.testJavascript\n ? Placeholder.replacing(html.testJavascript)\n : Placeholder.immediatelyAfter(this.javascript.end);\n this.implicitTestScripts = html.implicitTestScripts\n ? Placeholder.replacing(html.implicitTestScripts)\n : Placeholder.immediatelyAfter(this.implicitScripts.end);\n this.implicitTestStyles = html.implicitTestStyles\n ? Placeholder.replacing(html.implicitTestStyles)\n : Placeholder.immediatelyAfter(this.implicitStyles.end);\n }\n\n private placeholders(): Placeholder[] {\n return [\n this.javascript,\n this.styles,\n this.implicitScripts,\n this.implicitStyles,\n this.implicitTestScripts,\n this.implicitTestStyles,\n this.testJavascript,\n ];\n }\n\n clear() {\n for (let range of this.placeholders()) {\n range.clear();\n }\n }\n\n // this takes the src relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertScriptTag(\n placeholder: Placeholder,\n relativeSrc: string,\n { type, tag = 'script' }: { type?: string; tag?: string } = {}\n ) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let src = this.asset.rootURL + relativeSrc;\n let attributes: Record<string, string> = type ? { src, type } : { src };\n let newTag = makeTag(document, { from, tag, attributes });\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n\n // this takes the href relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertStyleLink(placeholder: Placeholder, relativeHref: string) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let href = this.asset.rootURL + relativeHref;\n let newTag = makeTag(document, { from, tag: 'link', attributes: { href } });\n normalizeStyleLink(newTag);\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n}\n\nexport function insertNewline(at: Node) {\n at.parentElement!.insertBefore(at.ownerDocument!.createTextNode('\\n'), at);\n}\n"]}
package/src/index.d.ts CHANGED
@@ -1,14 +1,14 @@
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';
4
5
  export { default as Options, optionsWithDefaults } from './options';
6
+ export { default as toBroccoliPlugin } from './to-broccoli-plugin';
5
7
  export { default as WaitForTrees, OutputPaths } from './wait-for-trees';
6
8
  export { compile as jsHandlebarsCompile } from './js-handlebars';
7
9
  export { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';
8
- export { Resolver } from './module-resolver';
9
- export { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';
10
- export type { Options as ResolverOptions } from './module-resolver-options';
10
+ export { Resolver, Options as ResolverOptions, ModuleRequest, Resolution, ResolverFunction, SyncResolverFunction, } from './module-resolver';
11
11
  export { ResolverLoader } from './resolver-loader';
12
- export { virtualContent, type VirtualResponse } from './virtual-content';
12
+ export { virtualContent } from './virtual-content';
13
13
  export type { Engine } from './app-files';
14
14
  export * from '@embroider/shared-internals';
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.virtualContent = exports.ResolverLoader = exports.ModuleRequest = exports.Resolver = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.jsHandlebarsCompile = exports.WaitForTrees = exports.optionsWithDefaults = exports.HTMLEntrypoint = exports.getPackagerCacheDir = exports.getAppMeta = exports.applyVariantToBabelConfig = void 0;
20
+ exports.virtualContent = exports.ResolverLoader = exports.Resolver = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.jsHandlebarsCompile = exports.WaitForTrees = exports.toBroccoliPlugin = exports.optionsWithDefaults = exports.HTMLEntrypoint = exports.getPackagerCacheDir = exports.getAppMeta = exports.applyVariantToBabelConfig = void 0;
21
21
  var packager_1 = require("./packager");
22
22
  Object.defineProperty(exports, "applyVariantToBabelConfig", { enumerable: true, get: function () { return packager_1.applyVariantToBabelConfig; } });
23
23
  Object.defineProperty(exports, "getAppMeta", { enumerable: true, get: function () { return packager_1.getAppMeta; } });
@@ -26,6 +26,8 @@ var html_entrypoint_1 = require("./html-entrypoint");
26
26
  Object.defineProperty(exports, "HTMLEntrypoint", { enumerable: true, get: function () { return html_entrypoint_1.HTMLEntrypoint; } });
27
27
  var options_1 = require("./options");
28
28
  Object.defineProperty(exports, "optionsWithDefaults", { enumerable: true, get: function () { return options_1.optionsWithDefaults; } });
29
+ var to_broccoli_plugin_1 = require("./to-broccoli-plugin");
30
+ Object.defineProperty(exports, "toBroccoliPlugin", { enumerable: true, get: function () { return __importDefault(to_broccoli_plugin_1).default; } });
29
31
  var wait_for_trees_1 = require("./wait-for-trees");
30
32
  Object.defineProperty(exports, "WaitForTrees", { enumerable: true, get: function () { return __importDefault(wait_for_trees_1).default; } });
31
33
  var js_handlebars_1 = require("./js-handlebars");
@@ -39,8 +41,6 @@ Object.defineProperty(exports, "expectWarning", { enumerable: true, get: functio
39
41
  Object.defineProperty(exports, "throwOnWarnings", { enumerable: true, get: function () { return messages_1.throwOnWarnings; } });
40
42
  var module_resolver_1 = require("./module-resolver");
41
43
  Object.defineProperty(exports, "Resolver", { enumerable: true, get: function () { return module_resolver_1.Resolver; } });
42
- var module_request_1 = require("./module-request");
43
- Object.defineProperty(exports, "ModuleRequest", { enumerable: true, get: function () { return module_request_1.ModuleRequest; } });
44
44
  var resolver_loader_1 = require("./resolver-loader");
45
45
  Object.defineProperty(exports, "ResolverLoader", { enumerable: true, get: function () { return resolver_loader_1.ResolverLoader; } });
46
46
  var virtual_content_1 = require("./virtual-content");
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;AAEvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,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,qDAA6C;AAApC,2GAAA,QAAQ,OAAA;AACjB,mDAAkH;AAAzG,+GAAA,aAAa,OAAA;AAEtB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAyE;AAAhE,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 WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport { Resolver } from './module-resolver';\nexport { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';\nexport type { Options as ResolverOptions } from './module-resolver-options';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent, type VirtualResponse } 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;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"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path_1 = require("path");
4
4
  const fs_1 = require("fs");
5
+ const filesize_1 = require("filesize");
5
6
  class MeasureConcat {
6
7
  constructor(name, concat, baseDir) {
7
8
  this.name = name;
@@ -21,7 +22,7 @@ class MeasureConcat {
21
22
  console.log(`Concatenated ${this.name}:`);
22
23
  console.log(Object.entries(this.stats)
23
24
  .sort((a, b) => b[1] - a[1])
24
- .map(([name, bytes]) => ` ${name}: ${bytes} bytes`)
25
+ .map(([name, bytes]) => ` ${name}: ${(0, filesize_1.filesize)(bytes, {})}`)
25
26
  .join('\n'));
26
27
  return await this.concat.end();
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"measure-concat.js","sourceRoot":"","sources":["measure-concat.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAC5B,2BAA8B;AAE9B,MAAqB,aAAa;IAEhC,YAAoB,IAAY,EAAU,MAAuB,EAAU,OAAe;QAAtE,SAAI,GAAJ,IAAI,CAAQ;QAAU,WAAM,GAAN,MAAM,CAAiB;QAAU,YAAO,GAAP,OAAO,CAAQ;QAD1F,UAAK,GAAmC,EAAE,CAAC;IACkD,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`)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AAK,IAAI,KAAK,IAAA,mBAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;aAC3D,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';\nimport { filesize } from 'filesize';\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}: ${filesize(bytes, {})}`)\n .join('\\n')\n );\n return await this.concat.end();\n }\n}\n"]}