@embroider/core 4.6.6 → 4.6.8

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 (118) hide show
  1. package/package.json +5 -5
  2. package/dist/src/app-files.d.ts +0 -34
  3. package/dist/src/app-files.d.ts.map +0 -1
  4. package/dist/src/app-files.js +0 -201
  5. package/dist/src/app-files.js.map +0 -1
  6. package/dist/src/describe-exports.d.ts +0 -5
  7. package/dist/src/describe-exports.d.ts.map +0 -1
  8. package/dist/src/describe-exports.js +0 -52
  9. package/dist/src/describe-exports.js.map +0 -1
  10. package/dist/src/html-entrypoint.d.ts +0 -23
  11. package/dist/src/html-entrypoint.d.ts.map +0 -1
  12. package/dist/src/html-entrypoint.js +0 -185
  13. package/dist/src/html-entrypoint.js.map +0 -1
  14. package/dist/src/html-placeholder.d.ts +0 -40
  15. package/dist/src/html-placeholder.d.ts.map +0 -1
  16. package/dist/src/html-placeholder.js +0 -130
  17. package/dist/src/html-placeholder.js.map +0 -1
  18. package/dist/src/index.d.ts +0 -15
  19. package/dist/src/index.d.ts.map +0 -1
  20. package/dist/src/index.js +0 -50
  21. package/dist/src/index.js.map +0 -1
  22. package/dist/src/js-handlebars.d.ts +0 -2
  23. package/dist/src/js-handlebars.d.ts.map +0 -1
  24. package/dist/src/js-handlebars.js +0 -20
  25. package/dist/src/js-handlebars.js.map +0 -1
  26. package/dist/src/measure-concat.d.ts +0 -14
  27. package/dist/src/measure-concat.d.ts.map +0 -1
  28. package/dist/src/measure-concat.js +0 -33
  29. package/dist/src/measure-concat.js.map +0 -1
  30. package/dist/src/messages.d.ts +0 -9
  31. package/dist/src/messages.d.ts.map +0 -1
  32. package/dist/src/messages.js +0 -74
  33. package/dist/src/messages.js.map +0 -1
  34. package/dist/src/module-request.d.ts +0 -45
  35. package/dist/src/module-request.d.ts.map +0 -1
  36. package/dist/src/module-request.js +0 -87
  37. package/dist/src/module-request.js.map +0 -1
  38. package/dist/src/module-resolver-options.d.ts +0 -43
  39. package/dist/src/module-resolver-options.d.ts.map +0 -1
  40. package/dist/src/module-resolver-options.js +0 -155
  41. package/dist/src/module-resolver-options.js.map +0 -1
  42. package/dist/src/module-resolver.d.ts +0 -71
  43. package/dist/src/module-resolver.d.ts.map +0 -1
  44. package/dist/src/module-resolver.js +0 -1167
  45. package/dist/src/module-resolver.js.map +0 -1
  46. package/dist/src/node-resolve.d.ts +0 -36
  47. package/dist/src/node-resolve.d.ts.map +0 -1
  48. package/dist/src/node-resolve.js +0 -134
  49. package/dist/src/node-resolve.js.map +0 -1
  50. package/dist/src/options.d.ts +0 -26
  51. package/dist/src/options.d.ts.map +0 -1
  52. package/dist/src/options.js +0 -26
  53. package/dist/src/options.js.map +0 -1
  54. package/dist/src/packager.d.ts +0 -20
  55. package/dist/src/packager.d.ts.map +0 -1
  56. package/dist/src/packager.js +0 -34
  57. package/dist/src/packager.js.map +0 -1
  58. package/dist/src/portable.d.ts +0 -26
  59. package/dist/src/portable.d.ts.map +0 -1
  60. package/dist/src/portable.js +0 -231
  61. package/dist/src/portable.js.map +0 -1
  62. package/dist/src/resolvable-extensions.d.ts +0 -2
  63. package/dist/src/resolvable-extensions.d.ts.map +0 -1
  64. package/dist/src/resolvable-extensions.js +0 -13
  65. package/dist/src/resolvable-extensions.js.map +0 -1
  66. package/dist/src/resolver-loader.d.ts +0 -9
  67. package/dist/src/resolver-loader.d.ts.map +0 -1
  68. package/dist/src/resolver-loader.js +0 -54
  69. package/dist/src/resolver-loader.js.map +0 -1
  70. package/dist/src/stage.d.ts +0 -9
  71. package/dist/src/stage.d.ts.map +0 -1
  72. package/dist/src/stage.js +0 -3
  73. package/dist/src/stage.js.map +0 -1
  74. package/dist/src/virtual-content.d.ts +0 -36
  75. package/dist/src/virtual-content.d.ts.map +0 -1
  76. package/dist/src/virtual-content.js +0 -232
  77. package/dist/src/virtual-content.js.map +0 -1
  78. package/dist/src/virtual-entrypoint.d.ts +0 -22
  79. package/dist/src/virtual-entrypoint.d.ts.map +0 -1
  80. package/dist/src/virtual-entrypoint.js +0 -280
  81. package/dist/src/virtual-entrypoint.js.map +0 -1
  82. package/dist/src/virtual-route-entrypoint.d.ts +0 -11
  83. package/dist/src/virtual-route-entrypoint.d.ts.map +0 -1
  84. package/dist/src/virtual-route-entrypoint.js +0 -68
  85. package/dist/src/virtual-route-entrypoint.js.map +0 -1
  86. package/dist/src/virtual-test-support-styles.d.ts +0 -8
  87. package/dist/src/virtual-test-support-styles.d.ts.map +0 -1
  88. package/dist/src/virtual-test-support-styles.js +0 -61
  89. package/dist/src/virtual-test-support-styles.js.map +0 -1
  90. package/dist/src/virtual-test-support.d.ts +0 -8
  91. package/dist/src/virtual-test-support.d.ts.map +0 -1
  92. package/dist/src/virtual-test-support.js +0 -65
  93. package/dist/src/virtual-test-support.js.map +0 -1
  94. package/dist/src/virtual-vendor-styles.d.ts +0 -9
  95. package/dist/src/virtual-vendor-styles.d.ts.map +0 -1
  96. package/dist/src/virtual-vendor-styles.js +0 -84
  97. package/dist/src/virtual-vendor-styles.js.map +0 -1
  98. package/dist/src/virtual-vendor.d.ts +0 -8
  99. package/dist/src/virtual-vendor.d.ts.map +0 -1
  100. package/dist/src/virtual-vendor.js +0 -55
  101. package/dist/src/virtual-vendor.js.map +0 -1
  102. package/dist/src/wait-for-trees.d.ts +0 -14
  103. package/dist/src/wait-for-trees.d.ts.map +0 -1
  104. package/dist/src/wait-for-trees.js +0 -98
  105. package/dist/src/wait-for-trees.js.map +0 -1
  106. package/dist/tests/babel-debug-util.d.ts +0 -2
  107. package/dist/tests/babel-debug-util.d.ts.map +0 -1
  108. package/dist/tests/babel-debug-util.js +0 -36
  109. package/dist/tests/babel-debug-util.js.map +0 -1
  110. package/dist/tests/example-target.d.ts +0 -3
  111. package/dist/tests/example-target.d.ts.map +0 -1
  112. package/dist/tests/example-target.js +0 -10
  113. package/dist/tests/example-target.js.map +0 -1
  114. package/dist/tests/portable.test.d.ts +0 -2
  115. package/dist/tests/portable.test.d.ts.map +0 -1
  116. package/dist/tests/portable.test.js +0 -14
  117. package/dist/tests/portable.test.js.map +0 -1
  118. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,232 +0,0 @@
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.virtualContent = virtualContent;
7
- const path_1 = require("path");
8
- const _1 = require(".");
9
- 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"));
17
- // Given a filename that was passed to your ModuleRequest's `virtualize()`,
18
- // this produces the corresponding contents. It's a static, stateless function
19
- // because we recognize that that process that did resolution might not be the
20
- // 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
- };
53
- }
54
- const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
55
- import { setComponentTemplate } from "@ember/component";
56
- import template from "{{{js-string-escape hbsModule}}}";
57
- import { deprecate } from "@ember/debug";
58
-
59
-
60
- deprecate("Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '{{debugName}}'.",
61
- false, {
62
- id: 'component-template-resolving',
63
- url: 'https://deprecations.emberjs.com/id/component-template-resolving',
64
- until: '6.0.0',
65
- for: 'ember-source',
66
- since: {
67
- available: '5.10.0',
68
- enabled: '5.10.0',
69
- },
70
- }
71
- );
72
-
73
- {{#if jsModule}}
74
- import component from "{{{js-string-escape jsModule}}}";
75
- export default setComponentTemplate(template, component);
76
- {{else}}
77
- import templateOnlyComponent from "@ember/component/template-only";
78
- export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
79
- {{/if}}
80
- `);
81
- function renderFastbootSwitchTemplate(params) {
82
- return {
83
- src: fastbootSwitchTemplate({
84
- names: [...params.names].filter(name => name !== 'default'),
85
- hasDefaultExport: params.names.has('default'),
86
- }),
87
- watches: [],
88
- };
89
- }
90
- const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
91
- import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
92
- let mod;
93
- if (macroCondition(getGlobalConfig().fastboot?.isRunning)){
94
- mod = importSync('./fastboot');
95
- } else {
96
- mod = importSync('./browser');
97
- }
98
- {{#if hasDefaultExport}}
99
- export default mod.default;
100
- {{/if}}
101
- {{#each names as |name|}}
102
- export const {{name}} = mod.{{name}};
103
- {{/each}}
104
- `);
105
- function hasDepsWithImplicitModules(pkg, type) {
106
- for (let dep of pkg.dependencies) {
107
- // anything that isn't a v2 ember package by this point is not an active
108
- // addon. We ignore peerDependencies here because classic ember-cli ignores
109
- // peerDependencies here, and we're implementing the implicit-modules
110
- // backward-comptibility feature.
111
- if (!dep.isV2Addon() || pkg.categorizeDependency(dep.name) === 'peerDependencies') {
112
- continue;
113
- }
114
- let implicitModules = dep.meta[type];
115
- if (implicitModules && implicitModules.length > 0) {
116
- return true;
117
- }
118
- if (hasDepsWithImplicitModules(dep, type)) {
119
- return true;
120
- }
121
- }
122
- return false;
123
- }
124
- function renderImplicitModules({ type, fromFile }, resolver) {
125
- let resolvableExtensionsPattern = (0, _1.extensionsPattern)(resolver.options.resolvableExtensions);
126
- const pkg = resolver.packageCache.ownerOfFile(fromFile);
127
- if (!pkg?.isV2Ember()) {
128
- throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
129
- }
130
- let ownModules = [];
131
- let dependencyModules = [];
132
- let deps = pkg.dependencies.sort(orderAddons);
133
- for (let dep of deps) {
134
- // anything that isn't a v2 ember package by this point is not an active
135
- // addon.
136
- if (!dep.isV2Addon()) {
137
- continue;
138
- }
139
- // we ignore peerDependencies here because classic ember-cli ignores
140
- // peerDependencies here, and we're implementing the implicit-modules
141
- // backward-comptibility feature.
142
- if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {
143
- continue;
144
- }
145
- let implicitModules = dep.meta[type];
146
- if (implicitModules) {
147
- let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);
148
- for (let name of implicitModules) {
149
- let packageName = dep.name;
150
- let renamedMeta = dep.meta['renamed-packages'];
151
- if (renamedMeta) {
152
- Object.entries(renamedMeta).forEach(([key, value]) => {
153
- if (value === dep.name) {
154
- packageName = key;
155
- }
156
- });
157
- }
158
- let runtime = (0, path_1.join)(packageName, name).replace(resolvableExtensionsPattern, '');
159
- let runtimeRenameLookup = runtime.split('\\').join('/');
160
- if (renamedModules && renamedModules[runtimeRenameLookup]) {
161
- runtime = renamedModules[runtimeRenameLookup];
162
- }
163
- runtime = runtime.split(path_1.sep).join('/');
164
- ownModules.push({
165
- runtime,
166
- buildtime: path_1.posix.join(packageName, name),
167
- });
168
- }
169
- }
170
- // we don't recurse across an engine boundary. Engines import their own
171
- // implicit-modules.
172
- if (!dep.isEngine() && hasDepsWithImplicitModules(dep, type)) {
173
- dependencyModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
174
- }
175
- }
176
- return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };
177
- }
178
- const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
179
-
180
-
181
- {{#each dependencyModules as |module index|}}
182
- import dep{{index}} from "{{js-string-escape module}}";
183
- {{/each}}
184
-
185
- {{#each ownModules as |module index|}}
186
- import * as own{{index}} from "{{js-string-escape module.buildtime}}";
187
- {{/each}}
188
-
189
- export default Object.assign({},
190
- {{#each dependencyModules as |module index|}}
191
- dep{{index}},
192
- {{/each}}
193
- {
194
- {{#each ownModules as |module index|}}
195
- "{{js-string-escape module.runtime}}": own{{index}},
196
- {{/each}}
197
- }
198
- );
199
- `);
200
- // meta['renamed-modules'] has mapping from classic filename to real filename.
201
- // This takes that and converts it to the inverst mapping from real import path
202
- // to classic import path.
203
- function inverseRenamedModules(meta, extensions) {
204
- let renamed = meta['renamed-modules'];
205
- if (renamed) {
206
- let inverted = {};
207
- for (let [classic, real] of Object.entries(renamed)) {
208
- inverted[real.replace(extensions, '')] = classic.replace(extensions, '');
209
- }
210
- return inverted;
211
- }
212
- }
213
- function orderAddons(depA, depB) {
214
- let depAIdx = 0;
215
- let depBIdx = 0;
216
- if (depA && depA.meta && depA.isV2Addon()) {
217
- depAIdx = depA.meta['order-index'] || 0;
218
- }
219
- if (depB && depB.meta && depB.isV2Addon()) {
220
- depBIdx = depB.meta['order-index'] || 0;
221
- }
222
- return depAIdx - depBIdx;
223
- }
224
- function renderTemplateOnlyComponent({ specifier }) {
225
- let watches = [specifier];
226
- let hbs = (0, _1.syntheticJStoHBS)(specifier);
227
- if (hbs) {
228
- watches.push(hbs);
229
- }
230
- return { src: (0, _1.templateOnlyComponentSource)(), watches };
231
- }
232
- //# sourceMappingURL=virtual-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["../../src/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,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrD,KAAK,iBAAiB;YACpB,OAAO,IAAA,gDAAyB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvD,KAAK,gBAAgB;YACnB,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACvC,KAAK,kBAAkB,CAAC;QACxB,KAAK,uBAAuB;YAC1B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,KAAK,kBAAkB;YACrB,OAAO,IAAA,gDAAqB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,KAAK,iBAAiB;YACpB,OAAO,4BAA4B,CAAC,Q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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 hasDepsWithImplicitModules(pkg: Package, type: 'implicit-modules' | 'implicit-test-modules'): boolean {\n for (let dep of pkg.dependencies) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon. 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 (!dep.isV2Addon() || pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n let implicitModules = dep.meta[type];\n if (implicitModules && implicitModules.length > 0) {\n return true;\n }\n if (hasDepsWithImplicitModules(dep, type)) {\n return true;\n }\n }\n return false;\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() && hasDepsWithImplicitModules(dep, type)) {\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,22 +0,0 @@
1
- import { AppFiles, type RouteFiles } from './app-files';
2
- import type { Resolver } from './module-resolver';
3
- export interface EntrypointResponse {
4
- type: 'entrypoint';
5
- fromDir: string;
6
- specifier: string;
7
- }
8
- export declare function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined;
9
- export declare function renderEntrypoint(resolver: Resolver, { fromDir }: {
10
- fromDir: string;
11
- }): {
12
- src: string;
13
- watches: string[];
14
- };
15
- export declare function importPaths(resolver: Resolver, { engine }: AppFiles, engineRelativePath: string): {
16
- runtime: string;
17
- buildtime: string;
18
- };
19
- export declare function splitRoute(routeName: string, files: RouteFiles, splitAtRoutes: (RegExp | string)[] | undefined, addToParent: (routeName: string, filename: string) => void, addLazyBundle: (routeNames: string[], files: string[]) => void): void;
20
- export declare function getAppFiles(appRoot: string): Set<string>;
21
- export declare function getFastbootFiles(appRoot: string): Set<string>;
22
- //# sourceMappingURL=virtual-entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-entrypoint.d.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";
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.staticAppPathsPattern = staticAppPathsPattern;
7
- exports.renderEntrypoint = renderEntrypoint;
8
- exports.importPaths = importPaths;
9
- exports.splitRoute = splitRoute;
10
- exports.getAppFiles = getAppFiles;
11
- exports.getFastbootFiles = getFastbootFiles;
12
- const app_files_1 = require("./app-files");
13
- const js_handlebars_1 = require("./js-handlebars");
14
- const lodash_1 = require("lodash");
15
- const path_1 = require("path");
16
- const shared_internals_1 = require("@embroider/shared-internals");
17
- const walk_sync_1 = __importDefault(require("walk-sync"));
18
- const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
19
- const options_1 = require("./options");
20
- const resolvable_extensions_1 = require("./resolvable-extensions");
21
- function staticAppPathsPattern(staticAppPaths) {
22
- if (staticAppPaths && staticAppPaths.length > 0) {
23
- return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => (0, escape_string_regexp_1.default)(staticAppPath)).join('|') + ')(?:$|/)');
24
- }
25
- }
26
- function renderEntrypoint(resolver, { fromDir }) {
27
- const owner = resolver.packageCache.ownerOfFile(fromDir);
28
- if (!owner) {
29
- throw new Error('Owner expected'); // ToDo: Really bad error, update message
30
- }
31
- let engine = resolver.owningEngine(owner);
32
- let isApp = owner?.root === resolver.options.engines[0].root;
33
- let hasFastboot = Boolean(resolver.options.engines[0].activeAddons.find(a => a.name === 'ember-cli-fastboot'));
34
- let defineModulesFrom = ['./-embroider-implicit-modules.js'];
35
- let appFiles = new app_files_1.AppFiles({
36
- package: owner,
37
- addons: new Map(engine.activeAddons.map(addon => [
38
- resolver.packageCache.get(addon.root),
39
- addon.canResolveFromFile,
40
- ])),
41
- isApp,
42
- modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,
43
- appRelativePath: 'NOT_USED_DELETE_ME',
44
- }, getAppFiles(fromDir), hasFastboot ? getFastbootFiles(owner.root) : new Set(), (0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions), staticAppPathsPattern(resolver.options.staticAppPaths), resolver.options.podModulePrefix);
45
- /**
46
- * we are only reading staticInvokables off this type so I'm setting the type manually here. I don't know why
47
- * resolver.options is reporting an incorrect type here, but I have verified this programatically that this
48
- * is the right shape here and tests fail if it is wrong anyway
49
- */
50
- let options = resolver.options.options ?? (0, options_1.optionsWithDefaults)();
51
- let requiredAppFiles = [appFiles.otherAppFiles];
52
- if (!options.staticInvokables) {
53
- requiredAppFiles.push(appFiles.components);
54
- requiredAppFiles.push(appFiles.helpers);
55
- requiredAppFiles.push(appFiles.modifiers);
56
- }
57
- let styles = [];
58
- // only import styles from engines with a parent (this excludeds the parent application) as their styles
59
- // will be inserted via a direct <link> tag.
60
- if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
61
- styles.push({
62
- path: '@embroider/virtual/vendor.css',
63
- });
64
- }
65
- let lazyRoutes = [];
66
- for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
67
- splitRoute(routeName, routeFiles, resolver.options.splitAtRoutes, (_, filename) => {
68
- requiredAppFiles.push([filename]);
69
- }, (routeNames) => {
70
- lazyRoutes.push({
71
- names: routeNames,
72
- path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,
73
- });
74
- });
75
- }
76
- let [fastboot, nonFastboot] = (0, lodash_1.partition)(excludeDotFiles((0, lodash_1.flatten)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
77
- let amdModules = nonFastboot.map(file => importPaths(resolver, appFiles, file));
78
- let fastbootOnlyAmdModules = fastboot.map(file => importPaths(resolver, appFiles, file));
79
- let lazyEngines = [];
80
- if (isApp) {
81
- // deliberately ignoring the app (which is the first entry in the engines array)
82
- let [, ...childEngines] = resolver.options.engines;
83
- for (let childEngine of childEngines) {
84
- if (childEngine.isLazy) {
85
- lazyEngines.push({
86
- names: [childEngine.packageName],
87
- path: `${childEngine.packageName}/engine`,
88
- });
89
- }
90
- else {
91
- amdModules.push({
92
- buildtime: `${childEngine.packageName}/engine`,
93
- runtime: `${childEngine.packageName}/engine`,
94
- });
95
- }
96
- }
97
- }
98
- let params = {
99
- amdModules,
100
- fastbootOnlyAmdModules,
101
- lazyRoutes,
102
- lazyEngines,
103
- styles,
104
- // this is a backward-compatibility feature: addons can force inclusion of modules.
105
- defineModulesFrom,
106
- };
107
- return {
108
- src: entryTemplate(params),
109
- watches: [fromDir],
110
- };
111
- }
112
- const entryTemplate = (0, js_handlebars_1.compile)(`
113
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
114
-
115
- {{#if styles}}
116
- if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {
117
- {{#each styles as |stylePath| ~}}
118
- await import("{{js-string-escape stylePath.path}}");
119
- {{/each}}
120
- }
121
- {{/if}}
122
-
123
- {{#each defineModulesFrom as |module index| ~}}
124
- import defineModule{{index}} from "{{js-string-escape module}}";
125
- {{/each}}
126
-
127
- {{#each amdModules as |amdModule index| ~}}
128
- import * as amdModule{{index}} from "{{js-string-escape amdModule.buildtime}}"
129
- {{/each}}
130
-
131
- let exportFastbootModules = {};
132
-
133
- {{#if fastbootOnlyAmdModules}}
134
- if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
135
- let fastbootModules = {};
136
-
137
- {{#each fastbootOnlyAmdModules as |amdModule| ~}}
138
- fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
139
- {{/each}}
140
-
141
- const resolvedValues = await Promise.all(Object.values(fastbootModules));
142
-
143
- Object.keys(fastbootModules).forEach((k, i) => {
144
- exportFasbootModules[k] = resolvedValues[i];
145
- })
146
- }
147
- {{/if}}
148
-
149
-
150
- {{#if lazyRoutes}}
151
- window._embroiderRouteBundles_ = [
152
- {{#each lazyRoutes as |route|}}
153
- {
154
- names: {{json-stringify route.names}},
155
- load: function() {
156
- return import("{{js-string-escape route.path}}");
157
- }
158
- },
159
- {{/each}}
160
- ]
161
- {{/if}}
162
-
163
- {{#if lazyEngines}}
164
- window._embroiderEngineBundles_ = [
165
- {{#each lazyEngines as |engine|}}
166
- {
167
- names: {{json-stringify engine.names}},
168
- load: function() {
169
- return import("{{js-string-escape engine.path}}").then(m=> ({ default: { "{{engine.path}}": m.default } }));;
170
- }
171
- },
172
- {{/each}}
173
- ]
174
- {{/if}}
175
-
176
- export default Object.assign(
177
- {},
178
- {{#each defineModulesFrom as |module index| ~}}
179
- defineModule{{index}},
180
- {{/each}}
181
- {
182
- {{#each amdModules as |amdModule index| ~}}
183
- "{{js-string-escape amdModule.runtime}}": amdModule{{index}},
184
- {{/each}}
185
- },
186
- exportFastbootModules
187
- );
188
- `);
189
- function excludeDotFiles(files) {
190
- return files.filter(file => !file.startsWith('.') && !file.includes('/.'));
191
- }
192
- function importPaths(resolver, { engine }, engineRelativePath) {
193
- let resolvableExtensionsPattern = (0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions);
194
- let noHBS = engineRelativePath.replace(resolvableExtensionsPattern, '').replace(/\.hbs$/, '');
195
- return {
196
- runtime: `${engine.modulePrefix}/${noHBS}`,
197
- buildtime: `./${engineRelativePath}`,
198
- };
199
- }
200
- function splitRoute(routeName, files, splitAtRoutes, addToParent, addLazyBundle) {
201
- let shouldSplit = routeName && shouldSplitRoute(routeName, splitAtRoutes);
202
- let ownFiles = [];
203
- let ownNames = new Set();
204
- if (files.template) {
205
- if (shouldSplit) {
206
- ownFiles.push(files.template);
207
- ownNames.add(routeName);
208
- }
209
- else {
210
- addToParent(routeName, files.template);
211
- }
212
- }
213
- if (files.controller) {
214
- if (shouldSplit) {
215
- ownFiles.push(files.controller);
216
- ownNames.add(routeName);
217
- }
218
- else {
219
- addToParent(routeName, files.controller);
220
- }
221
- }
222
- if (files.route) {
223
- if (shouldSplit) {
224
- ownFiles.push(files.route);
225
- ownNames.add(routeName);
226
- }
227
- else {
228
- addToParent(routeName, files.route);
229
- }
230
- }
231
- for (let [childName, childFiles] of files.children) {
232
- splitRoute(`${routeName}.${childName}`, childFiles, splitAtRoutes, (childRouteName, childFile) => {
233
- // this is our child calling "addToParent"
234
- if (shouldSplit) {
235
- ownFiles.push(childFile);
236
- ownNames.add(childRouteName);
237
- }
238
- else {
239
- addToParent(childRouteName, childFile);
240
- }
241
- }, (routeNames, files) => {
242
- addLazyBundle(routeNames, files);
243
- });
244
- }
245
- if (ownFiles.length > 0) {
246
- addLazyBundle(Array.from(ownNames), ownFiles);
247
- }
248
- }
249
- function shouldSplitRoute(routeName, splitAtRoutes) {
250
- if (!splitAtRoutes) {
251
- return false;
252
- }
253
- return splitAtRoutes.find(pattern => {
254
- if (typeof pattern === 'string') {
255
- return pattern === routeName;
256
- }
257
- else {
258
- return pattern.test(routeName);
259
- }
260
- });
261
- }
262
- function getAppFiles(appRoot) {
263
- const files = (0, walk_sync_1.default)(appRoot, {
264
- ignore: [
265
- '_babel_filter_.js',
266
- ...(0, resolvable_extensions_1.resolvableExtensions)().map(ext => `app${ext}`),
267
- ...(0, resolvable_extensions_1.resolvableExtensions)().map(ext => `engine${ext}`),
268
- 'assets',
269
- ...(0, resolvable_extensions_1.resolvableExtensions)().map(ext => `testem${ext}`),
270
- 'node_modules',
271
- ],
272
- });
273
- return new Set(files);
274
- }
275
- function getFastbootFiles(appRoot) {
276
- const appDirPath = (0, path_1.join)(appRoot, '_fastboot_');
277
- const files = (0, walk_sync_1.default)(appDirPath);
278
- return new Set(files);
279
- }
280
- //# sourceMappingURL=virtual-entrypoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-entrypoint.js","sourceRoot":"","sources":["../../src/virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAkBA,sDAIC;AAED,4CAqHC;AA2FD,kCAOC;AAED,gCA6DC;AAeD,kCAYC;AAED,4CAIC;AA/UD,2CAAwD;AACxD,mDAA0C;AAE1C,mCAA4C;AAC5C,+BAA4B;AAC5B,kEAAgE;AAChE,0DAAiC;AAEjC,gFAAgD;AAChD,uCAAgD;A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,EAAC,OAAO,EAAE;QACxC,MAAM,EAAE;YACN,mBAAmB;YACnB,GAAG,IAAA,4CAAoB,GAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC;YACjD,GAAG,IAAA,4CAAoB,GAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpD,QAAQ;YACR,GAAG,IAAA,4CAAoB,GAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpD,cAAc;SACf;KACF,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 { 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';\nimport { resolvableExtensions } from './resolvable-extensions';\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 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 let defineModulesFrom = ['./-embroider-implicit-modules.js'];\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 /**\n * we are only reading staticInvokables off this type so I'm setting the type manually here. I don't know why\n * resolver.options is reporting an incorrect type here, but I have verified this programatically that this\n * is the right shape here and tests fail if it is wrong anyway\n */\n let options =\n (resolver.options as unknown as { options: { staticInvokables: boolean } }).options ?? optionsWithDefaults();\n\n let requiredAppFiles = [appFiles.otherAppFiles];\n if (!options.staticInvokables) {\n requiredAppFiles.push(appFiles.components);\n requiredAppFiles.push(appFiles.helpers);\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 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 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 if (childEngine.isLazy) {\n lazyEngines.push({\n names: [childEngine.packageName],\n path: `${childEngine.packageName}/engine`,\n });\n } else {\n amdModules.push({\n buildtime: `${childEngine.packageName}/engine`,\n runtime: `${childEngine.packageName}/engine`,\n });\n }\n }\n }\n\n let params = {\n amdModules,\n fastbootOnlyAmdModules,\n lazyRoutes,\n lazyEngines,\n styles,\n // this is a backward-compatibility feature: addons can force inclusion of modules.\n defineModulesFrom,\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{{#each defineModulesFrom as |module index| ~}}\n import defineModule{{index}} from \"{{js-string-escape module}}\";\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}}\").then(m=> ({ default: { \"{{engine.path}}\": m.default } }));;\n }\n },\n {{/each}}\n]\n{{/if}}\n\nexport default Object.assign(\n {},\n {{#each defineModulesFrom as |module index| ~}}\n defineModule{{index}},\n {{/each}}\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 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(Array.from(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: [\n '_babel_filter_.js',\n ...resolvableExtensions().map(ext => `app${ext}`),\n ...resolvableExtensions().map(ext => `engine${ext}`),\n 'assets',\n ...resolvableExtensions().map(ext => `testem${ext}`),\n 'node_modules',\n ],\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,11 +0,0 @@
1
- import type { Resolver } from './module-resolver';
2
- export interface RouteEntrypointResponse {
3
- type: 'route-entrypoint';
4
- fromDir: string;
5
- route: string;
6
- }
7
- export declare function renderRouteEntrypoint({ fromDir, route }: RouteEntrypointResponse, resolver: Resolver): {
8
- src: string;
9
- watches: string[];
10
- };
11
- //# sourceMappingURL=virtual-route-entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-route-entrypoint.d.ts","sourceRoot":"","sources":["../../src/virtual-route-entrypoint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAMlD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAKD,wBAAgB,qBAAqB,CACnC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,uBAAuB,EAC3C,QAAQ,EAAE,QAAQ,GACjB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CA+DpC"}