@embroider/core 3.5.1-unstable.fc482ba → 3.5.2

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 (68) hide show
  1. package/package.json +11 -22
  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 +5 -5
  12. package/src/index.js +4 -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/messages.js.map +1 -1
  17. package/src/module-resolver.d.ts +61 -24
  18. package/src/module-resolver.js +310 -469
  19. package/src/module-resolver.js.map +1 -1
  20. package/src/node-resolve.d.ts +6 -31
  21. package/src/node-resolve.js +44 -112
  22. package/src/node-resolve.js.map +1 -1
  23. package/src/options.d.ts +7 -0
  24. package/src/options.js +1 -0
  25. package/src/options.js.map +1 -1
  26. package/src/packager.d.ts +8 -0
  27. package/src/packager.js +9 -0
  28. package/src/packager.js.map +1 -1
  29. package/src/portable-babel-config.d.ts +11 -0
  30. package/src/portable-babel-config.js +132 -0
  31. package/src/portable-babel-config.js.map +1 -0
  32. package/src/portable-babel-launcher.d.ts +6 -0
  33. package/src/portable-babel-launcher.js +75 -0
  34. package/src/portable-babel-launcher.js.map +1 -0
  35. package/src/resolver-loader.js +1 -8
  36. package/src/resolver-loader.js.map +1 -1
  37. package/src/to-broccoli-plugin.d.ts +8 -0
  38. package/src/to-broccoli-plugin.js +30 -0
  39. package/src/to-broccoli-plugin.js.map +1 -0
  40. package/src/virtual-content.d.ts +12 -32
  41. package/src/virtual-content.js +184 -83
  42. package/src/virtual-content.js.map +1 -1
  43. package/src/module-request.d.ts +0 -44
  44. package/src/module-request.js +0 -100
  45. package/src/module-request.js.map +0 -1
  46. package/src/module-resolver-options.d.ts +0 -42
  47. package/src/module-resolver-options.js +0 -164
  48. package/src/module-resolver-options.js.map +0 -1
  49. package/src/virtual-entrypoint.d.ts +0 -21
  50. package/src/virtual-entrypoint.js +0 -273
  51. package/src/virtual-entrypoint.js.map +0 -1
  52. package/src/virtual-route-entrypoint.d.ts +0 -10
  53. package/src/virtual-route-entrypoint.js +0 -62
  54. package/src/virtual-route-entrypoint.js.map +0 -1
  55. package/src/virtual-test-support-styles.d.ts +0 -7
  56. package/src/virtual-test-support-styles.js +0 -61
  57. package/src/virtual-test-support-styles.js.map +0 -1
  58. package/src/virtual-test-support.d.ts +0 -7
  59. package/src/virtual-test-support.js +0 -65
  60. package/src/virtual-test-support.js.map +0 -1
  61. package/src/virtual-vendor-styles.d.ts +0 -8
  62. package/src/virtual-vendor-styles.js +0 -83
  63. package/src/virtual-vendor-styles.js.map +0 -1
  64. package/src/virtual-vendor.d.ts +0 -7
  65. package/src/virtual-vendor.js +0 -53
  66. package/src/virtual-vendor.js.map +0 -1
  67. package/types/virtual/index.d.ts +0 -9
  68. package/types/virtual/index.js +0 -3
@@ -14,7 +14,6 @@ var _ResolverLoader_resolver, _ResolverLoader_configFile, _ResolverLoader_watche
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ResolverLoader = void 0;
16
16
  const fs_extra_1 = require("fs-extra");
17
- const module_resolver_options_1 = require("./module-resolver-options");
18
17
  const module_resolver_1 = require("./module-resolver");
19
18
  const shared_internals_1 = require("@embroider/shared-internals");
20
19
  const path_1 = require("path");
@@ -38,13 +37,7 @@ class ResolverLoader {
38
37
  }
