@embroider/core 3.4.20-unstable.b89b741 → 3.4.20-unstable.c3af848

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 (37) hide show
  1. package/package.json +6 -6
  2. package/src/index.d.ts +2 -2
  3. package/src/index.js +1 -2
  4. package/src/index.js.map +1 -1
  5. package/src/module-request.d.ts +5 -6
  6. package/src/module-request.js +11 -2
  7. package/src/module-request.js.map +1 -1
  8. package/src/module-resolver.d.ts +3 -1
  9. package/src/module-resolver.js +130 -108
  10. package/src/module-resolver.js.map +1 -1
  11. package/src/node-resolve.d.ts +2 -1
  12. package/src/node-resolve.js +6 -8
  13. package/src/node-resolve.js.map +1 -1
  14. package/src/packager.d.ts +0 -8
  15. package/src/packager.js +0 -9
  16. package/src/packager.js.map +1 -1
  17. package/src/virtual-content.d.ts +28 -10
  18. package/src/virtual-content.js +45 -114
  19. package/src/virtual-content.js.map +1 -1
  20. package/src/virtual-entrypoint.d.ts +4 -2
  21. package/src/virtual-entrypoint.js +2 -18
  22. package/src/virtual-entrypoint.js.map +1 -1
  23. package/src/virtual-route-entrypoint.d.ts +4 -9
  24. package/src/virtual-route-entrypoint.js +1 -33
  25. package/src/virtual-route-entrypoint.js.map +1 -1
  26. package/src/virtual-test-support-styles.d.ts +5 -2
  27. package/src/virtual-test-support-styles.js +2 -5
  28. package/src/virtual-test-support-styles.js.map +1 -1
  29. package/src/virtual-test-support.d.ts +5 -2
  30. package/src/virtual-test-support.js +2 -5
  31. package/src/virtual-test-support.js.map +1 -1
  32. package/src/virtual-vendor-styles.d.ts +5 -1
  33. package/src/virtual-vendor-styles.js +2 -1
  34. package/src/virtual-vendor-styles.js.map +1 -1
  35. package/src/virtual-vendor.d.ts +5 -2
  36. package/src/virtual-vendor.js +4 -8
  37. package/src/virtual-vendor.js.map +1 -1
package/src/packager.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyVariantToBabelConfig = applyVariantToBabelConfig;
4
- exports.getAppMeta = getAppMeta;
5
4
  exports.getPackagerCacheDir = getPackagerCacheDir;
6
5
  const shared_internals_1 = require("@embroider/shared-internals");
7
- const fs_extra_1 = require("fs-extra");
8
6
  const lodash_1 = require("lodash");
9
7
  const path_1 = require("path");
10
8
  function applyVariantToBabelConfig(variant, babelConfig) {
@@ -25,13 +23,6 @@ function applyVariantToBabelConfig(variant, babelConfig) {
25
23
  }
26
24
  return babelConfig;
27
25
  }
28
- /**
29
- * Get the app meta-data for a package
30
- */
31
- function getAppMeta(pathToVanillaApp) {
32
- let pkg = JSON.parse((0, fs_extra_1.readFileSync)((0, path_1.join)(pathToVanillaApp, 'package.json'), 'utf8'));
33
- return pkg;
34
- }
35
26
  /**
36
27
  * Get the path to a cache directory in the recommended location
37
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;AAwEA,8DAkBC;AAKD,gCAGC;AAOD,kDAEC;AA1GD,kEAAqD;AACrD,uCAAwC;AACxC,mCAAmC;AACnC,+BAA4B;AAoE5B,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,WAAgB;IAC1E,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CACzE,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,mBAAmB,GAAG,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;YACjD,mBAAmB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YACnE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,gBAAwB;IACjD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,gBAAgB,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnF,OAAO,GAA0D,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { AppMeta } from '@embroider/shared-internals';\nimport { tmpdir } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the app meta-data for a package\n */\nexport function getAppMeta(pathToVanillaApp: string) {\n let pkg = JSON.parse(readFileSync(join(pathToVanillaApp, 'package.json'), 'utf8'));\n return pkg as unknown as { name: string; 'ember-addon': AppMeta };\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
1
+ {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;AAsEA,8DAkBC;AAOD,kDAEC;AAjGD,kEAAqD;AACrD,mCAAmC;AACnC,+BAA4B;AAoE5B,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,WAAgB;IAC1E,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CACzE,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,mBAAmB,GAAG,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;YACjD,mBAAmB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YACnE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { tmpdir } from '@embroider/shared-internals';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
@@ -1,17 +1,35 @@
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);
2
11
  export interface VirtualContentResult {
3
12
  src: string;
4
13
  watches: string[];
5
14
  }
6
- export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
7
- export declare function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string;
8
- export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
9
- export declare function decodeFastbootSwitch(filename: string): {
10
- names: string[];
11
- hasDefaultExport: boolean;
12
- filename: string;
13
- } | undefined;
14
- export declare function decodeImplicitModules(filename: string): {
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 {
15
28
  type: 'implicit-modules' | 'implicit-test-modules';
16
29
  fromFile: string;
17
- } | undefined;
30
+ }
31
+ export interface TemplateOnlyComponentResponse {
32
+ type: 'template-only-component-js';
33
+ specifier: string;
34
+ }
35
+ export {};
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.virtualContent = virtualContent;
4
- exports.virtualPairComponent = virtualPairComponent;
5
- exports.fastbootSwitch = fastbootSwitch;
6
- exports.decodeFastbootSwitch = decodeFastbootSwitch;
7
- exports.decodeImplicitModules = decodeImplicitModules;
8
7
  const path_1 = require("path");
9
8
  const _1 = require(".");
10
9
  const js_handlebars_1 = require("./js-handlebars");
@@ -14,48 +13,37 @@ const virtual_vendor_1 = require("./virtual-vendor");
14
13
  const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
15
14
  const virtual_entrypoint_1 = require("./virtual-entrypoint");
16
15
  const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
16
+ const assert_never_1 = __importDefault(require("assert-never"));
17
17
  // Given a filename that was passed to your ModuleRequest's `virtualize()`,
18
18
  // this produces the corresponding contents. It's a static, stateless function
19
19
  // because we recognize that that process that did resolution might not be the
20
20
  // same one that loads the content.
21
- function virtualContent(filename, resolver) {
22
- let entrypoint = (0, virtual_entrypoint_1.decodeEntrypoint)(filename);
23
- if (entrypoint) {
24
- return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, entrypoint);
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);
25
46
  }
