@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.
- package/package.json +5 -5
- package/dist/src/app-files.d.ts +0 -34
- package/dist/src/app-files.d.ts.map +0 -1
- package/dist/src/app-files.js +0 -201
- package/dist/src/app-files.js.map +0 -1
- package/dist/src/describe-exports.d.ts +0 -5
- package/dist/src/describe-exports.d.ts.map +0 -1
- package/dist/src/describe-exports.js +0 -52
- package/dist/src/describe-exports.js.map +0 -1
- package/dist/src/html-entrypoint.d.ts +0 -23
- package/dist/src/html-entrypoint.d.ts.map +0 -1
- package/dist/src/html-entrypoint.js +0 -185
- package/dist/src/html-entrypoint.js.map +0 -1
- package/dist/src/html-placeholder.d.ts +0 -40
- package/dist/src/html-placeholder.d.ts.map +0 -1
- package/dist/src/html-placeholder.js +0 -130
- package/dist/src/html-placeholder.js.map +0 -1
- package/dist/src/index.d.ts +0 -15
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -50
- package/dist/src/index.js.map +0 -1
- package/dist/src/js-handlebars.d.ts +0 -2
- package/dist/src/js-handlebars.d.ts.map +0 -1
- package/dist/src/js-handlebars.js +0 -20
- package/dist/src/js-handlebars.js.map +0 -1
- package/dist/src/measure-concat.d.ts +0 -14
- package/dist/src/measure-concat.d.ts.map +0 -1
- package/dist/src/measure-concat.js +0 -33
- package/dist/src/measure-concat.js.map +0 -1
- package/dist/src/messages.d.ts +0 -9
- package/dist/src/messages.d.ts.map +0 -1
- package/dist/src/messages.js +0 -74
- package/dist/src/messages.js.map +0 -1
- package/dist/src/module-request.d.ts +0 -45
- package/dist/src/module-request.d.ts.map +0 -1
- package/dist/src/module-request.js +0 -87
- package/dist/src/module-request.js.map +0 -1
- package/dist/src/module-resolver-options.d.ts +0 -43
- package/dist/src/module-resolver-options.d.ts.map +0 -1
- package/dist/src/module-resolver-options.js +0 -155
- package/dist/src/module-resolver-options.js.map +0 -1
- package/dist/src/module-resolver.d.ts +0 -71
- package/dist/src/module-resolver.d.ts.map +0 -1
- package/dist/src/module-resolver.js +0 -1167
- package/dist/src/module-resolver.js.map +0 -1
- package/dist/src/node-resolve.d.ts +0 -36
- package/dist/src/node-resolve.d.ts.map +0 -1
- package/dist/src/node-resolve.js +0 -134
- package/dist/src/node-resolve.js.map +0 -1
- package/dist/src/options.d.ts +0 -26
- package/dist/src/options.d.ts.map +0 -1
- package/dist/src/options.js +0 -26
- package/dist/src/options.js.map +0 -1
- package/dist/src/packager.d.ts +0 -20
- package/dist/src/packager.d.ts.map +0 -1
- package/dist/src/packager.js +0 -34
- package/dist/src/packager.js.map +0 -1
- package/dist/src/portable.d.ts +0 -26
- package/dist/src/portable.d.ts.map +0 -1
- package/dist/src/portable.js +0 -231
- package/dist/src/portable.js.map +0 -1
- package/dist/src/resolvable-extensions.d.ts +0 -2
- package/dist/src/resolvable-extensions.d.ts.map +0 -1
- package/dist/src/resolvable-extensions.js +0 -13
- package/dist/src/resolvable-extensions.js.map +0 -1
- package/dist/src/resolver-loader.d.ts +0 -9
- package/dist/src/resolver-loader.d.ts.map +0 -1
- package/dist/src/resolver-loader.js +0 -54
- package/dist/src/resolver-loader.js.map +0 -1
- package/dist/src/stage.d.ts +0 -9
- package/dist/src/stage.d.ts.map +0 -1
- package/dist/src/stage.js +0 -3
- package/dist/src/stage.js.map +0 -1
- package/dist/src/virtual-content.d.ts +0 -36
- package/dist/src/virtual-content.d.ts.map +0 -1
- package/dist/src/virtual-content.js +0 -232
- package/dist/src/virtual-content.js.map +0 -1
- package/dist/src/virtual-entrypoint.d.ts +0 -22
- package/dist/src/virtual-entrypoint.d.ts.map +0 -1
- package/dist/src/virtual-entrypoint.js +0 -280
- package/dist/src/virtual-entrypoint.js.map +0 -1
- package/dist/src/virtual-route-entrypoint.d.ts +0 -11
- package/dist/src/virtual-route-entrypoint.d.ts.map +0 -1
- package/dist/src/virtual-route-entrypoint.js +0 -68
- package/dist/src/virtual-route-entrypoint.js.map +0 -1
- package/dist/src/virtual-test-support-styles.d.ts +0 -8
- package/dist/src/virtual-test-support-styles.d.ts.map +0 -1
- package/dist/src/virtual-test-support-styles.js +0 -61
- package/dist/src/virtual-test-support-styles.js.map +0 -1
- package/dist/src/virtual-test-support.d.ts +0 -8
- package/dist/src/virtual-test-support.d.ts.map +0 -1
- package/dist/src/virtual-test-support.js +0 -65
- package/dist/src/virtual-test-support.js.map +0 -1
- package/dist/src/virtual-vendor-styles.d.ts +0 -9
- package/dist/src/virtual-vendor-styles.d.ts.map +0 -1
- package/dist/src/virtual-vendor-styles.js +0 -84
- package/dist/src/virtual-vendor-styles.js.map +0 -1
- package/dist/src/virtual-vendor.d.ts +0 -8
- package/dist/src/virtual-vendor.d.ts.map +0 -1
- package/dist/src/virtual-vendor.js +0 -55
- package/dist/src/virtual-vendor.js.map +0 -1
- package/dist/src/wait-for-trees.d.ts +0 -14
- package/dist/src/wait-for-trees.d.ts.map +0 -1
- package/dist/src/wait-for-trees.js +0 -98
- package/dist/src/wait-for-trees.js.map +0 -1
- package/dist/tests/babel-debug-util.d.ts +0 -2
- package/dist/tests/babel-debug-util.d.ts.map +0 -1
- package/dist/tests/babel-debug-util.js +0 -36
- package/dist/tests/babel-debug-util.js.map +0 -1
- package/dist/tests/example-target.d.ts +0 -3
- package/dist/tests/example-target.d.ts.map +0 -1
- package/dist/tests/example-target.js +0 -10
- package/dist/tests/example-target.js.map +0 -1
- package/dist/tests/portable.test.d.ts +0 -2
- package/dist/tests/portable.test.d.ts.map +0 -1
- package/dist/tests/portable.test.js +0 -14
- package/dist/tests/portable.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/core",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A build system for EmberJS applications.",
|
|
6
6
|
"repository": {
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"semver": "^7.3.5",
|
|
63
63
|
"typescript-memoize": "^1.0.1",
|
|
64
64
|
"walk-sync": "^3.0.0",
|
|
65
|
-
"@embroider/macros": "1.21.0",
|
|
66
65
|
"@embroider/reverse-exports": "0.2.0",
|
|
67
|
-
"@embroider/shared-internals": "3.2.0"
|
|
66
|
+
"@embroider/shared-internals": "3.2.0",
|
|
67
|
+
"@embroider/macros": "1.21.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@glimmer/syntax": "^0.94.9",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"fixturify": "^2.1.1",
|
|
85
85
|
"tmp": "^0.1.0",
|
|
86
86
|
"typescript": "^5.4.5",
|
|
87
|
-
"embroider-
|
|
88
|
-
"
|
|
87
|
+
"@embroider/test-support": "0.36.0",
|
|
88
|
+
"embroider-sample-transforms": "0.0.0"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">= 20.19.*"
|
package/dist/src/app-files.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Package, AddonPackage } from '@embroider/shared-internals';
|
|
2
|
-
export interface RouteFiles {
|
|
3
|
-
route?: string;
|
|
4
|
-
template?: string;
|
|
5
|
-
controller?: string;
|
|
6
|
-
children: Map<string, RouteFiles>;
|
|
7
|
-
}
|
|
8
|
-
export declare class AppFiles {
|
|
9
|
-
readonly engine: Engine;
|
|
10
|
-
readonly components: ReadonlyArray<string>;
|
|
11
|
-
readonly helpers: ReadonlyArray<string>;
|
|
12
|
-
readonly modifiers: ReadonlyArray<string>;
|
|
13
|
-
private perRoute;
|
|
14
|
-
readonly otherAppFiles: ReadonlyArray<string>;
|
|
15
|
-
readonly isFastbootOnly: Map<string, boolean>;
|
|
16
|
-
readonly fastbootFiles: {
|
|
17
|
-
[appName: string]: {
|
|
18
|
-
localFilename: string;
|
|
19
|
-
shadowedFilename: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
constructor(engine: Engine, appFiles: Set<string>, fastbootFiles: Set<string>, resolvableExtensions: RegExp, staticAppPathsPattern: RegExp | undefined, podModulePrefix?: string);
|
|
23
|
-
private handleClassicRouteFile;
|
|
24
|
-
private handlePodsRouteFile;
|
|
25
|
-
get routeFiles(): Readonly<RouteFiles>;
|
|
26
|
-
}
|
|
27
|
-
export interface Engine {
|
|
28
|
-
package: Package;
|
|
29
|
-
addons: Map<AddonPackage, string>;
|
|
30
|
-
isApp: boolean;
|
|
31
|
-
modulePrefix: string;
|
|
32
|
-
appRelativePath: string;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=app-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-files.d.ts","sourceRoot":"","sources":["../../src/app-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEzE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAED,qBAAa,QAAQ;IAUjB,QAAQ,CAAC,MAAM,EAAE,MAAM;IATzB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAa;IAC7B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,CAAA;KAAE,CAAC;gBAGpG,MAAM,EAAE,MAAM,EACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EACrB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,EAC1B,oBAAoB,EAAE,MAAM,EAC5B,qBAAqB,EAAE,MAAM,GAAG,SAAS,EACzC,eAAe,CAAC,EAAE,MAAM;IAwJ1B,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,mBAAmB;IA+B3B,IAAI,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,CAErC;CACF;AAED,MAAM,WAAW,MAAM;IAErB,OAAO,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAElC,KAAK,EAAE,OAAO,CAAC;IAEf,YAAY,EAAE,MAAM,CAAC;IAErB,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/src/app-files.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppFiles = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
class AppFiles {
|
|
6
|
-
engine;
|
|
7
|
-
components;
|
|
8
|
-
helpers;
|
|
9
|
-
modifiers;
|
|
10
|
-
perRoute;
|
|
11
|
-
otherAppFiles;
|
|
12
|
-
isFastbootOnly;
|
|
13
|
-
fastbootFiles;
|
|
14
|
-
constructor(engine, appFiles, fastbootFiles, resolvableExtensions, staticAppPathsPattern, podModulePrefix) {
|
|
15
|
-
this.engine = engine;
|
|
16
|
-
let components = [];
|
|
17
|
-
let helpers = [];
|
|
18
|
-
let modifiers = [];
|
|
19
|
-
let otherAppFiles = [];
|
|
20
|
-
this.perRoute = { children: new Map() };
|
|
21
|
-
let combinedFiles = new Map();
|
|
22
|
-
let combinedNonFastbootFiles = new Map();
|
|
23
|
-
function add(map, filename) {
|
|
24
|
-
if (!resolvableExtensions.test(filename)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (/\.d\.ts$/.test(filename)) {
|
|
28
|
-
// .d.ts files are technically "*.ts" files but aren't really and we
|
|
29
|
-
// don't want to include them when we crawl through the app.
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
filename = filename.split(path_1.sep).join('/');
|
|
33
|
-
let extensionless = filename.replace(resolvableExtensions, '');
|
|
34
|
-
let prior = map.get(extensionless);
|
|
35
|
-
if (!prior) {
|
|
36
|
-
// no prior, so we win
|
|
37
|
-
map.set(extensionless, filename);
|
|
38
|
-
}
|
|
39
|
-
else if (prior.startsWith('components/') && prior.endsWith('.hbs') && !prior.endsWith('/template.hbs')) {
|
|
40
|
-
// The prior entry in combinedFiles is a colocated hbs component. The
|
|
41
|
-
// name "template.hbs" is special in the template colocation rules due
|
|
42
|
-
// to earlier pods patterns.
|
|
43
|
-
//
|
|
44
|
-
// colocated hbs never wins over the corresponding other resolvable js
|
|
45
|
-
// or ts.
|
|
46
|
-
map.set(extensionless, filename);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for (let f of appFiles) {
|
|
50
|
-
add(combinedFiles, f);
|
|
51
|
-
add(combinedNonFastbootFiles, f);
|
|
52
|
-
}
|
|
53
|
-
for (let f of fastbootFiles) {
|
|
54
|
-
add(combinedFiles, f);
|
|
55
|
-
}
|
|
56
|
-
for (let addon of engine.addons.keys()) {
|
|
57
|
-
let appJS = addon.meta['app-js'];
|
|
58
|
-
if (appJS) {
|
|
59
|
-
for (let filename of Object.keys(appJS)) {
|
|
60
|
-
filename = filename.replace(/^\.\//, '');
|
|
61
|
-
add(combinedFiles, filename);
|
|
62
|
-
add(combinedNonFastbootFiles, filename);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
let fastbootJS = addon.meta['fastboot-js'];
|
|
66
|
-
if (fastbootJS) {
|
|
67
|
-
for (let filename of Object.keys(fastbootJS)) {
|
|
68
|
-
filename = filename.replace(/^\.\//, '');
|
|
69
|
-
add(combinedFiles, filename);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
let isFastbootOnly = new Map();
|
|
74
|
-
for (let [extensionless, relativePath] of combinedFiles) {
|
|
75
|
-
isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(extensionless));
|
|
76
|
-
if (relativePath.startsWith('tests/')) {
|
|
77
|
-
// skip tests because they are dealt with separately
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (relativePath.startsWith('components/')) {
|
|
81
|
-
// hbs files are not resolvable when they're used via co-location with
|
|
82
|
-
// an associated js file because it's the js that is resolvable.
|
|
83
|
-
// An hbs file is used via colocation when it's inside the components
|
|
84
|
-
// directory, and also not named "template.hbs" (because that is an
|
|
85
|
-
// older pattern used with pods-like layouts).
|
|
86
|
-
let isHbs = relativePath.endsWith('.hbs');
|
|
87
|
-
if (!isHbs || relativePath.endsWith('/template.hbs')) {
|
|
88
|
-
components.push(relativePath);
|
|
89
|
-
}
|
|
90
|
-
else if (isHbs) {
|
|
91
|
-
// template-only components will be compiled as js files during the
|
|
92
|
-
// build process, so we push a virtual path to js in the list of files
|
|
93
|
-
// because the resolver will be able to recognize a template-only and
|
|
94
|
-
// give a correct answer in the end.
|
|
95
|
-
let jsPath = relativePath.replace(/\.hbs$/, '.js');
|
|
96
|
-
components.push(jsPath);
|
|
97
|
-
}
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (relativePath.startsWith('templates/components/')) {
|
|
101
|
-
components.push(relativePath);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (relativePath.startsWith('helpers/')) {
|
|
105
|
-
helpers.push(relativePath);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (relativePath.startsWith('modifiers/')) {
|
|
109
|
-
modifiers.push(relativePath);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if ((podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix)) ||
|
|
113
|
-
this.handleClassicRouteFile(relativePath)) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (staticAppPathsPattern) {
|
|
117
|
-
if (!staticAppPathsPattern.test(relativePath)) {
|
|
118
|
-
otherAppFiles.push(relativePath);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
otherAppFiles.push(relativePath);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
this.components = components;
|
|
126
|
-
this.helpers = helpers;
|
|
127
|
-
this.modifiers = modifiers;
|
|
128
|
-
this.otherAppFiles = otherAppFiles;
|
|
129
|
-
this.isFastbootOnly = isFastbootOnly;
|
|
130
|
-
// this deliberately only describes the app's fastboot files. Not the full
|
|
131
|
-
// merge from all the addons. This is because they need different handling
|
|
132
|
-
// in the module resolver -- addon fastboot files can always be a
|
|
133
|
-
// fallbackResolve, because if the app happens to define the same name
|
|
134
|
-
// (whether fastboot-specific or just browser) that wins over the addon.
|
|
135
|
-
// Whereas if the app itself defines a fastbot-specific version of a file,
|
|
136
|
-
// that must take precedence over the *normal* resolution, and must be
|
|
137
|
-
// implemented in beforeResolve.
|
|
138
|
-
this.fastbootFiles = Object.fromEntries([...fastbootFiles].map(name => [
|
|
139
|
-
`./${name}`,
|
|
140
|
-
{
|
|
141
|
-
localFilename: `./_fastboot_/${name}`,
|
|
142
|
-
shadowedFilename: appFiles.has(name) ? `./${name}` : undefined,
|
|
143
|
-
},
|
|
144
|
-
]));
|
|
145
|
-
}
|
|
146
|
-
handleClassicRouteFile(relativePath) {
|
|
147
|
-
let [prefix, ...rest] = relativePath.replace(/\.\w{1,3}$/, '').split('/');
|
|
148
|
-
if (!['controllers', 'templates', 'routes'].includes(prefix)) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
let type = prefix.slice(0, -1);
|
|
152
|
-
let cursor = this.perRoute;
|
|
153
|
-
for (let part of rest) {
|
|
154
|
-
let child = cursor.children.get(part);
|
|
155
|
-
if (child) {
|
|
156
|
-
cursor = child;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
let newEntry = { children: new Map() };
|
|
160
|
-
cursor.children.set(part, newEntry);
|
|
161
|
-
cursor = newEntry;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
cursor[type] = relativePath;
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
handlePodsRouteFile(relativePath, podModulePrefix) {
|
|
168
|
-
let parts = relativePath.replace(/\.\w{1,3}$/, '').split('/');
|
|
169
|
-
let type = parts.pop();
|
|
170
|
-
if (!type || !['controller', 'template', 'route'].includes(type)) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
let podParts = podModulePrefix.split('/');
|
|
174
|
-
// The first part of podModulePrefix is the app's package name
|
|
175
|
-
podParts.shift();
|
|
176
|
-
for (let podPart of podParts) {
|
|
177
|
-
if (parts.shift() !== podPart) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
let cursor = this.perRoute;
|
|
182
|
-
for (let part of parts) {
|
|
183
|
-
let child = cursor.children.get(part);
|
|
184
|
-
if (child) {
|
|
185
|
-
cursor = child;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
let newEntry = { children: new Map() };
|
|
189
|
-
cursor.children.set(part, newEntry);
|
|
190
|
-
cursor = newEntry;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
cursor[type] = relativePath;
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
get routeFiles() {
|
|
197
|
-
return this.perRoute;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
exports.AppFiles = AppFiles;
|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QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA9ND,4BA8NC","sourcesContent":["import { sep } from 'path';\nimport type { Package, AddonPackage } from '@embroider/shared-internals';\n\nexport interface RouteFiles {\n route?: string;\n template?: string;\n controller?: string;\n children: Map<string, RouteFiles>;\n}\n\nexport class AppFiles {\n readonly components: ReadonlyArray<string>;\n readonly helpers: ReadonlyArray<string>;\n readonly modifiers: ReadonlyArray<string>;\n private perRoute: RouteFiles;\n readonly otherAppFiles: ReadonlyArray<string>;\n readonly isFastbootOnly: Map<string, boolean>;\n readonly fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };\n\n constructor(\n readonly engine: Engine,\n appFiles: Set<string>,\n fastbootFiles: Set<string>,\n resolvableExtensions: RegExp,\n staticAppPathsPattern: RegExp | undefined,\n podModulePrefix?: string\n ) {\n let components: string[] = [];\n let helpers: string[] = [];\n let modifiers: string[] = [];\n let otherAppFiles: string[] = [];\n this.perRoute = { children: new Map() };\n\n let combinedFiles = new Map<string, string>();\n let combinedNonFastbootFiles = new Map<string, string>();\n\n function add(map: Map<string, string>, filename: string): void {\n if (!resolvableExtensions.test(filename)) {\n return;\n }\n\n if (/\\.d\\.ts$/.test(filename)) {\n // .d.ts files are technically \"*.ts\" files but aren't really and we\n // don't want to include them when we crawl through the app.\n return;\n }\n\n filename = filename.split(sep).join('/');\n\n let extensionless = filename.replace(resolvableExtensions, '');\n let prior = map.get(extensionless);\n\n if (!prior) {\n // no prior, so we win\n map.set(extensionless, filename);\n } else if (prior.startsWith('components/') && prior.endsWith('.hbs') && !prior.endsWith('/template.hbs')) {\n // The prior entry in combinedFiles is a colocated hbs component. The\n // name \"template.hbs\" is special in the template colocation rules due\n // to earlier pods patterns.\n //\n // colocated hbs never wins over the corresponding other resolvable js\n // or ts.\n map.set(extensionless, filename);\n }\n }\n\n for (let f of appFiles) {\n add(combinedFiles, f);\n add(combinedNonFastbootFiles, f);\n }\n for (let f of fastbootFiles) {\n add(combinedFiles, f);\n }\n\n for (let addon of engine.addons.keys()) {\n let appJS = addon.meta['app-js'];\n if (appJS) {\n for (let filename of Object.keys(appJS)) {\n filename = filename.replace(/^\\.\\//, '');\n add(combinedFiles, filename);\n add(combinedNonFastbootFiles, filename);\n }\n }\n\n let fastbootJS = addon.meta['fastboot-js'];\n if (fastbootJS) {\n for (let filename of Object.keys(fastbootJS)) {\n filename = filename.replace(/^\\.\\//, '');\n add(combinedFiles, filename);\n }\n }\n }\n\n let isFastbootOnly = new Map<string, boolean>();\n for (let [extensionless, relativePath] of combinedFiles) {\n isFastbootOnly.set(relativePath, !combinedNonFastbootFiles.has(extensionless));\n\n if (relativePath.startsWith('tests/')) {\n // skip tests because they are dealt with separately\n continue;\n }\n\n if (relativePath.startsWith('components/')) {\n // hbs files are not resolvable when they're used via co-location with\n // an associated js file because it's the js that is resolvable.\n // An hbs file is used via colocation when it's inside the components\n // directory, and also not named \"template.hbs\" (because that is an\n // older pattern used with pods-like layouts).\n let isHbs = relativePath.endsWith('.hbs');\n if (!isHbs || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\n } else if (isHbs) {\n // template-only components will be compiled as js files during the\n // build process, so we push a virtual path to js in the list of files\n // because the resolver will be able to recognize a template-only and\n // give a correct answer in the end.\n let jsPath = relativePath.replace(/\\.hbs$/, '.js');\n components.push(jsPath);\n }\n continue;\n }\n\n if (relativePath.startsWith('templates/components/')) {\n components.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('helpers/')) {\n helpers.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('modifiers/')) {\n modifiers.push(relativePath);\n continue;\n }\n\n if (\n (podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix)) ||\n this.handleClassicRouteFile(relativePath)\n ) {\n continue;\n }\n\n if (staticAppPathsPattern) {\n if (!staticAppPathsPattern.test(relativePath)) {\n otherAppFiles.push(relativePath);\n }\n } else {\n otherAppFiles.push(relativePath);\n }\n }\n this.components = components;\n this.helpers = helpers;\n this.modifiers = modifiers;\n this.otherAppFiles = otherAppFiles;\n this.isFastbootOnly = isFastbootOnly;\n\n // this deliberately only describes the app's fastboot files. Not the full\n // merge from all the addons. This is because they need different handling\n // in the module resolver -- addon fastboot files can always be a\n // fallbackResolve, because if the app happens to define the same name\n // (whether fastboot-specific or just browser) that wins over the addon.\n // Whereas if the app itself defines a fastbot-specific version of a file,\n // that must take precedence over the *normal* resolution, and must be\n // implemented in beforeResolve.\n this.fastbootFiles = Object.fromEntries(\n [...fastbootFiles].map(name => [\n `./${name}`,\n {\n localFilename: `./_fastboot_/${name}`,\n shadowedFilename: appFiles.has(name) ? `./${name}` : undefined,\n },\n ])\n );\n }\n\n private handleClassicRouteFile(relativePath: string): boolean {\n let [prefix, ...rest] = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n if (!['controllers', 'templates', 'routes'].includes(prefix)) {\n return false;\n }\n let type = prefix.slice(0, -1) as 'controller' | 'template' | 'route';\n let cursor = this.perRoute;\n for (let part of rest) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type] = relativePath;\n return true;\n }\n\n private handlePodsRouteFile(relativePath: string, podModulePrefix: string): boolean {\n let parts = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n let type = parts.pop();\n if (!type || !['controller', 'template', 'route'].includes(type)) {\n return false;\n }\n let podParts = podModulePrefix.split('/');\n // The first part of podModulePrefix is the app's package name\n podParts.shift();\n\n for (let podPart of podParts) {\n if (parts.shift() !== podPart) {\n return false;\n }\n }\n\n let cursor = this.perRoute;\n for (let part of parts) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type as 'controller' | 'template' | 'route'] = relativePath;\n return true;\n }\n\n get routeFiles(): Readonly<RouteFiles> {\n return this.perRoute;\n }\n}\n\nexport interface Engine {\n // the engine's own package\n package: Package;\n // the set of active addons in the engine. For each one we keep track of a file that can resolve the addon, because we'll need that later.\n addons: Map<AddonPackage, string>;\n // is this the top-level engine?\n isApp: boolean;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // TODO: remove this after we remove the stage2 entrypoint\n appRelativePath: string;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe-exports.d.ts","sourceRoot":"","sources":["../../src/describe-exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAOpD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CA0CzG"}
|
|
@@ -1,52 +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.describeExports = describeExports;
|
|
7
|
-
const core_1 = require("@babel/core");
|
|
8
|
-
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
9
|
-
const core_2 = require("@babel/core");
|
|
10
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
11
|
-
function describeExports(code, babelParserConfig) {
|
|
12
|
-
let ast = (0, core_1.parse)(code, babelParserConfig);
|
|
13
|
-
if (!ast || ast.type !== 'File') {
|
|
14
|
-
throw new Error(`bug in embroider/core describe-exports`);
|
|
15
|
-
}
|
|
16
|
-
let names = new Set();
|
|
17
|
-
(0, traverse_1.default)(ast, {
|
|
18
|
-
ExportNamedDeclaration(path) {
|
|
19
|
-
for (let spec of path.node.specifiers) {
|
|
20
|
-
switch (spec.type) {
|
|
21
|
-
case 'ExportSpecifier':
|
|
22
|
-
case 'ExportNamespaceSpecifier':
|
|
23
|
-
const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;
|
|
24
|
-
names.add(name);
|
|
25
|
-
break;
|
|
26
|
-
case 'ExportDefaultSpecifier':
|
|
27
|
-
// this is in the types but was never standardized
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
(0, assert_never_1.default)(spec);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (core_2.types.isVariableDeclaration(path.node.declaration)) {
|
|
34
|
-
for (let dec of path.node.declaration.declarations) {
|
|
35
|
-
if (core_2.types.isIdentifier(dec.id)) {
|
|
36
|
-
names.add(dec.id.name);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (core_2.types.isFunctionDeclaration(path.node.declaration) || core_2.types.isClassDeclaration(path.node.declaration)) {
|
|
41
|
-
if (core_2.types.isIdentifier(path.node.declaration.id)) {
|
|
42
|
-
names.add(path.node.declaration.id.name);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
ExportDefaultDeclaration(_path) {
|
|
47
|
-
names.add('default');
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
return { names };
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=describe-exports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe-exports.js","sourceRoot":"","sources":["../../src/describe-exports.ts"],"names":[],"mappings":";;;;;AAOA,0CA0CC;AAhDD,sCAAoC;AAEpC,+DAAuC;AACvC,sCAAyC;AACzC,gEAAuC;AAEvC,SAAgB,eAAe,CAAC,IAAY,EAAE,iBAAmC;IAC/E,IAAI,GAAG,GAAG,IAAA,YAAK,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,K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AC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC7C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC;QACD,wBAAwB,CAAC,KAA2C;YAClE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC","sourcesContent":["import type { TransformOptions } from '@babel/core';\nimport { parse } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport { types as t } from '@babel/core';\nimport assertNever from 'assert-never';\n\nexport function describeExports(code: string, babelParserConfig: TransformOptions): { names: Set<string> } {\n let ast = parse(code, babelParserConfig);\n if (!ast || ast.type !== 'File') {\n throw new Error(`bug in embroider/core describe-exports`);\n }\n let names: Set<string> = new Set();\n\n traverse(ast, {\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n for (let spec of path.node.specifiers) {\n switch (spec.type) {\n case 'ExportSpecifier':\n case 'ExportNamespaceSpecifier':\n const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;\n\n names.add(name);\n break;\n case 'ExportDefaultSpecifier':\n // this is in the types but was never standardized\n break;\n default:\n assertNever(spec);\n }\n }\n if (t.isVariableDeclaration(path.node.declaration)) {\n for (let dec of path.node.declaration.declarations) {\n if (t.isIdentifier(dec.id)) {\n names.add(dec.id.name);\n }\n }\n }\n if (t.isFunctionDeclaration(path.node.declaration) || t.isClassDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n names.add(path.node.declaration.id.name);\n }\n }\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n names.add('default');\n },\n });\n return { names };\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Variant } from './packager';
|
|
2
|
-
export declare class HTMLEntrypoint {
|
|
3
|
-
private pathToVanillaApp;
|
|
4
|
-
private rootURL;
|
|
5
|
-
private publicAssetURL;
|
|
6
|
-
filename: string;
|
|
7
|
-
private dom;
|
|
8
|
-
private placeholders;
|
|
9
|
-
modules: string[];
|
|
10
|
-
scripts: string[];
|
|
11
|
-
styles: string[];
|
|
12
|
-
constructor(pathToVanillaApp: string, rootURL: string, publicAssetURL: string, filename: string);
|
|
13
|
-
private relativeToApp;
|
|
14
|
-
private handledScripts;
|
|
15
|
-
private handledStyles;
|
|
16
|
-
render(stats: BundleSummary): string;
|
|
17
|
-
}
|
|
18
|
-
export interface BundleSummary {
|
|
19
|
-
entrypoints: Map<string, Map<number, string[]>>;
|
|
20
|
-
lazyBundles: Map<string, string[]>;
|
|
21
|
-
variants: Variant[];
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=html-entrypoint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-entrypoint.d.ts","sourceRoot":"","sources":["../../src/html-entrypoint.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,qBAAa,cAAc;IAQvB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IACf,QAAQ,EAAE,MAAM;IAVzB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAM;IACvB,OAAO,EAAE,MAAM,EAAE,CAAM;IACvB,MAAM,EAAE,MAAM,EAAE,CAAM;gBAGZ,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM;IAgCzB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,aAAa;IAYrB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM;CA2ErC;AAED,MAAM,WAAW,aAAa;IAK5B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAShD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAEnC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB"}
|
|
@@ -1,185 +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.HTMLEntrypoint = void 0;
|
|
7
|
-
const shared_internals_1 = require("@embroider/shared-internals");
|
|
8
|
-
const fs_extra_1 = require("fs-extra");
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
const jsdom_1 = require("jsdom");
|
|
11
|
-
const partition_1 = __importDefault(require("lodash/partition"));
|
|
12
|
-
const zip_1 = __importDefault(require("lodash/zip"));
|
|
13
|
-
const html_placeholder_1 = __importDefault(require("./html-placeholder"));
|
|
14
|
-
class HTMLEntrypoint {
|
|
15
|
-
pathToVanillaApp;
|
|
16
|
-
rootURL;
|
|
17
|
-
publicAssetURL;
|
|
18
|
-
filename;
|
|
19
|
-
dom;
|
|
20
|
-
placeholders = new Map();
|
|
21
|
-
modules = [];
|
|
22
|
-
scripts = [];
|
|
23
|
-
styles = [];
|
|
24
|
-
constructor(pathToVanillaApp, rootURL, publicAssetURL, filename) {
|
|
25
|
-
this.pathToVanillaApp = pathToVanillaApp;
|
|
26
|
-
this.rootURL = rootURL;
|
|
27
|
-
this.publicAssetURL = publicAssetURL;
|
|
28
|
-
this.filename = filename;
|
|
29
|
-
this.dom = new jsdom_1.JSDOM((0, fs_extra_1.readFileSync)((0, path_1.join)(this.pathToVanillaApp, this.filename), 'utf8'));
|
|
30
|
-
for (let tag of this.handledStyles()) {
|
|
31
|
-
let styleTag = tag;
|
|
32
|
-
let href = styleTag.href;
|
|
33
|
-
if (!isAbsoluteURL(href)) {
|
|
34
|
-
let url = this.relativeToApp(href);
|
|
35
|
-
this.styles.push(url);
|
|
36
|
-
let placeholder = new html_placeholder_1.default(styleTag);
|
|
37
|
-
let list = (0, shared_internals_1.getOrCreate)(this.placeholders, url, () => []);
|
|
38
|
-
list.push(placeholder);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
for (let scriptTag of this.handledScripts()) {
|
|
42
|
-
// scriptTag.src include rootURL. Convert it to be relative to the app.
|
|
43
|
-
let src = this.relativeToApp(scriptTag.src);
|
|
44
|
-
if (scriptTag.type === 'module') {
|
|
45
|
-
this.modules.push(src);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.scripts.push(src);
|
|
49
|
-
}
|
|
50
|
-
let placeholder = new html_placeholder_1.default(scriptTag);
|
|
51
|
-
let list = (0, shared_internals_1.getOrCreate)(this.placeholders, src, () => []);
|
|
52
|
-
list.push(placeholder);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
relativeToApp(rootRelativeURL) {
|
|
56
|
-
return rootRelativeURL.replace(this.rootURL, '');
|
|
57
|
-
}
|
|
58
|
-
handledScripts() {
|
|
59
|
-
let scriptTags = [...this.dom.window.document.querySelectorAll('script')];
|
|
60
|
-
let [ignoredScriptTags, handledScriptTags] = (0, partition_1.default)(scriptTags, scriptTag => {
|
|
61
|
-
return !scriptTag.src || scriptTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(scriptTag.src);
|
|
62
|
-
});
|
|
63
|
-
for (let scriptTag of ignoredScriptTags) {
|
|
64
|
-
scriptTag.removeAttribute('data-embroider-ignore');
|
|
65
|
-
}
|
|
66
|
-
return handledScriptTags;
|
|
67
|
-
}
|
|
68
|
-
handledStyles() {
|
|
69
|
-
let styleTags = [...this.dom.window.document.querySelectorAll('link[rel*="stylesheet"]')];
|
|
70
|
-
let [ignoredStyleTags, handledStyleTags] = (0, partition_1.default)(styleTags, styleTag => {
|
|
71
|
-
return !styleTag.href || styleTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(styleTag.href);
|
|
72
|
-
});
|
|
73
|
-
for (let styleTag of ignoredStyleTags) {
|
|
74
|
-
styleTag.removeAttribute('data-embroider-ignore');
|
|
75
|
-
}
|
|
76
|
-
return handledStyleTags;
|
|
77
|
-
}
|
|
78
|
-
// bundles maps from input asset to a per-variant map of output assets
|
|
79
|
-
render(stats) {
|
|
80
|
-
let insertedLazy = new Set();
|
|
81
|
-
let fastbootVariant = stats.variants.findIndex(v => Boolean(v.runtime === 'fastboot'));
|
|
82
|
-
let supportsFastboot = stats.variants.some(v => v.runtime === 'fastboot' || v.runtime === 'all');
|
|
83
|
-
for (let [src, placeholders] of this.placeholders) {
|
|
84
|
-
let match = stats.entrypoints.get(src);
|
|
85
|
-
if (match) {
|
|
86
|
-
let firstVariant = stats.variants.findIndex((_, index) => Boolean(match.get(index)));
|
|
87
|
-
let matchingBundles = match.get(firstVariant);
|
|
88
|
-
let matchingFastbootBundles = fastbootVariant >= 0 ? match.get(fastbootVariant) || [] : [];
|
|
89
|
-
for (let placeholder of placeholders) {
|
|
90
|
-
placeholder.clear();
|
|
91
|
-
if (supportsFastboot && placeholder.isScript()) {
|
|
92
|
-
// if there is any fastboot involved, we will emit the lazy bundles
|
|
93
|
-
// right before our first script.
|
|
94
|
-
let lazyMatch = stats.lazyBundles.get(src);
|
|
95
|
-
if (lazyMatch && !insertedLazy.has(src)) {
|
|
96
|
-
insertLazyJavascript(lazyMatch, placeholder, this.rootURL);
|
|
97
|
-
insertLazyStyles(lazyMatch, placeholder, this.publicAssetURL);
|
|
98
|
-
insertedLazy.add(src);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
for (let [base, fastboot] of (0, zip_1.default)(matchingBundles, matchingFastbootBundles)) {
|
|
102
|
-
if (supportsFastboot) {
|
|
103
|
-
// the fastboot version gets prefixed with the rootURL, which
|
|
104
|
-
// points to our local build directory, because that's where
|
|
105
|
-
// fastboot always loads scripts from. If there's no
|
|
106
|
-
// fastboot-specific variant, fastboot loads the base variant, but
|
|
107
|
-
// still from rootURL rather than publicAssetURL.
|
|
108
|
-
fastboot = this.rootURL + (fastboot ?? base);
|
|
109
|
-
}
|
|
110
|
-
if (base) {
|
|
111
|
-
// the browser version gets prefixed with the publicAssetURL
|
|
112
|
-
// because that's where browsers will load it from
|
|
113
|
-
base = this.publicAssetURL + base;
|
|
114
|
-
}
|
|
115
|
-
if (!base) {
|
|
116
|
-
// this bundle only exists in the fastboot variant
|
|
117
|
-
let element = placeholder.start.ownerDocument.createElement('fastboot-script');
|
|
118
|
-
element.setAttribute('src', fastboot);
|
|
119
|
-
placeholder.insert(element);
|
|
120
|
-
placeholder.insertNewline();
|
|
121
|
-
}
|
|
122
|
-
else if (!fastboot) {
|
|
123
|
-
// no fastboot variant
|
|
124
|
-
placeholder.insertURL(base);
|
|
125
|
-
}
|
|
126
|
-
else if (fastboot === base) {
|
|
127
|
-
// fastboot variant happens to be exactly the same bundle as base
|
|
128
|
-
// (and publicAssetURL===rootURL), so a plain script tag covers
|
|
129
|
-
// both
|
|
130
|
-
placeholder.insertURL(base);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// we have both and they differ
|
|
134
|
-
let element = placeholder.insertURL(base);
|
|
135
|
-
if (element) {
|
|
136
|
-
element.setAttribute('data-fastboot-src', fastboot);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
// no match means keep the original HTML content for this placeholder.
|
|
144
|
-
// (If we really wanted it empty instead, there would be matchingBundles
|
|
145
|
-
// and it would be an empty list.)
|
|
146
|
-
for (let placeholder of placeholders) {
|
|
147
|
-
placeholder.reset();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return this.dom.serialize();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.HTMLEntrypoint = HTMLEntrypoint;
|
|
155
|
-
function isAbsoluteURL(url) {
|
|
156
|
-
return /^(?:[a-z]+:)?\/\//i.test(url);
|
|
157
|
-
}
|
|
158
|
-
// we (somewhat arbitrarily) decide to put the lazy javascript bundles before
|
|
159
|
-
// the very first <script> that we have rewritten
|
|
160
|
-
function insertLazyJavascript(lazyBundles, placeholder, rootURL) {
|
|
161
|
-
for (let bundle of lazyBundles) {
|
|
162
|
-
if (bundle.endsWith('.js')) {
|
|
163
|
-
let element = placeholder.start.ownerDocument.createElement('fastboot-script');
|
|
164
|
-
// we're using rootURL instead of publicAssetURL here because
|
|
165
|
-
// <fastboot-script> is executed by fastboot, which always loads them from
|
|
166
|
-
// the local build directory. NOT from the publicAssetURL that browsers
|
|
167
|
-
// will use, which could be a CDN.
|
|
168
|
-
element.setAttribute('src', rootURL + bundle);
|
|
169
|
-
placeholder.insert(element);
|
|
170
|
-
placeholder.insertNewline();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function insertLazyStyles(lazyBundles, placeholder, publicAssetURL) {
|
|
175
|
-
for (let bundle of lazyBundles) {
|
|
176
|
-
if (bundle.endsWith('.css')) {
|
|
177
|
-
let element = placeholder.start.ownerDocument.createElement('link');
|
|
178
|
-
element.setAttribute('href', publicAssetURL + bundle);
|
|
179
|
-
element.setAttribute('rel', 'stylesheet');
|
|
180
|
-
placeholder.insert(element);
|
|
181
|
-
placeholder.insertNewline();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
//# sourceMappingURL=html-entrypoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-entrypoint.js","sourceRoot":"","sources":["../../src/html-entrypoint.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0D;AAC1D,uCAA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nimport { join } from 'path';\nimport { JSDOM } from 'jsdom';\nimport partition from 'lodash/partition';\nimport zip from 'lodash/zip';\nimport Placeholder from './html-placeholder';\nimport type { Variant } from './packager';\n\nexport class HTMLEntrypoint {\n private dom: JSDOM;\n private placeholders: Map<string, Placeholder[]> = new Map();\n modules: string[] = [];\n scripts: string[] = [];\n styles: string[] = [];\n\n constructor(\n private pathToVanillaApp: string,\n private rootURL: string,\n private publicAssetURL: string,\n public filename: string\n ) {\n this.dom = new JSDOM(readFileSync(join(this.pathToVanillaApp, this.filename), 'utf8'));\n\n for (let tag of this.handledStyles()) {\n let styleTag = tag as HTMLLinkElement;\n let href = styleTag.href;\n if (!isAbsoluteURL(href)) {\n let url = this.relativeToApp(href);\n this.styles.push(url);\n let placeholder = new Placeholder(styleTag);\n let list = getOrCreate(this.placeholders, url, () => []);\n list.push(placeholder);\n }\n }\n\n for (let scriptTag of this.handledScripts()) {\n // scriptTag.src include rootURL. Convert it to be relative to the app.\n let src = this.relativeToApp(scriptTag.src);\n\n if (scriptTag.type === 'module') {\n this.modules.push(src);\n } else {\n this.scripts.push(src);\n }\n\n let placeholder = new Placeholder(scriptTag);\n let list = getOrCreate(this.placeholders, src, () => []);\n list.push(placeholder);\n }\n }\n\n private relativeToApp(rootRelativeURL: string) {\n return rootRelativeURL.replace(this.rootURL, '');\n }\n\n private handledScripts() {\n let scriptTags = [...this.dom.window.document.querySelectorAll('script')] as HTMLScriptElement[];\n let [ignoredScriptTags, handledScriptTags] = partition(scriptTags, scriptTag => {\n return !scriptTag.src || scriptTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(scriptTag.src);\n });\n for (let scriptTag of ignoredScriptTags) {\n scriptTag.removeAttribute('data-embroider-ignore');\n }\n return handledScriptTags;\n }\n\n private handledStyles() {\n let styleTags = [...this.dom.window.document.querySelectorAll('link[rel*=\"stylesheet\"]')] as HTMLLinkElement[];\n let [ignoredStyleTags, handledStyleTags] = partition(styleTags, styleTag => {\n return !styleTag.href || styleTag.hasAttribute('data-embroider-ignore') || isAbsoluteURL(styleTag.href);\n });\n for (let styleTag of ignoredStyleTags) {\n styleTag.removeAttribute('data-embroider-ignore');\n }\n return handledStyleTags;\n }\n\n // bundles maps from input asset to a per-variant map of output assets\n render(stats: BundleSummary): string {\n let insertedLazy = new Set<string>();\n let fastbootVariant = stats.variants.findIndex(v => Boolean(v.runtime === 'fastboot'));\n let supportsFastboot = stats.variants.some(v => v.runtime === 'fastboot' || v.runtime === 'all');\n\n for (let [src, placeholders] of this.placeholders) {\n let match = stats.entrypoints.get(src);\n if (match) {\n let firstVariant = stats.variants.findIndex((_, index) => Boolean(match!.get(index)));\n let matchingBundles = match.get(firstVariant)!;\n let matchingFastbootBundles = fastbootVariant >= 0 ? match.get(fastbootVariant) || [] : [];\n\n for (let placeholder of placeholders) {\n placeholder.clear();\n if (supportsFastboot && placeholder.isScript()) {\n // if there is any fastboot involved, we will emit the lazy bundles\n // right before our first script.\n\n let lazyMatch = stats.lazyBundles.get(src);\n if (lazyMatch && !insertedLazy.has(src)) {\n insertLazyJavascript(lazyMatch, placeholder, this.rootURL);\n insertLazyStyles(lazyMatch, placeholder, this.publicAssetURL);\n insertedLazy.add(src);\n }\n }\n for (let [base, fastboot] of zip(matchingBundles, matchingFastbootBundles)) {\n if (supportsFastboot) {\n // the fastboot version gets prefixed with the rootURL, which\n // points to our local build directory, because that's where\n // fastboot always loads scripts from. If there's no\n // fastboot-specific variant, fastboot loads the base variant, but\n // still from rootURL rather than publicAssetURL.\n fastboot = this.rootURL + (fastboot ?? base);\n }\n\n if (base) {\n // the browser version gets prefixed with the publicAssetURL\n // because that's where browsers will load it from\n base = this.publicAssetURL + base;\n }\n\n if (!base) {\n // this bundle only exists in the fastboot variant\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n element.setAttribute('src', fastboot!);\n placeholder.insert(element);\n placeholder.insertNewline();\n } else if (!fastboot) {\n // no fastboot variant\n placeholder.insertURL(base);\n } else if (fastboot === base) {\n // fastboot variant happens to be exactly the same bundle as base\n // (and publicAssetURL===rootURL), so a plain script tag covers\n // both\n placeholder.insertURL(base);\n } else {\n // we have both and they differ\n let element = placeholder.insertURL(base);\n if (element) {\n element.setAttribute('data-fastboot-src', fastboot);\n }\n }\n }\n }\n } else {\n // no match means keep the original HTML content for this placeholder.\n // (If we really wanted it empty instead, there would be matchingBundles\n // and it would be an empty list.)\n for (let placeholder of placeholders) {\n placeholder.reset();\n }\n }\n }\n return this.dom.serialize();\n }\n}\n\nexport interface BundleSummary {\n // entrypoints.get(inputAsset).get(variantIndex) === outputAssets\n //\n // these are the output assets that are needed eagerly to boot the given input\n // asset\n entrypoints: Map<string, Map<number, string[]>>;\n\n // lazyBundles.get(inputAsset) === lazyOutputAssets\n //\n // these are the output assets that might be loaded lazyily at runtime by the\n // given input asset.\n //\n // These are tracked specifically for the fastboot variant, because that's\n // where we need to be responsble for them.\n lazyBundles: Map<string, string[]>;\n\n variants: Variant[];\n}\n\nfunction isAbsoluteURL(url: string) {\n return /^(?:[a-z]+:)?\\/\\//i.test(url);\n}\n\n// we (somewhat arbitrarily) decide to put the lazy javascript bundles before\n// the very first <script> that we have rewritten\nfunction insertLazyJavascript(lazyBundles: string[], placeholder: Placeholder, rootURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.js')) {\n let element = placeholder.start.ownerDocument.createElement('fastboot-script');\n // we're using rootURL instead of publicAssetURL here because\n // <fastboot-script> is executed by fastboot, which always loads them from\n // the local build directory. NOT from the publicAssetURL that browsers\n // will use, which could be a CDN.\n element.setAttribute('src', rootURL + bundle);\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n\nfunction insertLazyStyles(lazyBundles: string[], placeholder: Placeholder, publicAssetURL: string) {\n for (let bundle of lazyBundles) {\n if (bundle.endsWith('.css')) {\n let element = placeholder.start.ownerDocument.createElement('link');\n element.setAttribute('href', publicAssetURL + bundle);\n element.setAttribute('rel', 'stylesheet');\n placeholder.insert(element);\n placeholder.insertNewline();\n }\n }\n}\n"]}
|