39
38
  get resolver() {
40
39
  if (!__classPrivateFieldGet(this, _ResolverLoader_resolver, "f")) {
41
- let config;
42
- if ((0, fs_extra_1.existsSync)(__classPrivateFieldGet(this, _ResolverLoader_configFile, "f"))) {
43
- config = (0, fs_extra_1.readJSONSync)(__classPrivateFieldGet(this, _ResolverLoader_configFile, "f"));
44
- }
45
- else {
46
- config = (0, module_resolver_options_1.buildResolverOptions)({});
47
- }
40
+ let config = (0, fs_extra_1.readJSONSync)((0, path_1.join)((0, shared_internals_1.locateEmbroiderWorkingDir)(this.appRoot), 'resolver.json'));
48
41
  __classPrivateFieldSet(this, _ResolverLoader_resolver, new module_resolver_1.Resolver(config), "f");
49
42
  }
50
43
  return __classPrivateFieldGet(this, _ResolverLoader_resolver, "f");
@@ -1 +1 @@
1
- {"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAoD;AACpD,uEAA+E;AAC/E,uDAA6C;AAC7C,kEAAwE;AACxE,+BAA4B;AAE5B,2BAAsC;AAEtC,MAAa,cAAc;IAKzB,YAAqB,OAAe,EAAE,KAAK,GAAG,KAAK;QAA9B,YAAO,GAAP,OAAO,CAAQ;QAJpC,2CAAgC;QAChC,6CAAoB;QACpB,0CAAgC;QAG9B,uBAAA,IAAI,8BAAe,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,MAAA,CAAC;QAClF,IAAI,KAAK,EAAE,CAAC;YACV,uBAAA,IAAI,2BAAY,IAAA,UAAO,EAAC,uBAAA,IAAI,kCAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE;gBACpE,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;YAC7B,CAAC,CAAC,MAAA,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK;;QACH,MAAA,uBAAA,IAAI,+BAAS,0CAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,uBAAA,IAAI,gCAAU,EAAE,CAAC;YACpB,IAAI,MAAe,CAAC;YACpB,IAAI,IAAA,qBAAU,EAAC,uBAAA,IAAI,kCAAY,CAAC,EAAE,CAAC;gBACjC,MAAM,GAAG,IAAA,uBAAY,EAAC,uBAAA,IAAI,kCAAY,CAAC,CAAC;YAC1C,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,IAAA,8CAAoB,EAAC,EAAE,CAAC,CAAC;YACpC,CAAC;YACD,uBAAA,IAAI,4BAAa,IAAI,0BAAQ,CAAC,MAAM,CAAC,MAAA,CAAC;QACxC,CAAC;QACD,OAAO,uBAAA,IAAI,gCAAU,CAAC;IACxB,CAAC;CACF;AA9BD,wCA8BC","sourcesContent":["import { existsSync, readJSONSync } from 'fs-extra';\nimport { buildResolverOptions, type Options } from './module-resolver-options';\nimport { Resolver } from './module-resolver';\nimport { locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport { join } from 'path';\nimport type { FSWatcher } from 'fs';\nimport { watch as fsWatch } from 'fs';\n\nexport class ResolverLoader {\n #resolver: Resolver | undefined;\n #configFile: string;\n #watcher: FSWatcher | undefined;\n\n constructor(readonly appRoot: string, watch = false) {\n this.#configFile = join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json');\n if (watch) {\n this.#watcher = fsWatch(this.#configFile, { persistent: false }, () => {\n this.#resolver = undefined;\n });\n }\n }\n\n close() {\n this.#watcher?.close();\n }\n\n get resolver(): Resolver {\n if (!this.#resolver) {\n let config: Options;\n if (existsSync(this.#configFile)) {\n config = readJSONSync(this.#configFile);\n } else {\n config = buildResolverOptions({});\n }\n this.#resolver = new Resolver(config);\n }\n return this.#resolver;\n }\n}\n"]}
1
+ {"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAwC;AAExC,uDAA6C;AAC7C,kEAAwE;AACxE,+BAA4B;AAE5B,2BAAsC;AAEtC,MAAa,cAAc;IAKzB,YAAqB,OAAe,EAAE,KAAK,GAAG,KAAK;QAA9B,YAAO,GAAP,OAAO,CAAQ;QAJpC,2CAAgC;QAChC,6CAAoB;QACpB,0CAAgC;QAG9B,uBAAA,IAAI,8BAAe,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,MAAA,CAAC;QAClF,IAAI,KAAK,EAAE,CAAC;YACV,uBAAA,IAAI,2BAAY,IAAA,UAAO,EAAC,uBAAA,IAAI,kCAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE;gBACpE,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;YAC7B,CAAC,CAAC,MAAA,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK;;QACH,MAAA,uBAAA,IAAI,+BAAS,0CAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,uBAAA,IAAI,gCAAU,EAAE,CAAC;YACpB,IAAI,MAAM,GAAY,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YACnG,uBAAA,IAAI,4BAAa,IAAI,0BAAQ,CAAC,MAAM,CAAC,MAAA,CAAC;QACxC,CAAC;QACD,OAAO,uBAAA,IAAI,gCAAU,CAAC;IACxB,CAAC;CACF;AAzBD,wCAyBC","sourcesContent":["import { readJSONSync } from 'fs-extra';\nimport type { Options } from './module-resolver';\nimport { Resolver } from './module-resolver';\nimport { locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport { join } from 'path';\nimport type { FSWatcher } from 'fs';\nimport { watch as fsWatch } from 'fs';\n\nexport class ResolverLoader {\n #resolver: Resolver | undefined;\n #configFile: string;\n #watcher: FSWatcher | undefined;\n\n constructor(readonly appRoot: string, watch = false) {\n this.#configFile = join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json');\n if (watch) {\n this.#watcher = fsWatch(this.#configFile, { persistent: false }, () => {\n this.#resolver = undefined;\n });\n }\n }\n\n close() {\n this.#watcher?.close();\n }\n\n get resolver(): Resolver {\n if (!this.#resolver) {\n let config: Options = readJSONSync(join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json'));\n this.#resolver = new Resolver(config);\n }\n return this.#resolver;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import Plugin from 'broccoli-plugin';
2
+ import type { PackagerConstructor, Variant } from './packager';
3
+ import type Stage from './stage';
4
+ interface BroccoliPackager<Options> {
5
+ new (stage: Stage, variants: Variant[], options?: Options): Plugin;
6
+ }
7
+ export default function toBroccoliPlugin<Options>(packagerClass: PackagerConstructor<Options>): BroccoliPackager<Options>;
8
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = toBroccoliPlugin;
7
+ const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
8
+ const shared_internals_1 = require("@embroider/shared-internals");
9
+ function toBroccoliPlugin(packagerClass) {
10
+ class PackagerRunner extends broccoli_plugin_1.default {
11
+ constructor(stage, variants, options) {
12
+ super([stage.tree], {
13
+ persistentOutput: true,
14
+ needsCache: false,
15
+ annotation: packagerClass.annotation,
16
+ });
17
+ this.stage = stage;
18
+ this.variants = variants;
19
+ this.options = options;
20
+ }
21
+ async build() {
22
+ if (!this.packager) {
23
+ this.packager = new packagerClass(this.stage.inputPath, this.outputPath, this.variants, msg => console.log(msg.split(shared_internals_1.tmpdir).join('$TMPDIR')), this.options);
24
+ }
25
+ return this.packager.build();
26
+ }
27
+ }
28
+ return PackagerRunner;
29
+ }
30
+ //# sourceMappingURL=to-broccoli-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-broccoli-plugin.js","sourceRoot":"","sources":["to-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AASA,mCA2BC;AApCD,sEAAqC;AAGrC,kEAAqD;AAMrD,SAAwB,gBAAgB,CACtC,aAA2C;IAE3C,MAAM,cAAe,SAAQ,yBAAM;QAEjC,YAAoB,KAAY,EAAU,QAAmB,EAAU,OAAiB;YACtF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAClB,gBAAgB,EAAE,IAAI;gBACtB,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;YALe,UAAK,GAAL,KAAK,CAAO;YAAU,aAAQ,GAAR,QAAQ,CAAW;YAAU,YAAO,GAAP,OAAO,CAAU;QAMxF,CAAC;QAED,KAAK,CAAC,KAAK;YACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,EACpB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,QAAQ,EACb,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EACrD,IAAI,CAAC,OAAO,CACb,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Packager, PackagerConstructor, Variant } from './packager';\nimport type Stage from './stage';\nimport { tmpdir } from '@embroider/shared-internals';\n\ninterface BroccoliPackager<Options> {\n new (stage: Stage, variants: Variant[], options?: Options): Plugin;\n}\n\nexport default function toBroccoliPlugin<Options>(\n packagerClass: PackagerConstructor<Options>\n): BroccoliPackager<Options> {\n class PackagerRunner extends Plugin {\n private packager: Packager | undefined;\n constructor(private stage: Stage, private variants: Variant[], private options?: Options) {\n super([stage.tree], {\n persistentOutput: true,\n needsCache: false,\n annotation: packagerClass.annotation,\n });\n }\n\n async build() {\n if (!this.packager) {\n this.packager = new packagerClass(\n this.stage.inputPath,\n this.outputPath,\n this.variants,\n msg => console.log(msg.split(tmpdir).join('$TMPDIR')),\n this.options\n );\n }\n return this.packager.build();\n }\n }\n return PackagerRunner;\n}\n"]}
@@ -1,35 +1,15 @@
1
1
  import type { Resolver } from '.';
2
- import { type TestSupportResponse } from './virtual-test-support';
3
- import { type TestSupportStylesResponse } from './virtual-test-support-styles';
4
- import { type VirtualVendorResponse } from './virtual-vendor';
5
- import { type VirtualVendorStylesResponse } from './virtual-vendor-styles';
6
- import { type EntrypointResponse } from './virtual-entrypoint';
7
- import { type RouteEntrypointResponse } from './virtual-route-entrypoint';
8
- export type VirtualResponse = {
9
- specifier: string;
10
- } & (FastbootSwitchResponse | ImplicitModulesResponse | EntrypointResponse | RouteEntrypointResponse | TestSupportResponse | TestSupportStylesResponse | VirtualVendorResponse | VirtualVendorStylesResponse | VirtualPairResponse | TemplateOnlyComponentResponse);
11
- export interface VirtualContentResult {
12
- src: string;
13
- watches: string[];
14
- }
15
- export declare function virtualContent(response: VirtualResponse, resolver: Resolver): VirtualContentResult;
16
- export interface VirtualPairResponse {
17
- type: 'component-pair';
18
- specifier: string;
19
- hbsModule: string;
20
- jsModule: string | null;
21
- debugName: string;
22
- }
23
- interface FastbootSwitchResponse {
24
- type: 'fastboot-switch';
25
- names: Set<string>;
26
- }
27
- export interface ImplicitModulesResponse {
2
+ export declare function virtualContent(filename: string, resolver: Resolver): string;
3
+ export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
4
+ export declare function virtualExternalCJSModule(specifier: string): string;
5
+ export declare function virtualPairComponent(hbsModule: string, jsModule: string | null): string;
6
+ export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
7
+ export declare function decodeFastbootSwitch(filename: string): {
8
+ names: string[];
9
+ hasDefaultExport: boolean;
10
+ filename: string;
11
+ } | undefined;
12
+ export declare function decodeImplicitModules(filename: string): {
28
13
  type: 'implicit-modules' | 'implicit-test-modules';
29
14
  fromFile: string;
30
- }
31
- export interface TemplateOnlyComponentResponse {
32
- type: 'template-only-component-js';
33
- specifier: string;
34
- }
35
- export {};
15
+ } | undefined;
@@ -1,59 +1,71 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.virtualContent = virtualContent;
4
+ exports.virtualExternalESModule = virtualExternalESModule;
5
+ exports.virtualExternalCJSModule = virtualExternalCJSModule;
6
+ exports.virtualPairComponent = virtualPairComponent;
7
+ exports.fastbootSwitch = fastbootSwitch;
8
+ exports.decodeFastbootSwitch = decodeFastbootSwitch;
9
+ exports.decodeImplicitModules = decodeImplicitModules;
7
10
  const path_1 = require("path");
8
11
  const _1 = require(".");
9
12
  const js_handlebars_1 = require("./js-handlebars");
10
- const virtual_test_support_1 = require("./virtual-test-support");
11
- const virtual_test_support_styles_1 = require("./virtual-test-support-styles");
12
- const virtual_vendor_1 = require("./virtual-vendor");
13
- const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
14
- const virtual_entrypoint_1 = require("./virtual-entrypoint");
15
- const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
16
- const assert_never_1 = __importDefault(require("assert-never"));
13
+ const externalESPrefix = '/@embroider/ext-es/';
14
+ const externalCJSPrefix = '/@embroider/ext-cjs/';
17
15
  // Given a filename that was passed to your ModuleRequest's `virtualize()`,
18
16
  // this produces the corresponding contents. It's a static, stateless function
19
17
  // because we recognize that that process that did resolution might not be the
20
18
  // same one that loads the content.
21
- function virtualContent(response, resolver) {
22
- switch (response.type) {
23
- case 'entrypoint':
24
- return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, response);
25
- case 'vendor-js':
26
- return (0, virtual_vendor_1.renderVendor)(response, resolver);
27
- case 'vendor-css':
28
- return (0, virtual_vendor_styles_1.renderVendorStyles)(response, resolver);
29
- case 'test-support-css':
30
- return (0, virtual_test_support_styles_1.renderTestSupportStyles)(response, resolver);
31
- case 'test-support-js':
32
- return (0, virtual_test_support_1.renderImplicitTestScripts)(response, resolver);
33
- case 'component-pair':
34
- return pairedComponentShim(response);
35
- case 'implicit-modules':
36
- case 'implicit-test-modules':
37
- return renderImplicitModules(response, resolver);
38
- case 'route-entrypoint':
39
- return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(response, resolver);
40
- case 'fastboot-switch':
41
- return renderFastbootSwitchTemplate(response);
42
- case 'template-only-component-js':
43
- return renderTemplateOnlyComponent(response);
44
- default:
45
- throw (0, assert_never_1.default)(response);
46
- }
47
- }
48
- function pairedComponentShim(params) {
49
- return {
50
- src: pairedComponentShimTemplate(params),
51
- watches: [],
52
- };
19
+ function virtualContent(filename, resolver) {
20
+ let cjsExtern = decodeVirtualExternalCJSModule(filename);
21
+ if (cjsExtern) {
22
+ return renderCJSExternalShim(cjsExtern);
23
+ }
24
+ let extern = decodeVirtualExternalESModule(filename);
25
+ if (extern) {
26
+ return renderESExternalShim(extern);
27
+ }
28
+ let match = decodeVirtualPairComponent(filename);
29
+ if (match) {
30
+ return pairedComponentShim(match);
31
+ }
32
+ let fb = decodeFastbootSwitch(filename);
33
+ if (fb) {
34
+ return fastbootSwitchTemplate(fb);
35
+ }
36
+ let im = decodeImplicitModules(filename);
37
+ if (im) {
38
+ return renderImplicitModules(im, resolver);
39
+ }
40
+ throw new Error(`not an @embroider/core virtual file: ${filename}`);
41
+ }
42
+ const externalESShim = (0, js_handlebars_1.compile)(`
43
+ {{#if (eq moduleName "require")}}
44
+ const m = window.requirejs;
45
+ export default m;
46
+ const has = m.has;
47
+ export { has }
48
+ {{else}}
49
+ const m = window.require("{{{js-string-escape moduleName}}}");
50
+ {{#if default}}
51
+ export default m.default;
52
+ {{/if}}
53
+ {{#if names}}
54
+ const { {{#each names as |name|}}{{name}}, {{/each}} } = m;
55
+ export { {{#each names as |name|}}{{name}}, {{/each}} }
56
+ {{/if}}
57
+ {{/if}}
58
+ `);
59
+ function renderESExternalShim({ moduleName, exports }) {
60
+ return externalESShim({
61
+ moduleName,
62
+ default: exports.includes('default'),
63
+ names: exports.filter(n => n !== 'default'),
64
+ });
53
65
  }
54
- const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
66
+ const pairedComponentShim = (0, js_handlebars_1.compile)(`
55
67
  import { setComponentTemplate } from "@ember/component";
56
- import template from "{{{js-string-escape hbsModule}}}";
68
+ import template from "{{{js-string-escape relativeHBSModule}}}";
57
69
  import { deprecate } from "@ember/debug";
58
70
 
59
71
 
@@ -70,23 +82,96 @@ deprecate("Components with separately resolved templates are deprecated. Migrate
70
82
  }
71
83
  );
72
84
 
73
- {{#if jsModule}}
74
- import component from "{{{js-string-escape jsModule}}}";
85
+ {{#if relativeJSModule}}
86
+ import component from "{{{js-string-escape relativeJSModule}}}";
75
87
  export default setComponentTemplate(template, component);
76
88
  {{else}}
77
89
  import templateOnlyComponent from "@ember/component/template-only";
78
90
  export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
79
91
  {{/if}}
80
92
  `);
81
- function renderFastbootSwitchTemplate(params) {
93
+ function virtualExternalESModule(specifier, exports) {
94
+ if (exports) {
95
+ return externalESPrefix + specifier + `?exports=${exports.join(',')}`;
96
+ }
97
+ else {
98
+ return externalESPrefix + specifier;
99
+ }
100
+ }
101
+ function virtualExternalCJSModule(specifier) {
102
+ return externalCJSPrefix + specifier;
103
+ }
104
+ function decodeVirtualExternalESModule(filename) {
105
+ if (filename.startsWith(externalESPrefix)) {
106
+ let exports = [];
107
+ let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');
108
+ let nameString = url.searchParams.get('exports');
109
+ if (nameString) {
110
+ exports = nameString.split(',');
111
+ }
112
+ let moduleName = url.pathname.slice(1);
113
+ return { moduleName, exports };
114
+ }
115
+ }
116
+ function decodeVirtualExternalCJSModule(filename) {
117
+ if (filename.startsWith(externalCJSPrefix)) {
118
+ return { moduleName: filename.slice(externalCJSPrefix.length) };
119
+ }
120
+ }
121
+ const pairComponentMarker = '-embroider-pair-component';
122
+ const pairComponentPattern = /^(?<hbsModule>.*)\/(?<jsModule>[^\/]*)-embroider-pair-component$/;
123
+ function virtualPairComponent(hbsModule, jsModule) {
124
+ let relativeJSModule = '';
125
+ if (jsModule) {
126
+ relativeJSModule = (0, _1.explicitRelative)(hbsModule, jsModule);
127
+ }
128
+ return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;
129
+ }
130
+ function decodeVirtualPairComponent(filename) {
131
+ // Performance: avoid paying regex exec cost unless needed
132
+ if (!filename.includes(pairComponentMarker)) {
133
+ return null;
134
+ }
135
+ let match = pairComponentPattern.exec(filename);
136
+ if (!match) {
137
+ return null;
138
+ }
139
+ let { hbsModule, jsModule } = match.groups;
140
+ // target our real hbs module from our virtual module
141
+ let relativeHBSModule = (0, _1.explicitRelative)((0, path_1.dirname)(filename), hbsModule);
82
142
  return {
83
- src: fastbootSwitchTemplate({
84
- names: [...params.names].filter(name => name !== 'default'),
85
- hasDefaultExport: params.names.has('default'),
86
- }),
87
- watches: [],
143
+ relativeHBSModule,
144
+ relativeJSModule: decodeURIComponent(jsModule) || null,
145
+ debugName: (0, path_1.basename)(relativeHBSModule).replace(/\.(js|hbs)$/, ''),
88
146
  };
89
147
  }
148
+ const fastbootSwitchSuffix = '/embroider_fastboot_switch';
149
+ const fastbootSwitchPattern = /(?<original>.+)\/embroider_fastboot_switch(?:\?names=(?<names>.+))?$/;
150
+ function fastbootSwitch(specifier, fromFile, names) {
151
+ let filename = `${(0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier)}${fastbootSwitchSuffix}`;
152
+ if (names.size > 0) {
153
+ return `${filename}?names=${[...names].join(',')}`;
154
+ }
155
+ else {
156
+ return filename;
157
+ }
158
+ }
159
+ function decodeFastbootSwitch(filename) {
160
+ var _a, _b, _c;
161
+ // Performance: avoid paying regex exec cost unless needed
162
+ if (!filename.includes(fastbootSwitchSuffix)) {
163
+ return;
164
+ }
165
+ let match = fastbootSwitchPattern.exec(filename);
166
+ if (match) {
167
+ let names = (_c = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.names) === null || _b === void 0 ? void 0 : _b.split(',')) !== null && _c !== void 0 ? _c : [];
168
+ return {
169
+ names: names.filter(name => name !== 'default'),
170
+ hasDefaultExport: names.includes('default'),
171
+ filename: match.groups.original,
172
+ };
173
+ }
174
+ }
90
175
  const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
91
176
  import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
92
177
  let mod;
@@ -102,14 +187,28 @@ export default mod.default;
102
187
  export const {{name}} = mod.{{name}};
103
188
  {{/each}}
104
189
  `);
105
- function renderImplicitModules({ type, fromFile }, resolver) {
190
+ const implicitModulesPattern = /(?<filename>.*)[\\/]-embroider-implicit-(?<test>test-)?modules\.js$/;
191
+ function decodeImplicitModules(filename) {
192
+ // Performance: avoid paying regex exec cost unless needed
193
+ if (!filename.includes('-embroider-implicit-')) {
194
+ return;
195
+ }
196
+ let m = implicitModulesPattern.exec(filename);
197
+ if (m) {
198
+ return {
199
+ type: m.groups.test ? 'implicit-test-modules' : 'implicit-modules',
200
+ fromFile: m.groups.filename,
201
+ };
202
+ }
203
+ }
204
+ function renderImplicitModules({ type, fromFile, }, resolver) {
106
205
  let resolvableExtensionsPattern = (0, _1.extensionsPattern)(resolver.options.resolvableExtensions);
107
206
  const pkg = resolver.packageCache.ownerOfFile(fromFile);
108
207
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
109
208
  throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
110
209
  }
111
- let ownModules = [];
112
- let dependencyModules = [];
210
+ let lazyModules = [];
211
+ let eagerModules = [];
113
212
  let deps = pkg.dependencies.sort(orderAddons);
114
213
  for (let dep of deps) {
115
214
  // anything that isn't a v2 ember package by this point is not an active
@@ -142,7 +241,7 @@ function renderImplicitModules({ type, fromFile }, resolver) {
142
241
  runtime = renamedModules[runtimeRenameLookup];
143
242
  }
144
243
  runtime = runtime.split(path_1.sep).join('/');
145
- ownModules.push({
244
+ lazyModules.push({
146
245
  runtime,
147
246
  buildtime: path_1.posix.join(packageName, name),
148
247
  });
@@ -151,32 +250,20 @@ function renderImplicitModules({ type, fromFile }, resolver) {
151
250
  // we don't recurse across an engine boundary. Engines import their own
152
251
  // implicit-modules.
153
252
  if (!dep.isEngine()) {
154
- dependencyModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
253
+ eagerModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
155
254
  }
156
255
  }
157
- return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };
256
+ return implicitModulesTemplate({ lazyModules, eagerModules });
158
257
  }
159
258
  const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
160
-
161
-
162
- {{#each dependencyModules as |module index|}}
163
- import dep{{index}} from "{{js-string-escape module}}";
259
+ import { importSync as i } from '@embroider/macros';
260
+ let d = window.define;
261
+ {{#each lazyModules as |module|}}
262
+ d("{{js-string-escape module.runtime}}", function(){ return i("{{js-string-escape module.buildtime}}");});
164
263
  {{/each}}
165
-
166
- {{#each ownModules as |module index|}}
167
- import * as own{{index}} from "{{js-string-escape module.buildtime}}";
264
+ {{#each eagerModules as |module|}}
265
+ import "{{js-string-escape module}}";
168
266
  {{/each}}
169
-
170
- export default Object.assign({},
171
- {{#each dependencyModules as |module index|}}
172
- dep{{index}},
173
- {{/each}}
174
- {
175
- {{#each ownModules as |module index|}}
176
- "{{js-string-escape module.runtime}}": own{{index}},
177
- {{/each}}
178
- }
179
- );
180
267
  `);
181
268
  // meta['renamed-modules'] has mapping from classic filename to real filename.
182
269
  // This takes that and converts it to the inverst mapping from real import path
@@ -202,12 +289,26 @@ function orderAddons(depA, depB) {
202
289
  }
203
290
  return depAIdx - depBIdx;
204
291
  }
205
- function renderTemplateOnlyComponent({ specifier }) {
206
- let watches = [specifier];
207
- let hbs = (0, _1.syntheticJStoHBS)(specifier);
208
- if (hbs) {
209
- watches.push(hbs);
210
- }
211
- return { src: (0, _1.templateOnlyComponentSource)(), watches };
292
+ const renderCJSExternalShim = (0, js_handlebars_1.compile)(`
293
+ {{#if (eq moduleName "require")}}
294
+ const m = window.requirejs;
295
+ {{else}}
296
+ const m = window.require("{{{js-string-escape moduleName}}}");
297
+ {{/if}}
298
+ {{!-
299
+ There are plenty of hand-written AMD defines floating around
300
+ that lack this, and they will break when other build systems
301
+ encounter them.
302
+
303
+ As far as I can tell, Ember's loader was already treating this
304
+ case as a module, so in theory we aren't breaking anything by
305
+ marking it as such when other packagers come looking.
306
+
307
+ todo: get review on this part.
308
+ -}}
309
+ if (m.default && !m.__esModule) {
310
+ m.__esModule = true;
212
311
  }
312
+ module.exports = m;
313
+ `);
213
314
  //# sourceMappingURL=virtual-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;;;;AAmCA,wCA0BC;AA7DD,+BAAwC;AAExC,wBAAqF;AACrF,mDAA0C;AAC1C,iEAA6F;AAC7F,+EAAwG;AACxG,qDAA4E;AAC5E,mEAA+F;AAE/F,6DAAiF;AACjF,yEAAiG;AACjG,gEAAuC;AAoBvC,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAyB,EAAE,QAAkB;IAC1E,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,YAAY;YACf,OAAO,IAAA,qCAAgB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9C,KAAK,WAAW;YACd,OAAO,IAAA,6BAAY,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1C,KAAK,YAAY;YACf,OAAO,IAAA,0CAAkB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,KAAK,kBAAkB;YACrB,OAAO,IAAA,qDAAuB,EAAC,Q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AS,CAAC,CAAC;IACtC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAA,8BAA2B,GAAE,EAAE,OAAO,EAAE,CAAC;AACzD,CAAC","sourcesContent":["import { posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { extensionsPattern, syntheticJStoHBS, templateOnlyComponentSource } from '.';\nimport { compile } from './js-handlebars';\nimport { renderImplicitTestScripts, type TestSupportResponse } from './virtual-test-support';\nimport { renderTestSupportStyles, type TestSupportStylesResponse } from './virtual-test-support-styles';\nimport { renderVendor, type VirtualVendorResponse } from './virtual-vendor';\nimport { renderVendorStyles, type VirtualVendorStylesResponse } from './virtual-vendor-styles';\n\nimport { type EntrypointResponse, renderEntrypoint } from './virtual-entrypoint';\nimport { renderRouteEntrypoint, type RouteEntrypointResponse } from './virtual-route-entrypoint';\nimport assertNever from 'assert-never';\n\nexport type VirtualResponse = { specifier: string } & (\n | FastbootSwitchResponse\n | ImplicitModulesResponse\n | EntrypointResponse\n | RouteEntrypointResponse\n | TestSupportResponse\n | TestSupportStylesResponse\n | VirtualVendorResponse\n | VirtualVendorStylesResponse\n | VirtualPairResponse\n | TemplateOnlyComponentResponse\n);\n\nexport interface VirtualContentResult {\n src: string;\n watches: string[];\n}\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(response: VirtualResponse, resolver: Resolver): VirtualContentResult {\n switch (response.type) {\n case 'entrypoint':\n return renderEntrypoint(resolver, response);\n case 'vendor-js':\n return renderVendor(response, resolver);\n case 'vendor-css':\n return renderVendorStyles(response, resolver);\n case 'test-support-css':\n return renderTestSupportStyles(response, resolver);\n case 'test-support-js':\n return renderImplicitTestScripts(response, resolver);\n case 'component-pair':\n return pairedComponentShim(response);\n case 'implicit-modules':\n case 'implicit-test-modules':\n return renderImplicitModules(response, resolver);\n case 'route-entrypoint':\n return renderRouteEntrypoint(response, resolver);\n case 'fastboot-switch':\n return renderFastbootSwitchTemplate(response);\n case 'template-only-component-js':\n return renderTemplateOnlyComponent(response);\n default:\n throw assertNever(response);\n }\n}\n\ninterface PairedComponentShimParams {\n hbsModule: string;\n jsModule: string | null;\n debugName: string;\n}\n\nfunction pairedComponentShim(params: PairedComponentShimParams): VirtualContentResult {\n return {\n src: pairedComponentShimTemplate(params),\n watches: [],\n };\n}\n\nconst pairedComponentShimTemplate = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape hbsModule}}}\";\nimport { deprecate } from \"@ember/debug\";\n\n\ndeprecate(\"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '{{debugName}}'.\",\n false, {\n id: 'component-template-resolving',\n url: 'https://deprecations.emberjs.com/id/component-template-resolving',\n until: '6.0.0',\n for: 'ember-source',\n since: {\n available: '5.10.0',\n enabled: '5.10.0',\n },\n }\n);\n\n{{#if jsModule}}\nimport component from \"{{{js-string-escape jsModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: PairedComponentShimParams) => string;\n\nexport interface VirtualPairResponse {\n type: 'component-pair';\n specifier: string;\n hbsModule: string;\n jsModule: string | null;\n debugName: string;\n}\n\ninterface FastbootSwitchResponse {\n type: 'fastboot-switch';\n names: Set<string>;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchResponse): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate({\n names: [...params.names].filter(name => name !== 'default'),\n hasDefaultExport: params.names.has('default'),\n }),\n watches: [],\n };\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: { names: string[]; hasDefaultExport: boolean }) => string;\n\nexport interface ImplicitModulesResponse {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n}\n\nfunction renderImplicitModules({ type, fromFile }: ImplicitModulesResponse, resolver: Resolver): VirtualContentResult {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let ownModules: { runtime: string; buildtime: string }[] = [];\n let dependencyModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n ownModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n dependencyModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };\n}\n\nconst implicitModulesTemplate = compile(`\n\n\n{{#each dependencyModules as |module index|}}\n import dep{{index}} from \"{{js-string-escape module}}\";\n{{/each}}\n\n{{#each ownModules as |module index|}}\n import * as own{{index}} from \"{{js-string-escape module.buildtime}}\";\n{{/each}}\n\nexport default Object.assign({},\n {{#each dependencyModules as |module index|}}\n dep{{index}},\n {{/each}}\n {\n {{#each ownModules as |module index|}}\n \"{{js-string-escape module.runtime}}\": own{{index}},\n {{/each}}\n }\n);\n`) as (params: { dependencyModules: string[]; ownModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nexport interface TemplateOnlyComponentResponse {\n type: 'template-only-component-js';\n specifier: string;\n}\n\nfunction renderTemplateOnlyComponent({ specifier }: TemplateOnlyComponentResponse): VirtualContentResult {\n let watches = [specifier];\n let hbs = syntheticJStoHBS(specifier);\n if (hbs) {\n watches.push(hbs);\n }\n return { src: templateOnlyComponentSource(), watches };\n}\n"]}
1
+ {"version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,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;;;;;;CAqBrC,CAA+C,CAAC","sourcesContent":["import { dirname, basename, resolve, posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\n\nconst externalESPrefix = '/@embroider/ext-es/';\nconst externalCJSPrefix = '/@embroider/ext-cjs/';\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(filename: string, resolver: Resolver): string {\n let cjsExtern = decodeVirtualExternalCJSModule(filename);\n if (cjsExtern) {\n return renderCJSExternalShim(cjsExtern);\n }\n\n let extern = decodeVirtualExternalESModule(filename);\n if (extern) {\n return renderESExternalShim(extern);\n }\n let match = decodeVirtualPairComponent(filename);\n if (match) {\n return pairedComponentShim(match);\n }\n\n let fb = decodeFastbootSwitch(filename);\n if (fb) {\n return fastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\nconst externalESShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\nexport default m;\nconst has = m.has;\nexport { has }\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{#if default}}\nexport default m.default;\n{{/if}}\n{{#if names}}\nconst { {{#each names as |name|}}{{name}}, {{/each}} } = m;\nexport { {{#each names as |name|}}{{name}}, {{/each}} }\n{{/if}}\n{{/if}}\n`) as (params: { moduleName: string; default: boolean; names: string[] }) => string;\n\nfunction renderESExternalShim({ moduleName, exports }: { moduleName: string; exports: string[] }): string {\n return externalESShim({\n moduleName,\n default: exports.includes('default'),\n names: exports.filter(n => n !== 'default'),\n });\n}\n\nconst pairedComponentShim = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape relativeHBSModule}}}\";\nimport { deprecate } from \"@ember/debug\";\n\n\ndeprecate(\"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '{{debugName}}'.\",\n false, {\n id: 'component-template-resolving',\n url: 'https://deprecations.emberjs.com/id/component-template-resolving',\n until: '6.0.0',\n for: 'ember-source',\n since: {\n available: '5.10.0',\n enabled: '5.10.0',\n },\n }\n);\n\n{{#if relativeJSModule}}\nimport component from \"{{{js-string-escape relativeJSModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: { relativeHBSModule: string; relativeJSModule: string | null; debugName: string }) => string;\n\nexport function virtualExternalESModule(specifier: string, exports: string[] | undefined): string {\n if (exports) {\n return externalESPrefix + specifier + `?exports=${exports.join(',')}`;\n } else {\n return externalESPrefix + specifier;\n }\n}\n\nexport function virtualExternalCJSModule(specifier: string): string {\n return externalCJSPrefix + specifier;\n}\n\nfunction decodeVirtualExternalESModule(filename: string): { moduleName: string; exports: string[] } | undefined {\n if (filename.startsWith(externalESPrefix)) {\n let exports: string[] = [];\n let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');\n let nameString = url.searchParams.get('exports');\n if (nameString) {\n exports = nameString.split(',');\n }\n let moduleName = url.pathname.slice(1);\n return { moduleName, exports };\n }\n}\n\nfunction decodeVirtualExternalCJSModule(filename: string) {\n if (filename.startsWith(externalCJSPrefix)) {\n return { moduleName: filename.slice(externalCJSPrefix.length) };\n }\n}\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)\\/(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | null): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(hbsModule, jsModule);\n }\n return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(pairComponentMarker)) {\n return null;\n }\n let match = pairComponentPattern.exec(filename);\n if (!match) {\n return null;\n }\n let { hbsModule, jsModule } = match.groups! as { hbsModule: string; jsModule: string };\n // target our real hbs module from our virtual module\n let relativeHBSModule = explicitRelative(dirname(filename), hbsModule);\n return {\n relativeHBSModule,\n relativeJSModule: decodeURIComponent(jsModule) || null,\n debugName: basename(relativeHBSModule).replace(/\\.(js|hbs)$/, ''),\n };\n}\n\nconst fastbootSwitchSuffix = '/embroider_fastboot_switch';\nconst fastbootSwitchPattern = /(?<original>.+)\\/embroider_fastboot_switch(?:\\?names=(?<names>.+))?$/;\nexport function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string {\n let filename = `${resolve(dirname(fromFile), specifier)}${fastbootSwitchSuffix}`;\n if (names.size > 0) {\n return `${filename}?names=${[...names].join(',')}`;\n } else {\n return filename;\n }\n}\n\nexport function decodeFastbootSwitch(filename: string) {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(fastbootSwitchSuffix)) {\n return;\n }\n let match = fastbootSwitchPattern.exec(filename);\n if (match) {\n let names = match.groups?.names?.split(',') ?? [];\n return {\n names: names.filter(name => name !== 'default'),\n hasDefaultExport: names.includes('default'),\n filename: match.groups!.original,\n };\n }\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: { names: string[]; hasDefaultExport: boolean }) => string;\n\nconst implicitModulesPattern = /(?<filename>.*)[\\\\/]-embroider-implicit-(?<test>test-)?modules\\.js$/;\n\nexport function decodeImplicitModules(\n filename: string\n): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-implicit-')) {\n return;\n }\n let m = implicitModulesPattern.exec(filename);\n if (m) {\n return {\n type: m.groups!.test ? 'implicit-test-modules' : 'implicit-modules',\n fromFile: m.groups!.filename,\n };\n }\n}\n\nfunction renderImplicitModules(\n {\n type,\n fromFile,\n }: {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n },\n resolver: Resolver\n): string {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let lazyModules: { runtime: string; buildtime: string }[] = [];\n let eagerModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n lazyModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n eagerModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return implicitModulesTemplate({ lazyModules, eagerModules });\n}\n\nconst implicitModulesTemplate = compile(`\nimport { importSync as i } from '@embroider/macros';\nlet d = window.define;\n{{#each lazyModules as |module|}}\nd(\"{{js-string-escape module.runtime}}\", function(){ return i(\"{{js-string-escape module.buildtime}}\");});\n{{/each}}\n{{#each eagerModules as |module|}}\nimport \"{{js-string-escape module}}\";\n{{/each}}\n`) as (params: { eagerModules: string[]; lazyModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nconst renderCJSExternalShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{/if}}\n{{!-\n There are plenty of hand-written AMD defines floating around\n that lack this, and they will break when other build systems\n encounter them.\n\n As far as I can tell, Ember's loader was already treating this\n case as a module, so in theory we aren't breaking anything by\n marking it as such when other packagers come looking.\n\n todo: get review on this part.\n-}}\nif (m.default && !m.__esModule) {\n m.__esModule = true;\n}\nmodule.exports = m;\n`) as (params: { moduleName: string }) => string;\n"]}
@@ -1,44 +0,0 @@
1
- import type { VirtualResponse } from './virtual-content';
2
- export type Resolution<T = unknown, E = unknown> = {
3
- type: 'found';
4
- filename: string;
5
- virtual: VirtualResponse | false;
6
- result: T;
7
- } | {
8
- type: 'not_found';
9
- err: E;
10
- };
11
- export type RequestAdapterCreate<Init, Res extends Resolution> = (params: Init) => {
12
- initialState: InitialRequestState;
13
- adapter: RequestAdapter<Res>;
14
- } | undefined;
15
- export interface RequestAdapter<Res extends Resolution> {
16
- readonly debugType: string;
17
- resolve(request: ModuleRequest<Res>): Promise<Res>;
18
- notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);
19
- virtualResponse(request: ModuleRequest<Res>, response: VirtualResponse): Res | (() => Promise<Res>);
20
- }
21
- export interface InitialRequestState {
22
- readonly specifier: string;
23
- readonly fromFile: string;
24
- readonly meta: Record<string, unknown> | undefined;
25
- }
26
- export declare class ModuleRequest<Res extends Resolution = Resolution> implements ModuleRequest<Res> {
27
- #private;
28
- static create<Init, Res extends Resolution>(createAdapter: RequestAdapterCreate<Init, Res>, params: Init): ModuleRequest<Res> | undefined;
29
- private constructor();
30
- get specifier(): string;
31
- get fromFile(): string;
32
- get debugType(): string;
33
- get meta(): Record<string, unknown> | undefined;
34
- get resolvedTo(): Res | (() => Promise<Res>) | undefined;
35
- alias(newSpecifier: string): this;
36
- rehome(newFromFile: string): this;
37
- virtualize(virtualResponse: VirtualResponse): this;
38
- withMeta(meta: Record<string, any> | undefined): this;
39
- notFound(): this;
40
- resolveTo(res: Res | (() => Promise<Res>)): this;
41
- defaultResolve(): Promise<Res>;
42
- clone(): this;
43
- }
44
- export declare function extractResolution<Res extends Resolution = Resolution>(res: Res | (() => Promise<Res>)): Promise<Res>;