26
- let routeEntrypoint = (0, virtual_route_entrypoint_1.decodeRouteEntrypoint)(filename);
27
- if (routeEntrypoint) {
28
- return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(resolver, routeEntrypoint);
29
- }
30
- let match = decodeVirtualPairComponent(filename);
31
- if (match) {
32
- return pairedComponentShim(match);
33
- }
34
- let fb = decodeFastbootSwitch(filename);
35
- if (fb) {
36
- return renderFastbootSwitchTemplate(fb);
37
- }
38
- let im = decodeImplicitModules(filename);
39
- if (im) {
40
- return renderImplicitModules(im, resolver);
41
- }
42
- let isVendor = (0, virtual_vendor_1.decodeVirtualVendor)(filename);
43
- if (isVendor) {
44
- return (0, virtual_vendor_1.renderVendor)(filename, resolver);
45
- }
46
- let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
47
- if (isImplicitTestScripts) {
48
- return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
49
- }
50
- let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
51
- if (isVendorStyles) {
52
- return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
53
- }
54
- let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
55
- if (isTestSupportStyles) {
56
- return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
57
- }
58
- throw new Error(`not an @embroider/core virtual file: ${filename}`);
59
47
  }
60
48
  function pairedComponentShim(params) {
61
49
  return {
@@ -65,7 +53,7 @@ function pairedComponentShim(params) {
65
53
  }
66
54
  const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
67
55
  import { setComponentTemplate } from "@ember/component";
68
- import template from "{{{js-string-escape relativeHBSModule}}}";
56
+ import template from "{{{js-string-escape hbsModule}}}";
69
57
  import { deprecate } from "@ember/debug";
70
58
 
71
59
 
@@ -82,71 +70,20 @@ deprecate("Components with separately resolved templates are deprecated. Migrate
82
70
  }
83
71
  );
84
72
 
85
- {{#if relativeJSModule}}
86
- import component from "{{{js-string-escape relativeJSModule}}}";
73
+ {{#if jsModule}}
74
+ import component from "{{{js-string-escape jsModule}}}";
87
75
  export default setComponentTemplate(template, component);
88
76
  {{else}}
89
77
  import templateOnlyComponent from "@ember/component/template-only";
90
78
  export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
91
79
  {{/if}}
92
80
  `);
93
- const pairComponentMarker = '-embroider-pair-component';
94
- const pairComponentPattern = /^(?<hbsModule>.*)__vpc__(?<jsModule>[^\/]*)-embroider-pair-component$/;
95
- function virtualPairComponent(hbsModule, jsModule) {
96
- let relativeJSModule = '';
97
- if (jsModule) {
98
- relativeJSModule = (0, _1.explicitRelative)((0, path_1.dirname)(hbsModule), jsModule);
99
- }
100
- return `${hbsModule}__vpc__${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;
101
- }
102
- function decodeVirtualPairComponent(filename) {
103
- // Performance: avoid paying regex exec cost unless needed
104
- if (!filename.includes(pairComponentMarker)) {
105
- return null;
106
- }
107
- let match = pairComponentPattern.exec(filename);
108
- if (!match) {
109
- return null;
110
- }
111
- let { hbsModule, jsModule } = match.groups;
112
- // target our real hbs module from our virtual module
113
- let relativeHBSModule = (0, _1.explicitRelative)((0, path_1.dirname)(filename), hbsModule);
114
- return {
115
- relativeHBSModule,
116
- relativeJSModule: decodeURIComponent(jsModule) || null,
117
- debugName: (0, path_1.basename)(relativeHBSModule).replace(/\.(js|hbs)$/, ''),
118
- };
119
- }
120
- const fastbootSwitchSuffix = '/embroider_fastboot_switch';
121
- const fastbootSwitchPattern = /(?<original>.+)\/embroider_fastboot_switch(?:\?names=(?<names>.+))?$/;
122
- function fastbootSwitch(specifier, fromFile, names) {
123
- let filename = `${(0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier)}${fastbootSwitchSuffix}`;
124
- if (names.size > 0) {
125
- return `${filename}?names=${[...names].join(',')}`;
126
- }
127
- else {
128
- return filename;
129
- }
130
- }
131
- function decodeFastbootSwitch(filename) {
132
- var _a, _b, _c;
133
- // Performance: avoid paying regex exec cost unless needed
134
- if (!filename.includes(fastbootSwitchSuffix)) {
135
- return;
136
- }
137
- let match = fastbootSwitchPattern.exec(filename);
138
- if (match) {
139
- 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 : [];
140
- return {
141
- names: names.filter(name => name !== 'default'),
142
- hasDefaultExport: names.includes('default'),
143
- filename: match.groups.original,
144
- };
145
- }
146
- }
147
81
  function renderFastbootSwitchTemplate(params) {
148
82
  return {
149
- src: fastbootSwitchTemplate(params),
83
+ src: fastbootSwitchTemplate({
84
+ names: [...params.names].filter(name => name !== 'default'),
85
+ hasDefaultExport: params.names.has('default'),
86
+ }),
150
87
  watches: [],
151
88
  };
152
89
  }
@@ -165,21 +102,7 @@ export default mod.default;
165
102
  export const {{name}} = mod.{{name}};
166
103
  {{/each}}
167
104
  `);
168
- const implicitModulesPattern = /(?<filename>.*)[\\/]-embroider-implicit-(?<test>test-)?modules\.js$/;
169
- function decodeImplicitModules(filename) {
170
- // Performance: avoid paying regex exec cost unless needed
171
- if (!filename.includes('-embroider-implicit-')) {
172
- return;
173
- }
174
- let m = implicitModulesPattern.exec(filename);
175
- if (m) {
176
- return {
177
- type: m.groups.test ? 'implicit-test-modules' : 'implicit-modules',
178
- fromFile: m.groups.filename,
179
- };
180
- }
181
- }
182
- function renderImplicitModules({ type, fromFile, }, resolver) {
105
+ function renderImplicitModules({ type, fromFile }, resolver) {
183
106
  let resolvableExtensionsPattern = (0, _1.extensionsPattern)(resolver.options.resolvableExtensions);
184
107
  const pkg = resolver.packageCache.ownerOfFile(fromFile);
185
108
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
@@ -279,4 +202,12 @@ function orderAddons(depA, depB) {
279
202
  }
280
203
  return depAIdx - depBIdx;
281
204
  }
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 };
212
+ }
282
213
  //# sourceMappingURL=virtual-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":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explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\nimport { decodeImplicitTestScripts, renderImplicitTestScripts } from './virtual-test-support';\nimport { decodeTestSupportStyles, renderTestSupportStyles } from './virtual-test-support-styles';\nimport { decodeVirtualVendor, renderVendor } from './virtual-vendor';\nimport { decodeVirtualVendorStyles, renderVendorStyles } from './virtual-vendor-styles';\n\nimport { decodeEntrypoint, renderEntrypoint } from './virtual-entrypoint';\nimport { decodeRouteEntrypoint, renderRouteEntrypoint } from './virtual-route-entrypoint';\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(filename: string, resolver: Resolver): VirtualContentResult {\n let entrypoint = decodeEntrypoint(filename);\n if (entrypoint) {\n return renderEntrypoint(resolver, entrypoint);\n }\n\n let routeEntrypoint = decodeRouteEntrypoint(filename);\n if (routeEntrypoint) {\n return renderRouteEntrypoint(resolver, routeEntrypoint);\n }\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 renderFastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n let isVendor = decodeVirtualVendor(filename);\n if (isVendor) {\n return renderVendor(filename, resolver);\n }\n\n let isImplicitTestScripts = decodeImplicitTestScripts(filename);\n if (isImplicitTestScripts) {\n return renderImplicitTestScripts(filename, resolver);\n }\n\n let isVendorStyles = decodeVirtualVendorStyles(filename);\n if (isVendorStyles) {\n return renderVendorStyles(filename, resolver);\n }\n\n let isTestSupportStyles = decodeTestSupportStyles(filename);\n if (isTestSupportStyles) {\n return renderTestSupportStyles(filename, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\ninterface PairedComponentShimParams {\n relativeHBSModule: string;\n relativeJSModule: 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 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: PairedComponentShimParams) => string;\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)__vpc__(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(dirname(hbsModule), jsModule);\n }\n return `${hbsModule}__vpc__${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\ninterface FastbootSwitchParams {\n names: string[];\n hasDefaultExport: boolean;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchParams): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate(params),\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: FastbootSwitchParams) => 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): 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"]}
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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AAI,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;AAOD,SAAS,2BAA2B,CAAC,EAAE,SAAS,EAAiC;IAC/E,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAA,mBAAgB,EAAC,SAAS,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,8 +1,10 @@
1
1
  import { AppFiles, type RouteFiles } from './app-files';
2
2
  import type { Resolver } from './module-resolver';
3
- export declare function decodeEntrypoint(filename: string): {
3
+ export interface EntrypointResponse {
4
+ type: 'entrypoint';
4
5
  fromDir: string;
5
- } | undefined;
6
+ specifier: string;
7
+ }
6
8
  export declare function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined;
7
9
  export declare function renderEntrypoint(resolver: Resolver, { fromDir }: {
8
10
  fromDir: string;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.decodeEntrypoint = decodeEntrypoint;
7
6
  exports.staticAppPathsPattern = staticAppPathsPattern;
8
7
  exports.renderEntrypoint = renderEntrypoint;
9
8
  exports.importPaths = importPaths;
@@ -16,22 +15,8 @@ const lodash_1 = require("lodash");
16
15
  const path_1 = require("path");
17
16
  const shared_internals_1 = require("@embroider/shared-internals");
18
17
  const walk_sync_1 = __importDefault(require("walk-sync"));
19
- const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
20
18
  const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
21
19
  const options_1 = require("./options");
22
- const entrypointPattern = /(?<filename>.*)[\\/]-embroider-entrypoint.js/;
23
- function decodeEntrypoint(filename) {
24
- // Performance: avoid paying regex exec cost unless needed
25
- if (!filename.includes('-embroider-entrypoint')) {
26
- return;
27
- }
28
- let m = entrypointPattern.exec(filename);
29
- if (m) {
30
- return {
31
- fromDir: m.groups.filename,
32
- };
33
- }
34
- }
35
20
  function staticAppPathsPattern(staticAppPaths) {
36
21
  if (staticAppPaths && staticAppPaths.length > 0) {
37
22
  return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => (0, escape_string_regexp_1.default)(staticAppPath)).join('|') + ')(?:$|/)');
@@ -39,7 +24,6 @@ function staticAppPathsPattern(staticAppPaths) {
39
24
  }
40
25
  function renderEntrypoint(resolver, { fromDir }) {
41
26
  var _a;
42
- // this is new
43
27
  const owner = resolver.packageCache.ownerOfFile(fromDir);
44
28
  let eagerModules = [];
45
29
  if (!owner) {
@@ -98,10 +82,10 @@ function renderEntrypoint(resolver, { fromDir }) {
98
82
  for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
99
83
  splitRoute(routeName, routeFiles, resolver.options.splitAtRoutes, (_, filename) => {
100
84
  requiredAppFiles.push([filename]);
101
- }, (routeNames, _files) => {
85
+ }, (routeNames) => {
102
86
  lazyRoutes.push({
103
87
  names: routeNames,
104
- path: (0, virtual_route_entrypoint_1.encodePublicRouteEntrypoint)(routeNames, _files),
88
+ path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,
105
89
  });
106
90
  });
107
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-entrypoint.js","sourceRoot":"","sources":["virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAeA,4CAWC;AAED,sDAIC;AAED,4CAsHC;AA8FD,kCAOC;AAED,gCA6DC;AAeD,kCAKC;AAED,4CAIC;AAtVD,2CAAwD;AACxD,mDAA0C;AAG1C,mCAA4C;AAC5C,+BAA4B;AAC5B,kEAAgE;AAChE,0DAAiC;AAEjC,yEAAyE;AACzE,gFAAgD;AAChD,uCAAgD;AAEhD,MAAM,iBAAiB,GAAG,8CAA8C,CAAC;AAEzE,SAAgB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,aAA8C;IACzF,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,KAAK,SAAS,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,OAAO,EAAE;QACxC,MAAM,EAAE,CAAC,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC;KAC/E,CAAC,CAAC;IACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import { AppFiles, type RouteFiles } from './app-files';\nimport { compile } from './js-handlebars';\nimport type { Resolver } from './module-resolver';\nimport type { CompatResolverOptions } from '../../compat/src/resolver-transform';\nimport { flatten, partition } from 'lodash';\nimport { join } from 'path';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport walkSync from 'walk-sync';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { encodePublicRouteEntrypoint } from './virtual-route-entrypoint';\nimport escapeRegExp from 'escape-string-regexp';\nimport { optionsWithDefaults } from './options';\n\nconst entrypointPattern = /(?<filename>.*)[\\\\/]-embroider-entrypoint.js/;\n\nexport function decodeEntrypoint(filename: string): { fromDir: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-entrypoint')) {\n return;\n }\n let m = entrypointPattern.exec(filename);\n if (m) {\n return {\n fromDir: m.groups!.filename,\n };\n }\n}\n\nexport function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined {\n if (staticAppPaths && staticAppPaths.length > 0) {\n return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => escapeRegExp(staticAppPath)).join('|') + ')(?:$|/)');\n }\n}\n\nexport function renderEntrypoint(\n resolver: Resolver,\n { fromDir }: { fromDir: string }\n): { src: string; watches: string[] } {\n // this is new\n const owner = resolver.packageCache.ownerOfFile(fromDir);\n\n let eagerModules: string[] = [];\n\n if (!owner) {\n throw new Error('Owner expected'); // ToDo: Really bad error, update message\n }\n\n let engine = resolver.owningEngine(owner);\n let isApp = owner?.root === resolver.options.engines[0]!.root;\n let hasFastboot = Boolean(resolver.options.engines[0]!.activeAddons.find(a => a.name === 'ember-cli-fastboot'));\n\n let appFiles = new AppFiles(\n {\n package: owner,\n addons: new Map(\n engine.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp,\n modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,\n appRelativePath: 'NOT_USED_DELETE_ME',\n },\n getAppFiles(fromDir),\n hasFastboot ? getFastbootFiles(owner.root) : new Set(),\n extensionsPattern(resolver.options.resolvableExtensions),\n staticAppPathsPattern(resolver.options.staticAppPaths),\n resolver.options.podModulePrefix\n );\n\n let options = (resolver.options as CompatResolverOptions).options ?? optionsWithDefaults();\n\n let requiredAppFiles = [appFiles.otherAppFiles];\n if (!options.staticComponents) {\n requiredAppFiles.push(appFiles.components);\n }\n if (!options.staticHelpers) {\n requiredAppFiles.push(appFiles.helpers);\n }\n if (!options.staticModifiers) {\n requiredAppFiles.push(appFiles.modifiers);\n }\n\n let styles = [];\n // only import styles from engines with a parent (this excludeds the parent application) as their styles\n // will be inserted via a direct <link> tag.\n if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {\n styles.push({\n path: '@embroider/virtual/vendor.css',\n });\n }\n\n let lazyEngines: { names: string[]; path: string }[] = [];\n\n if (isApp) {\n // deliberately ignoring the app (which is the first entry in the engines array)\n let [, ...childEngines] = resolver.options.engines;\n for (let childEngine of childEngines) {\n let target = `@embroider/virtual/compat-modules/${childEngine.packageName}`;\n\n if (childEngine.isLazy) {\n lazyEngines.push({\n names: [childEngine.packageName],\n path: target,\n });\n } else {\n eagerModules.push(target);\n }\n }\n }\n\n let lazyRoutes: { names: string[]; path: string }[] = [];\n for (let [routeName, routeFiles] of appFiles.routeFiles.children) {\n splitRoute(\n routeName,\n routeFiles,\n resolver.options.splitAtRoutes,\n (_: string, filename: string) => {\n requiredAppFiles.push([filename]);\n },\n (routeNames: string[], _files: string[]) => {\n lazyRoutes.push({\n names: routeNames,\n path: encodePublicRouteEntrypoint(routeNames, _files),\n });\n }\n );\n }\n\n let [fastboot, nonFastboot] = partition(excludeDotFiles(flatten(requiredAppFiles)), file =>\n appFiles.isFastbootOnly.get(file)\n );\n\n let amdModules = nonFastboot.map(file => importPaths(resolver, appFiles, file));\n let fastbootOnlyAmdModules = fastboot.map(file => importPaths(resolver, appFiles, file));\n\n let params = {\n amdModules,\n fastbootOnlyAmdModules,\n lazyRoutes,\n lazyEngines,\n eagerModules,\n styles,\n // this is a backward-compatibility feature: addons can force inclusion of modules.\n defineModulesFrom: './-embroider-implicit-modules.js',\n };\n\n return {\n src: entryTemplate(params),\n watches: [fromDir],\n };\n}\n\nconst entryTemplate = compile(`\nimport { macroCondition, getGlobalConfig } from '@embroider/macros';\n\n{{#if styles}}\n if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {\n {{#each styles as |stylePath| ~}}\n await import(\"{{js-string-escape stylePath.path}}\");\n {{/each}}\n }\n{{/if}}\n\n{{#if defineModulesFrom ~}}\n import implicitModules from \"{{js-string-escape defineModulesFrom}}\";\n{{/if}}\n\n{{#each eagerModules as |eagerModule| ~}}\n import \"{{js-string-escape eagerModule}}\";\n{{/each}}\n\n{{#each amdModules as |amdModule index| ~}}\n import * as amdModule{{index}} from \"{{js-string-escape amdModule.buildtime}}\"\n{{/each}}\n\nlet exportFastbootModules = {};\n\n{{#if fastbootOnlyAmdModules}}\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {\n let fastbootModules = {};\n\n {{#each fastbootOnlyAmdModules as |amdModule| ~}}\n fastbootModules[\"{{js-string-escape amdModule.runtime}}\"] = import(\"{{js-string-escape amdModule.buildtime}}\");\n {{/each}}\n\n const resolvedValues = await Promise.all(Object.values(fastbootModules));\n\n Object.keys(fastbootModules).forEach((k, i) => {\n exportFasbootModules[k] = resolvedValues[i];\n })\n }\n{{/if}}\n\n\n{{#if lazyRoutes}}\nwindow._embroiderRouteBundles_ = [\n {{#each lazyRoutes as |route|}}\n {\n names: {{json-stringify route.names}},\n load: function() {\n return import(\"{{js-string-escape route.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\n{{#if lazyEngines}}\nwindow._embroiderEngineBundles_ = [\n {{#each lazyEngines as |engine|}}\n {\n names: {{json-stringify engine.names}},\n load: function() {\n return import(\"{{js-string-escape engine.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\nexport default Object.assign(\n {},\n implicitModules,\n {\n {{#each amdModules as |amdModule index| ~}}\n \"{{js-string-escape amdModule.runtime}}\": amdModule{{index}},\n {{/each}}\n },\n exportFastbootModules\n);\n`) as (params: {\n amdModules: { runtime: string; buildtime: string }[];\n fastbootOnlyAmdModules?: { runtime: string; buildtime: string }[];\n defineModulesFrom?: string;\n eagerModules?: string[];\n lazyRoutes?: { names: string[]; path: string }[];\n lazyEngines?: { names: string[]; path: string }[];\n styles?: { path: string }[];\n}) => string;\n\nfunction excludeDotFiles(files: string[]) {\n return files.filter(file => !file.startsWith('.') && !file.includes('/.'));\n}\n\nexport function importPaths(resolver: Resolver, { engine }: AppFiles, engineRelativePath: string) {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n let noHBS = engineRelativePath.replace(resolvableExtensionsPattern, '').replace(/\\.hbs$/, '');\n return {\n runtime: `${engine.modulePrefix}/${noHBS}`,\n buildtime: `./${engineRelativePath}`,\n };\n}\n\nexport function splitRoute(\n routeName: string,\n files: RouteFiles,\n splitAtRoutes: (RegExp | string)[] | undefined,\n addToParent: (routeName: string, filename: string) => void,\n addLazyBundle: (routeNames: string[], files: string[]) => void\n) {\n let shouldSplit = routeName && shouldSplitRoute(routeName, splitAtRoutes);\n let ownFiles = [];\n let ownNames = new Set() as Set<string>;\n\n if (files.template) {\n if (shouldSplit) {\n ownFiles.push(files.template);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.template);\n }\n }\n\n if (files.controller) {\n if (shouldSplit) {\n ownFiles.push(files.controller);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.controller);\n }\n }\n\n if (files.route) {\n if (shouldSplit) {\n ownFiles.push(files.route);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.route);\n }\n }\n\n for (let [childName, childFiles] of files.children) {\n splitRoute(\n `${routeName}.${childName}`,\n childFiles,\n splitAtRoutes,\n (childRouteName: string, childFile: string) => {\n // this is our child calling \"addToParent\"\n if (shouldSplit) {\n ownFiles.push(childFile);\n ownNames.add(childRouteName);\n } else {\n addToParent(childRouteName, childFile);\n }\n },\n (routeNames: string[], files: string[]) => {\n addLazyBundle(routeNames, files);\n }\n );\n }\n\n if (ownFiles.length > 0) {\n addLazyBundle([...ownNames], ownFiles);\n }\n}\n\nfunction shouldSplitRoute(routeName: string, splitAtRoutes: (RegExp | string)[] | undefined) {\n if (!splitAtRoutes) {\n return false;\n }\n return splitAtRoutes.find(pattern => {\n if (typeof pattern === 'string') {\n return pattern === routeName;\n } else {\n return pattern.test(routeName);\n }\n });\n}\n\nexport function getAppFiles(appRoot: string): Set<string> {\n const files: string[] = walkSync(appRoot, {\n ignore: ['_babel_filter_.js', 'app.js', 'assets', 'testem.js', 'node_modules'],\n });\n return new Set(files);\n}\n\nexport function getFastbootFiles(appRoot: string): Set<string> {\n const appDirPath = join(appRoot, '_fastboot_');\n const files: string[] = walkSync(appDirPath);\n return new Set(files);\n}\n"]}
1
+ {"version":3,"file":"virtual-entrypoint.js","sourceRoot":"","sources":["virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAkBA,sDAIC;AAED,4CAqHC;AA8FD,kCAOC;AAED,gCA6DC;AAeD,kCAKC;AAED,4CAIC;AA3UD,2CAAwD;AACxD,mDAA0C;AAG1C,mCAA4C;AAC5C,+BAA4B;AAC5B,kEAAgE;AAChE,0DAAiC;AAEjC,gFAAgD;AAChD,uCAAgD;AAQhD,SAAgB,qBAAqB,CAAC,cAAoC;IACxE,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,IAAA,8BAAY,EAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IACtH,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAC9B,QAAkB,EAClB,EAAE,OAAO,EAAuB;;IAEhC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,YAAY,GAAa,EAAE,CAAC;IAEhC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,yCAAyC;IAC9E,CAAC;IAED,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,KAAK,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,QAAQ,CAAC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AE,CAAC;QACxB,aAAa,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAiB,EAAE,aAA8C;IACzF,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,KAAK,SAAS,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,OAAO,EAAE;QACxC,MAAM,EAAE,CAAC,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC;KAC/E,CAAC,CAAC;IACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import { AppFiles, type RouteFiles } from './app-files';\nimport { compile } from './js-handlebars';\nimport type { Resolver } from './module-resolver';\nimport type { CompatResolverOptions } from '../../compat/src/resolver-transform';\nimport { flatten, partition } from 'lodash';\nimport { join } from 'path';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport walkSync from 'walk-sync';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport escapeRegExp from 'escape-string-regexp';\nimport { optionsWithDefaults } from './options';\n\nexport interface EntrypointResponse {\n type: 'entrypoint';\n fromDir: string;\n specifier: string;\n}\n\nexport function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined {\n if (staticAppPaths && staticAppPaths.length > 0) {\n return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => escapeRegExp(staticAppPath)).join('|') + ')(?:$|/)');\n }\n}\n\nexport function renderEntrypoint(\n resolver: Resolver,\n { fromDir }: { fromDir: string }\n): { src: string; watches: string[] } {\n const owner = resolver.packageCache.ownerOfFile(fromDir);\n\n let eagerModules: string[] = [];\n\n if (!owner) {\n throw new Error('Owner expected'); // ToDo: Really bad error, update message\n }\n\n let engine = resolver.owningEngine(owner);\n let isApp = owner?.root === resolver.options.engines[0]!.root;\n let hasFastboot = Boolean(resolver.options.engines[0]!.activeAddons.find(a => a.name === 'ember-cli-fastboot'));\n\n let appFiles = new AppFiles(\n {\n package: owner,\n addons: new Map(\n engine.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp,\n modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,\n appRelativePath: 'NOT_USED_DELETE_ME',\n },\n getAppFiles(fromDir),\n hasFastboot ? getFastbootFiles(owner.root) : new Set(),\n extensionsPattern(resolver.options.resolvableExtensions),\n staticAppPathsPattern(resolver.options.staticAppPaths),\n resolver.options.podModulePrefix\n );\n\n let options = (resolver.options as CompatResolverOptions).options ?? optionsWithDefaults();\n\n let requiredAppFiles = [appFiles.otherAppFiles];\n if (!options.staticComponents) {\n requiredAppFiles.push(appFiles.components);\n }\n if (!options.staticHelpers) {\n requiredAppFiles.push(appFiles.helpers);\n }\n if (!options.staticModifiers) {\n requiredAppFiles.push(appFiles.modifiers);\n }\n\n let styles = [];\n // only import styles from engines with a parent (this excludeds the parent application) as their styles\n // will be inserted via a direct <link> tag.\n if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {\n styles.push({\n path: '@embroider/virtual/vendor.css',\n });\n }\n\n let lazyEngines: { names: string[]; path: string }[] = [];\n\n if (isApp) {\n // deliberately ignoring the app (which is the first entry in the engines array)\n let [, ...childEngines] = resolver.options.engines;\n for (let childEngine of childEngines) {\n let target = `@embroider/virtual/compat-modules/${childEngine.packageName}`;\n\n if (childEngine.isLazy) {\n lazyEngines.push({\n names: [childEngine.packageName],\n path: target,\n });\n } else {\n eagerModules.push(target);\n }\n }\n }\n\n let lazyRoutes: { names: string[]; path: string }[] = [];\n for (let [routeName, routeFiles] of appFiles.routeFiles.children) {\n splitRoute(\n routeName,\n routeFiles,\n resolver.options.splitAtRoutes,\n (_: string, filename: string) => {\n requiredAppFiles.push([filename]);\n },\n (routeNames: string[]) => {\n lazyRoutes.push({\n names: routeNames,\n path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,\n });\n }\n );\n }\n\n let [fastboot, nonFastboot] = partition(excludeDotFiles(flatten(requiredAppFiles)), file =>\n appFiles.isFastbootOnly.get(file)\n );\n\n let amdModules = nonFastboot.map(file => importPaths(resolver, appFiles, file));\n let fastbootOnlyAmdModules = fastboot.map(file => importPaths(resolver, appFiles, file));\n\n let params = {\n amdModules,\n fastbootOnlyAmdModules,\n lazyRoutes,\n lazyEngines,\n eagerModules,\n styles,\n // this is a backward-compatibility feature: addons can force inclusion of modules.\n defineModulesFrom: './-embroider-implicit-modules.js',\n };\n\n return {\n src: entryTemplate(params),\n watches: [fromDir],\n };\n}\n\nconst entryTemplate = compile(`\nimport { macroCondition, getGlobalConfig } from '@embroider/macros';\n\n{{#if styles}}\n if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {\n {{#each styles as |stylePath| ~}}\n await import(\"{{js-string-escape stylePath.path}}\");\n {{/each}}\n }\n{{/if}}\n\n{{#if defineModulesFrom ~}}\n import implicitModules from \"{{js-string-escape defineModulesFrom}}\";\n{{/if}}\n\n{{#each eagerModules as |eagerModule| ~}}\n import \"{{js-string-escape eagerModule}}\";\n{{/each}}\n\n{{#each amdModules as |amdModule index| ~}}\n import * as amdModule{{index}} from \"{{js-string-escape amdModule.buildtime}}\"\n{{/each}}\n\nlet exportFastbootModules = {};\n\n{{#if fastbootOnlyAmdModules}}\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {\n let fastbootModules = {};\n\n {{#each fastbootOnlyAmdModules as |amdModule| ~}}\n fastbootModules[\"{{js-string-escape amdModule.runtime}}\"] = import(\"{{js-string-escape amdModule.buildtime}}\");\n {{/each}}\n\n const resolvedValues = await Promise.all(Object.values(fastbootModules));\n\n Object.keys(fastbootModules).forEach((k, i) => {\n exportFasbootModules[k] = resolvedValues[i];\n })\n }\n{{/if}}\n\n\n{{#if lazyRoutes}}\nwindow._embroiderRouteBundles_ = [\n {{#each lazyRoutes as |route|}}\n {\n names: {{json-stringify route.names}},\n load: function() {\n return import(\"{{js-string-escape route.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\n{{#if lazyEngines}}\nwindow._embroiderEngineBundles_ = [\n {{#each lazyEngines as |engine|}}\n {\n names: {{json-stringify engine.names}},\n load: function() {\n return import(\"{{js-string-escape engine.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\nexport default Object.assign(\n {},\n implicitModules,\n {\n {{#each amdModules as |amdModule index| ~}}\n \"{{js-string-escape amdModule.runtime}}\": amdModule{{index}},\n {{/each}}\n },\n exportFastbootModules\n);\n`) as (params: {\n amdModules: { runtime: string; buildtime: string }[];\n fastbootOnlyAmdModules?: { runtime: string; buildtime: string }[];\n defineModulesFrom?: string;\n eagerModules?: string[];\n lazyRoutes?: { names: string[]; path: string }[];\n lazyEngines?: { names: string[]; path: string }[];\n styles?: { path: string }[];\n}) => string;\n\nfunction excludeDotFiles(files: string[]) {\n return files.filter(file => !file.startsWith('.') && !file.includes('/.'));\n}\n\nexport function importPaths(resolver: Resolver, { engine }: AppFiles, engineRelativePath: string) {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n let noHBS = engineRelativePath.replace(resolvableExtensionsPattern, '').replace(/\\.hbs$/, '');\n return {\n runtime: `${engine.modulePrefix}/${noHBS}`,\n buildtime: `./${engineRelativePath}`,\n };\n}\n\nexport function splitRoute(\n routeName: string,\n files: RouteFiles,\n splitAtRoutes: (RegExp | string)[] | undefined,\n addToParent: (routeName: string, filename: string) => void,\n addLazyBundle: (routeNames: string[], files: string[]) => void\n) {\n let shouldSplit = routeName && shouldSplitRoute(routeName, splitAtRoutes);\n let ownFiles = [];\n let ownNames = new Set() as Set<string>;\n\n if (files.template) {\n if (shouldSplit) {\n ownFiles.push(files.template);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.template);\n }\n }\n\n if (files.controller) {\n if (shouldSplit) {\n ownFiles.push(files.controller);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.controller);\n }\n }\n\n if (files.route) {\n if (shouldSplit) {\n ownFiles.push(files.route);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.route);\n }\n }\n\n for (let [childName, childFiles] of files.children) {\n splitRoute(\n `${routeName}.${childName}`,\n childFiles,\n splitAtRoutes,\n (childRouteName: string, childFile: string) => {\n // this is our child calling \"addToParent\"\n if (shouldSplit) {\n ownFiles.push(childFile);\n ownNames.add(childRouteName);\n } else {\n addToParent(childRouteName, childFile);\n }\n },\n (routeNames: string[], files: string[]) => {\n addLazyBundle(routeNames, files);\n }\n );\n }\n\n if (ownFiles.length > 0) {\n addLazyBundle([...ownNames], ownFiles);\n }\n}\n\nfunction shouldSplitRoute(routeName: string, splitAtRoutes: (RegExp | string)[] | undefined) {\n if (!splitAtRoutes) {\n return false;\n }\n return splitAtRoutes.find(pattern => {\n if (typeof pattern === 'string') {\n return pattern === routeName;\n } else {\n return pattern.test(routeName);\n }\n });\n}\n\nexport function getAppFiles(appRoot: string): Set<string> {\n const files: string[] = walkSync(appRoot, {\n ignore: ['_babel_filter_.js', 'app.js', 'assets', 'testem.js', 'node_modules'],\n });\n return new Set(files);\n}\n\nexport function getFastbootFiles(appRoot: string): Set<string> {\n const appDirPath = join(appRoot, '_fastboot_');\n const files: string[] = walkSync(appDirPath);\n return new Set(files);\n}\n"]}
@@ -1,15 +1,10 @@
1
1
  import type { Resolver } from './module-resolver';
2
- export declare function encodeRouteEntrypoint(packagePath: string, matched: string | undefined, routeName: string): string;
3
- export declare function decodeRouteEntrypoint(filename: string): {
2
+ export interface RouteEntrypointResponse {
3
+ type: 'route-entrypoint';
4
4
  fromDir: string;
5
5
  route: string;
6
- } | undefined;
7
- export declare function encodePublicRouteEntrypoint(routeNames: string[], _files: string[]): string;
8
- export declare function decodePublicRouteEntrypoint(specifier: string): string | null;
9
- export declare function renderRouteEntrypoint(resolver: Resolver, { fromDir, route }: {
10
- fromDir: string;
11
- route: string;
12
- }): {
6
+ }
7
+ export declare function renderRouteEntrypoint({ fromDir, route }: RouteEntrypointResponse, resolver: Resolver): {
13
8
  src: string;
14
9
  watches: string[];
15
10
  };
@@ -1,44 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeRouteEntrypoint = encodeRouteEntrypoint;
4
- exports.decodeRouteEntrypoint = decodeRouteEntrypoint;
5
- exports.encodePublicRouteEntrypoint = encodePublicRouteEntrypoint;
6
- exports.decodePublicRouteEntrypoint = decodePublicRouteEntrypoint;
7
3
  exports.renderRouteEntrypoint = renderRouteEntrypoint;
8
4
  const app_files_1 = require("./app-files");
9
- const path_1 = require("path");
10
5
  const js_handlebars_1 = require("./js-handlebars");
11
6
  const shared_internals_1 = require("@embroider/shared-internals");
12
7
  const lodash_1 = require("lodash");
13
8
  const virtual_entrypoint_1 = require("./virtual-entrypoint");
14
- const entrypointPattern = /(?<filename>.*)[\\/]-embroider-route-entrypoint.js:route=(?<route>.*)/;
15
- function encodeRouteEntrypoint(packagePath, matched, routeName) {
16
- return (0, path_1.resolve)(packagePath, matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`);
17
- }
18
- function decodeRouteEntrypoint(filename) {
19
- // Performance: avoid paying regex exec cost unless needed
20
- if (!filename.includes('-embroider-route-entrypoint')) {
21
- return;
22
- }
23
- let m = entrypointPattern.exec(filename);
24
- if (m) {
25
- return {
26
- fromDir: m.groups.filename,
27
- route: m.groups.route,
28
- };
29
- }
30
- }
31
- function encodePublicRouteEntrypoint(routeNames, _files) {
32
- return `@embroider/core/route/${encodeURIComponent(routeNames[0])}`;
33
- }
34
- function decodePublicRouteEntrypoint(specifier) {
35
- const publicPrefix = '@embroider/core/route/';
36
- if (!specifier.startsWith(publicPrefix)) {
37
- return null;
38
- }
39
- return specifier.slice(publicPrefix.length);
40
- }
41
- function renderRouteEntrypoint(resolver, { fromDir, route }) {
9
+ function renderRouteEntrypoint({ fromDir, route }, resolver) {
42
10
  const owner = resolver.packageCache.ownerOfFile(fromDir);
43
11
  if (!owner) {
44
12
  throw new Error('Owner expected'); // ToDo: Really bad error, update message