@embroider/core 3.4.20-unstable.947c6d2 → 3.4.20-unstable.b470496
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.
- package/package.json +7 -7
- package/src/index.d.ts +3 -3
- package/src/index.js +3 -3
- package/src/index.js.map +1 -1
- package/src/module-request.d.ts +43 -0
- package/src/module-request.js +91 -0
- package/src/module-request.js.map +1 -0
- package/src/module-resolver.d.ts +1 -28
- package/src/module-resolver.js +123 -124
- package/src/module-resolver.js.map +1 -1
- package/src/node-resolve.d.ts +13 -16
- package/src/node-resolve.js +38 -57
- package/src/node-resolve.js.map +1 -1
- package/src/virtual-content.d.ts +24 -10
- package/src/virtual-content.js +35 -114
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +4 -2
- package/src/virtual-entrypoint.js +2 -18
- package/src/virtual-entrypoint.js.map +1 -1
- package/src/virtual-route-entrypoint.d.ts +4 -9
- package/src/virtual-route-entrypoint.js +1 -33
- package/src/virtual-route-entrypoint.js.map +1 -1
- package/src/virtual-test-support-styles.d.ts +5 -2
- package/src/virtual-test-support-styles.js +2 -5
- package/src/virtual-test-support-styles.js.map +1 -1
- package/src/virtual-test-support.d.ts +5 -2
- package/src/virtual-test-support.js +2 -5
- package/src/virtual-test-support.js.map +1 -1
- package/src/virtual-vendor-styles.d.ts +5 -1
- package/src/virtual-vendor-styles.js +2 -1
- package/src/virtual-vendor-styles.js.map +1 -1
- package/src/virtual-vendor.d.ts +5 -2
- package/src/virtual-vendor.js +4 -8
- package/src/virtual-vendor.js.map +1 -1
- package/src/to-broccoli-plugin.d.ts +0 -8
- package/src/to-broccoli-plugin.js +0 -30
- package/src/to-broccoli-plugin.js.map +0 -1
package/src/node-resolve.js
CHANGED
@@ -3,70 +3,42 @@ 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.
|
6
|
+
exports.NodeRequestAdapter = void 0;
|
7
7
|
exports.nodeResolve = nodeResolve;
|
8
8
|
const virtual_content_1 = require("./virtual-content");
|
9
9
|
const path_1 = require("path");
|
10
10
|
const shared_internals_1 = require("@embroider/shared-internals");
|
11
11
|
const assert_never_1 = __importDefault(require("assert-never"));
|
12
|
-
|
13
|
-
|
12
|
+
// these would be circular, but they're type-only so it's fine
|
13
|
+
const module_request_1 = require("./module-request");
|
14
|
+
class NodeRequestAdapter {
|
15
|
+
constructor(resolver) {
|
14
16
|
this.resolver = resolver;
|
15
|
-
this.specifier = specifier;
|
16
|
-
this.fromFile = fromFile;
|
17
|
-
this.isVirtual = isVirtual;
|
18
|
-
this.meta = meta;
|
19
|
-
this.isNotFound = isNotFound;
|
20
|
-
this.resolvedTo = resolvedTo;
|
21
17
|
}
|
22
18
|
get debugType() {
|
23
19
|
return 'node';
|
24
20
|
}
|
25
|
-
|
26
|
-
|
21
|
+
notFoundResponse(request) {
|
22
|
+
let err = new Error(`module not found ${request.specifier}`);
|
23
|
+
err.code = 'MODULE_NOT_FOUND';
|
24
|
+
return {
|
25
|
+
type: 'not_found',
|
26
|
+
err,
|
27
|
+
};
|
27
28
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
withMeta(meta) {
|
40
|
-
return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, meta, this.isNotFound, this.resolvedTo);
|
41
|
-
}
|
42
|
-
notFound() {
|
43
|
-
return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, this.meta, true, undefined);
|
29
|
+
virtualResponse(_request, virtual) {
|
30
|
+
return {
|
31
|
+
type: 'found',
|
32
|
+
filename: virtual.specifier,
|
33
|
+
virtual,
|
34
|
+
result: {
|
35
|
+
type: 'virtual',
|
36
|
+
content: (0, virtual_content_1.virtualContent)(virtual, this.resolver).src,
|
37
|
+
filename: virtual.specifier,
|
38
|
+
},
|
39
|
+
};
|
44
40
|
}
|
45
|
-
|
46
|
-
return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, this.meta, this.isNotFound, resolution);
|
47
|
-
}
|
48
|
-
async defaultResolve() {
|
49
|
-
const request = this;
|
50
|
-
if (request.isVirtual) {
|
51
|
-
return {
|
52
|
-
type: 'found',
|
53
|
-
filename: request.specifier,
|
54
|
-
isVirtual: true,
|
55
|
-
result: {
|
56
|
-
type: 'virtual',
|
57
|
-
content: (0, virtual_content_1.virtualContent)(request.specifier, this.resolver).src,
|
58
|
-
filename: request.specifier,
|
59
|
-
},
|
60
|
-
};
|
61
|
-
}
|
62
|
-
if (request.isNotFound) {
|
63
|
-
let err = new Error(`module not found ${request.specifier}`);
|
64
|
-
err.code = 'MODULE_NOT_FOUND';
|
65
|
-
return {
|
66
|
-
type: 'not_found',
|
67
|
-
err,
|
68
|
-
};
|
69
|
-
}
|
41
|
+
async resolve(request) {
|
70
42
|
// require.resolve does not like when we resolve from virtual paths.
|
71
43
|
// That is, a request like "../thing.js" from
|
72
44
|
// "/a/real/path/VIRTUAL_SUBDIR/virtual.js" has an unambiguous target of
|
@@ -102,12 +74,22 @@ class NodeModuleRequest {
|
|
102
74
|
}
|
103
75
|
continue;
|
104
76
|
}
|
105
|
-
return { type: 'found', filename, result: { type: 'real', filename },
|
77
|
+
return { type: 'found', filename, result: { type: 'real', filename }, virtual: false };
|
106
78
|
}
|
107
79
|
return { type: 'not_found', err: initialError };
|
108
80
|
}
|
109
81
|
}
|
110
|
-
exports.
|
82
|
+
exports.NodeRequestAdapter = NodeRequestAdapter;
|
83
|
+
NodeRequestAdapter.create = ({ resolver, specifier, fromFile }) => {
|
84
|
+
return {
|
85
|
+
initialState: {
|
86
|
+
specifier,
|
87
|
+
fromFile,
|
88
|
+
meta: undefined,
|
89
|
+
},
|
90
|
+
adapter: new NodeRequestAdapter(resolver),
|
91
|
+
};
|
92
|
+
};
|
111
93
|
function* candidates(specifier) {
|
112
94
|
yield specifier;
|
113
95
|
const extensions = ['.hbs.js', '.hbs'];
|
@@ -116,14 +98,13 @@ function* candidates(specifier) {
|
|
116
98
|
}
|
117
99
|
}
|
118
100
|
async function nodeResolve(resolver, specifier, fromFile) {
|
119
|
-
let
|
101
|
+
let request = module_request_1.ModuleRequest.create(NodeRequestAdapter.create, { resolver, fromFile, specifier });
|
102
|
+
let resolution = await resolver.resolve(request);
|
120
103
|
switch (resolution.type) {
|
121
104
|
case 'not_found':
|
122
105
|
return resolution;
|
123
106
|
case 'found':
|
124
107
|
return resolution.result;
|
125
|
-
case 'ignored':
|
126
|
-
throw new Error(`bug: this is supposed to be impossible because NodeModuleRequest.prototype.defaultResove does not use "ignored"`);
|
127
108
|
default:
|
128
109
|
throw (0, assert_never_1.default)(resolution);
|
129
110
|
}
|
package/src/node-resolve.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAmHA,kCAeC;AAlID,uDAAyE;AACzE,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAEvC,8DAA8D;AAC9D,qDAAkH;AAGlH,MAAa,kBAAkB;IAe7B,YAA4B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAElD,IAAI,SAAS;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gBAAgB,CAAC,OAAyD;QACxE,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,oBAAoB,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5D,GAAW,CAAC,IAAI,GAAG,kBAAkB,CAAC;QACvC,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,GAAG;SACJ,CA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I,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAQ,CAAC,CAAC;IAClD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { virtualContent, type VirtualResponse } from './virtual-content';\nimport { dirname, resolve, isAbsolute } from 'path';\nimport { explicitRelative } from '@embroider/shared-internals';\nimport assertNever from 'assert-never';\n\n// these would be circular, but they're type-only so it's fine\nimport { ModuleRequest, type RequestAdapter, type RequestAdapterCreate, type Resolution } from './module-request';\nimport type { Resolver } from './module-resolver';\n\nexport class NodeRequestAdapter implements RequestAdapter<Resolution<NodeResolution, Error>> {\n static create: RequestAdapterCreate<\n { resolver: Resolver; specifier: string; fromFile: string },\n Resolution<NodeResolution, Error>\n > = ({ resolver, specifier, fromFile }) => {\n return {\n initialState: {\n specifier,\n fromFile,\n meta: undefined,\n },\n adapter: new NodeRequestAdapter(resolver),\n };\n };\n\n private constructor(private resolver: Resolver) {}\n\n get debugType() {\n return 'node';\n }\n\n notFoundResponse(request: ModuleRequest<Resolution<NodeResolution, Error>>): Resolution<NodeResolution, Error> {\n let err = new Error(`module not found ${request.specifier}`);\n (err as any).code = 'MODULE_NOT_FOUND';\n return {\n type: 'not_found',\n err,\n };\n }\n\n virtualResponse(\n _request: ModuleRequest<Resolution<NodeResolution, Error>>,\n virtual: VirtualResponse\n ): Resolution<NodeResolution, Error> {\n return {\n type: 'found',\n filename: virtual.specifier,\n virtual,\n result: {\n type: 'virtual' as const,\n content: virtualContent(virtual, this.resolver).src,\n filename: virtual.specifier,\n },\n };\n }\n\n async resolve(request: ModuleRequest<Resolution<NodeResolution, Error>>): Promise<Resolution<NodeResolution, Error>> {\n // require.resolve does not like when we resolve from virtual paths.\n // That is, a request like \"../thing.js\" from\n // \"/a/real/path/VIRTUAL_SUBDIR/virtual.js\" has an unambiguous target of\n // \"/a/real/path/thing.js\", but require.resolve won't do that path\n // adjustment until after checking whether VIRTUAL_SUBDIR actually\n // exists.\n //\n // We can do the path adjustments before doing require.resolve.\n let { specifier } = request;\n let fromDir = dirname(request.fromFile);\n if (!isAbsolute(specifier) && specifier.startsWith('.')) {\n let targetPath = resolve(fromDir, specifier);\n let newFromDir = dirname(targetPath);\n if (fromDir !== newFromDir) {\n specifier = explicitRelative(newFromDir, targetPath);\n fromDir = newFromDir;\n }\n }\n\n let initialError;\n\n for (let candidate of candidates(specifier)) {\n let filename;\n try {\n filename = require.resolve(candidate, {\n paths: [fromDir],\n });\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n\n if (!initialError) {\n initialError = err;\n }\n\n continue;\n }\n return { type: 'found', filename, result: { type: 'real' as 'real', filename }, virtual: false };\n }\n\n return { type: 'not_found', err: initialError };\n }\n}\n\nfunction* candidates(specifier: string) {\n yield specifier;\n\n const extensions = ['.hbs.js', '.hbs'];\n\n for (let ext of extensions) {\n yield `${specifier}${ext}`;\n }\n}\n\ntype NodeResolution = { type: 'virtual'; filename: string; content: string } | { type: 'real'; filename: string };\n\ntype NodeResolutionError = { type: 'not_found'; err: Error };\n\nexport async function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string\n): Promise<NodeResolution | NodeResolutionError> {\n let request = ModuleRequest.create(NodeRequestAdapter.create, { resolver, fromFile, specifier });\n let resolution = await resolver.resolve(request!);\n switch (resolution.type) {\n case 'not_found':\n return resolution;\n case 'found':\n return resolution.result;\n default:\n throw assertNever(resolution);\n }\n}\n"]}
|
package/src/virtual-content.d.ts
CHANGED
@@ -1,17 +1,31 @@
|
|
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);
|
2
11
|
export interface VirtualContentResult {
|
3
12
|
src: string;
|
4
13
|
watches: string[];
|
5
14
|
}
|
6
|
-
export declare function virtualContent(
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
+
export declare function virtualContent(response: VirtualResponse, resolver: Resolver): VirtualContentResult;
|
16
|
+
export interface VirtualPairResponse {
|
17
|
+
type: 'component-pair';
|
18
|
+
specifier: string;
|
19
|
+
hbsModule: string;
|
20
|
+
jsModule: string | null;
|
21
|
+
debugName: string;
|
22
|
+
}
|
23
|
+
interface FastbootSwitchResponse {
|
24
|
+
type: 'fastboot-switch';
|
25
|
+
names: Set<string>;
|
26
|
+
}
|
27
|
+
export interface ImplicitModulesResponse {
|
15
28
|
type: 'implicit-modules' | 'implicit-test-modules';
|
16
29
|
fromFile: string;
|
17
|
-
}
|
30
|
+
}
|
31
|
+
export {};
|
package/src/virtual-content.js
CHANGED
@@ -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,35 @@ 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(
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
+
default:
|
43
|
+
throw (0, assert_never_1.default)(response);
|
25
44
|
}
|
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
45
|
}
|
60
46
|
function pairedComponentShim(params) {
|
61
47
|
return {
|
@@ -65,7 +51,7 @@ function pairedComponentShim(params) {
|
|
65
51
|
}
|
66
52
|
const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
|
67
53
|
import { setComponentTemplate } from "@ember/component";
|
68
|
-
import template from "{{{js-string-escape
|
54
|
+
import template from "{{{js-string-escape hbsModule}}}";
|
69
55
|
import { deprecate } from "@ember/debug";
|
70
56
|
|
71
57
|
|
@@ -82,71 +68,20 @@ deprecate("Components with separately resolved templates are deprecated. Migrate
|
|
82
68
|
}
|
83
69
|
);
|
84
70
|
|
85
|
-
{{#if
|
86
|
-
import component from "{{{js-string-escape
|
71
|
+
{{#if jsModule}}
|
72
|
+
import component from "{{{js-string-escape jsModule}}}";
|
87
73
|
export default setComponentTemplate(template, component);
|
88
74
|
{{else}}
|
89
75
|
import templateOnlyComponent from "@ember/component/template-only";
|
90
76
|
export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
|
91
77
|
{{/if}}
|
92
78
|
`);
|
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
79
|
function renderFastbootSwitchTemplate(params) {
|
148
80
|
return {
|
149
|
-
src: fastbootSwitchTemplate(
|
81
|
+
src: fastbootSwitchTemplate({
|
82
|
+
names: [...params.names].filter(name => name !== 'default'),
|
83
|
+
hasDefaultExport: params.names.has('default'),
|
84
|
+
}),
|
150
85
|
watches: [],
|
151
86
|
};
|
152
87
|
}
|
@@ -165,21 +100,7 @@ export default mod.default;
|
|
165
100
|
export const {{name}} = mod.{{name}};
|
166
101
|
{{/each}}
|
167
102
|
`);
|
168
|
-
|
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) {
|
103
|
+
function renderImplicitModules({ type, fromFile }, resolver) {
|
183
104
|
let resolvableExtensionsPattern = (0, _1.extensionsPattern)(resolver.options.resolvableExtensions);
|
184
105
|
const pkg = resolver.packageCache.ownerOfFile(fromFile);
|
185
106
|
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;AAqBA,wCA+CC;AA8CD,oDAMC;AAyBD,wCAOC;AAED,oDAcC;AAgCD,sDAcC;AAtND,+BAAoE;AAEpE,wBAAwD;AACxD,mDAA0C;AAC1C,iEAA8F;AAC9F,+EAAiG;AACjG,qDAAqE;AACrE,mEAAwF;AAExF,6DAA0E;AAC1E,yEAA0F;AAO1F,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAgB,EAAE,QAAkB;IACjE,IAAI,UAAU,GAAG,IAAA,qCAAgB,EAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAA,qCAAgB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,eAAe,GAAG,IAAA,gDAA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AAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,IAAa;IAC/C,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC","sourcesContent":["import { dirname, basename, resolve, posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\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":";;;;;AAkCA,wCAwBC;AA1DD,+BAAwC;AAExC,wBAAsC;AACtC,mDAA0C;AAC1C,iEAA6F;AAC7F,+EAAwG;AACxG,qDAA4E;AAC5E,mEAA+F;AAE/F,6DAAiF;AACjF,yEAAiG;AACjG,gEAAuC;AAmBvC,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,CA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AI,OAAO,EAAE,CAAC;QACZ,IAAI,QAAQ,GAAG,EAAgC,CAAC;QAChD,KAAK,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,IAAa;IAC/C,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC","sourcesContent":["import { posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { extensionsPattern } 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);\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 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"]}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { AppFiles, type RouteFiles } from './app-files';
|
2
2
|
import type { Resolver } from './module-resolver';
|
3
|
-
export
|
3
|
+
export interface EntrypointResponse {
|
4
|
+
type: 'entrypoint';
|
4
5
|
fromDir: string;
|
5
|
-
|
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
|
85
|
+
}, (routeNames) => {
|
102
86
|
lazyRoutes.push({
|
103
87
|
names: routeNames,
|
104
|
-
path: (0
|
88
|
+
path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,
|
105
89
|
});
|
106
90
|
});
|
107
91
|
}
|