@embroider/compat 3.4.9 → 3.5.1-unstable.14b84ff
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 +13 -13
- package/src/audit/babel-visitor.js +5 -3
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit/build.js.map +1 -1
- package/src/audit-cli.js.map +1 -1
- package/src/audit.d.ts +6 -54
- package/src/audit.js +86 -275
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.d.ts +2 -1
- package/src/babel-plugin-adjust-imports.js +1 -1
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/build-compat-addon.js.map +1 -1
- package/src/compat-adapters/@ember/test-waiters.js.map +1 -1
- package/src/compat-adapters/@ember-data/store.d.ts +1 -5
- package/src/compat-adapters/@ember-data/store.js +3 -15
- package/src/compat-adapters/@ember-data/store.js.map +1 -1
- package/src/compat-adapters/ember-asset-loader.js.map +1 -1
- package/src/compat-adapters/ember-cli-babel.js.map +1 -1
- package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
- package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
- package/src/compat-adapters/ember-composable-helpers.js.map +1 -1
- package/src/compat-adapters/ember-data.js.map +1 -1
- package/src/compat-adapters/ember-engines.js.map +1 -1
- package/src/compat-adapters/ember-fetch.d.ts +5 -0
- package/src/compat-adapters/ember-fetch.js +19 -0
- package/src/compat-adapters/ember-fetch.js.map +1 -0
- package/src/compat-adapters/ember-macro-helpers.js.map +1 -1
- package/src/compat-adapters/ember-scroll-modifiers.js.map +1 -1
- package/src/compat-adapters/ember-source.js +20 -2
- package/src/compat-adapters/ember-source.js.map +1 -1
- package/src/compat-adapters/ember-svg-jar.js.map +1 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app-builder.d.ts +7 -17
- package/src/compat-app-builder.js +94 -559
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +2 -3
- package/src/compat-app.js +60 -20
- package/src/compat-app.js.map +1 -1
- package/src/compat-utils.js.map +1 -1
- package/src/content-for-config.d.ts +11 -0
- package/src/content-for-config.js +66 -0
- package/src/content-for-config.js.map +1 -0
- package/src/dasherize-component-name.js.map +1 -1
- package/src/default-pipeline.d.ts +2 -2
- package/src/default-pipeline.js +22 -1
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.js.map +1 -1
- package/src/detect-babel-plugins.js.map +1 -1
- package/src/detect-compact-reexports.js.map +1 -1
- package/src/dummy-package.js.map +1 -1
- package/src/empty-package-tree.js.map +1 -1
- package/src/get-real-addon.js.map +1 -1
- package/src/hbs-to-js-broccoli-plugin.js.map +1 -1
- package/src/http-audit.d.ts +13 -0
- package/src/http-audit.js +46 -0
- package/src/http-audit.js.map +1 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/merges.js.map +1 -1
- package/src/module-visitor.d.ts +53 -0
- package/src/module-visitor.js +286 -0
- package/src/module-visitor.js.map +1 -0
- package/src/options.d.ts +1 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/prepare-htmlbars-ast-plugins.js.map +1 -1
- package/src/rename-require-plugin.js.map +1 -1
- package/src/resolver-transform.js +3 -0
- package/src/resolver-transform.js.map +1 -1
- package/src/rewrite-addon-tree.js.map +1 -1
- package/src/smoosh-package-json.js.map +1 -1
- package/src/snitch.js.map +1 -1
- package/src/standalone-addon-build.js.map +1 -1
- package/src/sync-dir.js.map +1 -1
- package/src/synthesize-template-only-components.js.map +1 -1
- package/src/v1-addon.js.map +1 -1
- package/src/v1-appboot.js.map +1 -1
- package/src/v1-config.js.map +1 -1
- package/src/v1-instance-cache.js.map +1 -1
- package/LICENSE +0 -21
- package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
- package/src/compat-adapters/@ember-data/debug.js +0 -22
- package/src/compat-adapters/@ember-data/debug.js.map +0 -1
|
@@ -1,49 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
10
|
};
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.CompatAppBuilder = void 0;
|
|
36
13
|
const core_1 = require("@embroider/core");
|
|
37
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
38
14
|
const path_1 = require("path");
|
|
39
15
|
const dependency_rules_1 = require("./dependency-rules");
|
|
40
16
|
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
41
|
-
const sortBy_1 = __importDefault(require("lodash/sortBy"));
|
|
42
|
-
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
43
|
-
const partition_1 = __importDefault(require("lodash/partition"));
|
|
44
17
|
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
45
18
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
46
|
-
const resolve_1 = require("resolve");
|
|
47
19
|
const bind_decorator_1 = __importDefault(require("bind-decorator"));
|
|
48
20
|
const fs_extra_1 = require("fs-extra");
|
|
49
21
|
const ember_html_1 = require("@embroider/core/src/ember-html");
|
|
@@ -53,22 +25,22 @@ const portable_1 = require("@embroider/core/src/portable");
|
|
|
53
25
|
const assert_never_1 = __importDefault(require("assert-never"));
|
|
54
26
|
const typescript_memoize_1 = require("typescript-memoize");
|
|
55
27
|
const path_2 = require("path");
|
|
56
|
-
const
|
|
28
|
+
const resolve_1 = __importDefault(require("resolve"));
|
|
57
29
|
const fs_extra_2 = require("fs-extra");
|
|
58
30
|
const node_1 = require("@embroider/macros/src/node");
|
|
59
|
-
const fast_sourcemap_concat_1 = __importDefault(require("fast-sourcemap-concat"));
|
|
60
31
|
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
|
|
61
32
|
const sync_dir_1 = require("./sync-dir");
|
|
62
33
|
// This exists during the actual broccoli build step. As opposed to CompatApp,
|
|
63
34
|
// which also exists during pipeline-construction time.
|
|
64
35
|
class CompatAppBuilder {
|
|
65
|
-
constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, synthVendor, synthStyles) {
|
|
36
|
+
constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, contentForTree, synthVendor, synthStyles) {
|
|
66
37
|
this.root = root;
|
|
67
38
|
this.origAppPackage = origAppPackage;
|
|
68
39
|
this.appPackageWithMovedDeps = appPackageWithMovedDeps;
|
|
69
40
|
this.options = options;
|
|
70
41
|
this.compatApp = compatApp;
|
|
71
42
|
this.configTree = configTree;
|
|
43
|
+
this.contentForTree = contentForTree;
|
|
72
44
|
this.synthVendor = synthVendor;
|
|
73
45
|
this.synthStyles = synthStyles;
|
|
74
46
|
// for each relativePath, an Asset we have already emitted
|
|
@@ -83,52 +55,11 @@ class CompatAppBuilder {
|
|
|
83
55
|
}
|
|
84
56
|
extractAssets(treePaths) {
|
|
85
57
|
let assets = [];
|
|
86
|
-
// Everything in our traditional public tree is an on-disk asset
|
|
87
|
-
if (treePaths.publicTree) {
|
|
88
|
-
walk_sync_1.default
|
|
89
|
-
.entries(treePaths.publicTree, {
|
|
90
|
-
directories: false,
|
|
91
|
-
})
|
|
92
|
-
.forEach(entry => {
|
|
93
|
-
assets.push({
|
|
94
|
-
kind: 'on-disk',
|
|
95
|
-
relativePath: entry.relativePath,
|
|
96
|
-
sourcePath: entry.fullPath,
|
|
97
|
-
mtime: entry.mtime,
|
|
98
|
-
size: entry.size,
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// ember-cli traditionally outputs a dummy testem.js file to prevent
|
|
103
|
-
// spurious errors when running tests under "ember s".
|
|
104
|
-
if (this.compatApp.shouldBuildTests) {
|
|
105
|
-
let testemAsset = this.findTestemAsset();
|
|
106
|
-
if (testemAsset) {
|
|
107
|
-
assets.push(testemAsset);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
58
|
for (let asset of this.emberEntrypoints(treePaths.htmlTree)) {
|
|
111
59
|
assets.push(asset);
|
|
112
60
|
}
|
|
113
61
|
return assets;
|
|
114
62
|
}
|
|
115
|
-
findTestemAsset() {
|
|
116
|
-
let sourcePath;
|
|
117
|
-
try {
|
|
118
|
-
sourcePath = (0, resolve_1.sync)('ember-cli/lib/broccoli/testem.js', { basedir: this.root });
|
|
119
|
-
}
|
|
120
|
-
catch (err) { }
|
|
121
|
-
if (sourcePath) {
|
|
122
|
-
let stat = (0, fs_extra_1.statSync)(sourcePath);
|
|
123
|
-
return {
|
|
124
|
-
kind: 'on-disk',
|
|
125
|
-
relativePath: 'testem.js',
|
|
126
|
-
sourcePath,
|
|
127
|
-
mtime: stat.mtime.getTime(),
|
|
128
|
-
size: stat.size,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
63
|
activeAddonChildren(pkg) {
|
|
133
64
|
let result = pkg.dependencies.filter(this.isActiveAddon).filter(
|
|
134
65
|
// When looking for child addons, we want to ignore 'peerDependencies' of
|
|
@@ -177,7 +108,7 @@ class CompatAppBuilder {
|
|
|
177
108
|
// For TS, we defer to ember-cli-babel, and the setting for
|
|
178
109
|
// "enableTypescriptTransform" can be set with and without
|
|
179
110
|
// ember-cli-typescript
|
|
180
|
-
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];
|
|
111
|
+
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js', '.gjs', '.gts'];
|
|
181
112
|
}
|
|
182
113
|
*emberEntrypoints(htmlTreePath) {
|
|
183
114
|
let classicEntrypoints = [
|
|
@@ -205,10 +136,7 @@ class CompatAppBuilder {
|
|
|
205
136
|
javascript: this.compatApp.findAppScript(scripts, entrypoint),
|
|
206
137
|
styles: this.compatApp.findAppStyles(styles, entrypoint),
|
|
207
138
|
implicitScripts: this.compatApp.findVendorScript(scripts, entrypoint),
|
|
208
|
-
implicitStyles: this.compatApp.findVendorStyles(styles, entrypoint),
|
|
209
139
|
testJavascript: this.compatApp.findTestScript(scripts),
|
|
210
|
-
implicitTestScripts: this.compatApp.findTestSupportScript(scripts),
|
|
211
|
-
implicitTestStyles: this.compatApp.findTestSupportStyles(styles),
|
|
212
140
|
};
|
|
213
141
|
},
|
|
214
142
|
};
|
|
@@ -233,10 +161,6 @@ class CompatAppBuilder {
|
|
|
233
161
|
resolverConfig(engines) {
|
|
234
162
|
let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
235
163
|
let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
236
|
-
let activeAddons = {};
|
|
237
|
-
for (let addon of this.allActiveAddons) {
|
|
238
|
-
activeAddons[addon.name] = addon.root;
|
|
239
|
-
}
|
|
240
164
|
let options = {
|
|
241
165
|
staticHelpers: this.options.staticHelpers,
|
|
242
166
|
staticModifiers: this.options.staticModifiers,
|
|
@@ -245,7 +169,6 @@ class CompatAppBuilder {
|
|
|
245
169
|
};
|
|
246
170
|
let config = {
|
|
247
171
|
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
248
|
-
activeAddons,
|
|
249
172
|
renameModules,
|
|
250
173
|
renamePackages,
|
|
251
174
|
resolvableExtensions: this.resolvableExtensions(),
|
|
@@ -257,118 +180,34 @@ class CompatAppBuilder {
|
|
|
257
180
|
root: (0, fs_extra_1.realpathSync)(index === 0 ? this.root : appFiles.engine.package.root),
|
|
258
181
|
fastbootFiles: appFiles.fastbootFiles,
|
|
259
182
|
activeAddons: [...appFiles.engine.addons]
|
|
260
|
-
.map(
|
|
261
|
-
name:
|
|
262
|
-
root:
|
|
183
|
+
.map(([addon, canResolveFromFile]) => ({
|
|
184
|
+
name: addon.name,
|
|
185
|
+
root: addon.root,
|
|
186
|
+
canResolveFromFile,
|
|
263
187
|
}))
|
|
264
188
|
// the traditional order is the order in which addons will run, such
|
|
265
189
|
// that the last one wins. Our resolver's order is the order to
|
|
266
190
|
// search, so first one wins.
|
|
267
191
|
.reverse(),
|
|
192
|
+
isLazy: appFiles.engine.package.isLazyEngine(),
|
|
268
193
|
})),
|
|
269
194
|
amdCompatibility: this.options.amdCompatibility,
|
|
270
195
|
// this is the additional stufff that @embroider/compat adds on top to do
|
|
271
196
|
// global template resolving
|
|
272
197
|
modulePrefix: this.modulePrefix(),
|
|
198
|
+
splitAtRoutes: this.options.splitAtRoutes,
|
|
273
199
|
podModulePrefix: this.podModulePrefix(),
|
|
274
200
|
activePackageRules: this.activeRules(),
|
|
275
201
|
options,
|
|
202
|
+
autoRun: this.compatApp.autoRun,
|
|
203
|
+
staticAppPaths: this.options.staticAppPaths,
|
|
276
204
|
};
|
|
277
205
|
return config;
|
|
278
206
|
}
|
|
279
|
-
scriptPriority(pkg) {
|
|
280
|
-
switch (pkg.name) {
|
|
281
|
-
case 'loader.js':
|
|
282
|
-
return 0;
|
|
283
|
-
case 'ember-source':
|
|
284
|
-
return 10;
|
|
285
|
-
default:
|
|
286
|
-
return 1000;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
207
|
get resolvableExtensionsPattern() {
|
|
290
208
|
return (0, core_1.extensionsPattern)(this.resolvableExtensions());
|
|
291
209
|
}
|
|
292
|
-
|
|
293
|
-
let result = this.impliedAddonAssets(type, engine).map((sourcePath) => {
|
|
294
|
-
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
295
|
-
return {
|
|
296
|
-
kind: 'on-disk',
|
|
297
|
-
relativePath: (0, core_1.explicitRelative)(this.root, sourcePath),
|
|
298
|
-
sourcePath,
|
|
299
|
-
mtime: stats.mtimeMs,
|
|
300
|
-
size: stats.size,
|
|
301
|
-
};
|
|
302
|
-
});
|
|
303
|
-
if (type === 'implicit-scripts') {
|
|
304
|
-
result.unshift({
|
|
305
|
-
kind: 'in-memory',
|
|
306
|
-
relativePath: '_testing_prefix_.js',
|
|
307
|
-
source: `var runningTests=false;`,
|
|
308
|
-
});
|
|
309
|
-
result.unshift({
|
|
310
|
-
kind: 'in-memory',
|
|
311
|
-
relativePath: '_ember_env_.js',
|
|
312
|
-
source: `window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`,
|
|
313
|
-
});
|
|
314
|
-
result.push({
|
|
315
|
-
kind: 'in-memory',
|
|
316
|
-
relativePath: '_loader_.js',
|
|
317
|
-
source: `loader.makeDefaultExport=false;`,
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
if (type === 'implicit-test-scripts') {
|
|
321
|
-
// this is the traditional test-support-suffix.js
|
|
322
|
-
result.push({
|
|
323
|
-
kind: 'in-memory',
|
|
324
|
-
relativePath: '_testing_suffix_.js',
|
|
325
|
-
source: `
|
|
326
|
-
var runningTests=true;
|
|
327
|
-
if (typeof Testem !== 'undefined' && (typeof QUnit !== 'undefined' || typeof Mocha !== 'undefined')) {
|
|
328
|
-
Testem.hookIntoTestFramework();
|
|
329
|
-
}`,
|
|
330
|
-
});
|
|
331
|
-
// whether or not anybody was actually using @embroider/macros
|
|
332
|
-
// explicitly as an addon, we ensure its test-support file is always
|
|
333
|
-
// present.
|
|
334
|
-
if (!result.find(s => s.kind === 'on-disk' && s.sourcePath.endsWith('embroider-macros-test-support.js'))) {
|
|
335
|
-
result.unshift({
|
|
336
|
-
kind: 'on-disk',
|
|
337
|
-
sourcePath: require.resolve('@embroider/macros/src/vendor/embroider-macros-test-support'),
|
|
338
|
-
mtime: 0,
|
|
339
|
-
size: 0,
|
|
340
|
-
relativePath: 'embroider-macros-test-support.js',
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return result;
|
|
345
|
-
}
|
|
346
|
-
impliedAddonAssets(type, { engine }) {
|
|
347
|
-
let result = [];
|
|
348
|
-
for (let addon of (0, sortBy_1.default)(Array.from(engine.addons), this.scriptPriority.bind(this))) {
|
|
349
|
-
let implicitScripts = addon.meta[type];
|
|
350
|
-
if (implicitScripts) {
|
|
351
|
-
let styles = [];
|
|
352
|
-
let options = { basedir: addon.root };
|
|
353
|
-
for (let mod of implicitScripts) {
|
|
354
|
-
if (type === 'implicit-styles') {
|
|
355
|
-
// exclude engines because they will handle their own css importation
|
|
356
|
-
if (!addon.isLazyEngine()) {
|
|
357
|
-
styles.push(resolve_2.default.sync(mod, options));
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
result.push(resolve_2.default.sync(mod, options));
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
if (styles.length) {
|
|
365
|
-
result = [...styles, ...result];
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return result;
|
|
370
|
-
}
|
|
371
|
-
babelConfig(resolverConfig) {
|
|
210
|
+
async babelConfig(resolverConfig) {
|
|
372
211
|
let babel = (0, cloneDeep_1.default)(this.compatApp.babelConfig());
|
|
373
212
|
if (!babel.plugins) {
|
|
374
213
|
babel.plugins = [];
|
|
@@ -378,7 +217,10 @@ class CompatAppBuilder {
|
|
|
378
217
|
babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));
|
|
379
218
|
// https://github.com/webpack/webpack/issues/12154
|
|
380
219
|
babel.plugins.push(require.resolve('./rename-require-plugin'));
|
|
381
|
-
babel.plugins.push([
|
|
220
|
+
babel.plugins.push([
|
|
221
|
+
require.resolve('babel-plugin-ember-template-compilation'),
|
|
222
|
+
await this.etcOptions(resolverConfig),
|
|
223
|
+
]);
|
|
382
224
|
// this is @embroider/macros configured for full stage3 resolution
|
|
383
225
|
babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
|
|
384
226
|
let colocationOptions = {
|
|
@@ -430,7 +272,7 @@ class CompatAppBuilder {
|
|
|
430
272
|
addCachablePlugin(portable.config);
|
|
431
273
|
return portable;
|
|
432
274
|
}
|
|
433
|
-
insertEmberApp(asset, appFiles, prepared
|
|
275
|
+
insertEmberApp(asset, appFiles, prepared) {
|
|
434
276
|
let html = asset.html;
|
|
435
277
|
if (this.fastbootConfig) {
|
|
436
278
|
// ignore scripts like ember-cli-livereload.js which are not really associated with
|
|
@@ -440,12 +282,6 @@ class CompatAppBuilder {
|
|
|
440
282
|
script.setAttribute('data-fastboot-ignore', '');
|
|
441
283
|
});
|
|
442
284
|
}
|
|
443
|
-
// our tests entrypoint already includes a correct module dependency on the
|
|
444
|
-
// app, so we only insert the app when we're not inserting tests
|
|
445
|
-
if (!asset.fileAsset.includeTests) {
|
|
446
|
-
let appJS = this.topAppJSAsset(appFiles, prepared);
|
|
447
|
-
html.insertScriptTag(html.javascript, appJS.relativePath, { type: 'module' });
|
|
448
|
-
}
|
|
449
285
|
if (this.fastbootConfig) {
|
|
450
286
|
// any extra fastboot app files get inserted into our html.javascript
|
|
451
287
|
// section, after the app has been inserted.
|
|
@@ -454,11 +290,6 @@ class CompatAppBuilder {
|
|
|
454
290
|
}
|
|
455
291
|
}
|
|
456
292
|
html.insertStyleLink(html.styles, `assets/${this.origAppPackage.name}.css`);
|
|
457
|
-
const parentEngine = appFiles.find(e => !e.engine.parent);
|
|
458
|
-
let vendorJS = this.implicitScriptsAsset(prepared, parentEngine, emberENV);
|
|
459
|
-
if (vendorJS) {
|
|
460
|
-
html.insertScriptTag(html.implicitScripts, vendorJS.relativePath);
|
|
461
|
-
}
|
|
462
293
|
if (this.fastbootConfig) {
|
|
463
294
|
// any extra fastboot vendor files get inserted into our
|
|
464
295
|
// html.implicitScripts section, after the regular implicit script
|
|
@@ -467,69 +298,12 @@ class CompatAppBuilder {
|
|
|
467
298
|
html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
|
|
468
299
|
}
|
|
469
300
|
}
|
|
470
|
-
let implicitStyles = this.implicitStylesAsset(prepared, parentEngine);
|
|
471
|
-
if (implicitStyles) {
|
|
472
|
-
html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
|
|
473
|
-
}
|
|
474
301
|
if (!asset.fileAsset.includeTests) {
|
|
475
302
|
return;
|
|
476
303
|
}
|
|
477
304
|
// Test-related assets happen below this point
|
|
478
305
|
let testJS = this.testJSEntrypoint(appFiles, prepared);
|
|
479
306
|
html.insertScriptTag(html.testJavascript, testJS.relativePath, { type: 'module' });
|
|
480
|
-
let implicitTestScriptsAsset = this.implicitTestScriptsAsset(prepared, parentEngine);
|
|
481
|
-
if (implicitTestScriptsAsset) {
|
|
482
|
-
html.insertScriptTag(html.implicitTestScripts, implicitTestScriptsAsset.relativePath);
|
|
483
|
-
}
|
|
484
|
-
let implicitTestStylesAsset = this.implicitTestStylesAsset(prepared, parentEngine);
|
|
485
|
-
if (implicitTestStylesAsset) {
|
|
486
|
-
html.insertStyleLink(html.implicitTestStyles, implicitTestStylesAsset.relativePath);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
implicitScriptsAsset(prepared, application, emberENV) {
|
|
490
|
-
let asset = prepared.get('assets/vendor.js');
|
|
491
|
-
if (!asset) {
|
|
492
|
-
let implicitScripts = this.impliedAssets('implicit-scripts', application, emberENV);
|
|
493
|
-
if (implicitScripts.length > 0) {
|
|
494
|
-
asset = new ConcatenatedAsset('assets/vendor.js', implicitScripts, this.resolvableExtensionsPattern);
|
|
495
|
-
prepared.set(asset.relativePath, asset);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
return asset;
|
|
499
|
-
}
|
|
500
|
-
implicitStylesAsset(prepared, application) {
|
|
501
|
-
let asset = prepared.get('assets/vendor.css');
|
|
502
|
-
if (!asset) {
|
|
503
|
-
let implicitStyles = this.impliedAssets('implicit-styles', application);
|
|
504
|
-
if (implicitStyles.length > 0) {
|
|
505
|
-
// we reverse because we want the synthetic vendor style at the top
|
|
506
|
-
asset = new ConcatenatedAsset('assets/vendor.css', implicitStyles.reverse(), this.resolvableExtensionsPattern);
|
|
507
|
-
prepared.set(asset.relativePath, asset);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
return asset;
|
|
511
|
-
}
|
|
512
|
-
implicitTestScriptsAsset(prepared, application) {
|
|
513
|
-
let testSupportJS = prepared.get('assets/test-support.js');
|
|
514
|
-
if (!testSupportJS) {
|
|
515
|
-
let implicitTestScripts = this.impliedAssets('implicit-test-scripts', application);
|
|
516
|
-
if (implicitTestScripts.length > 0) {
|
|
517
|
-
testSupportJS = new ConcatenatedAsset('assets/test-support.js', implicitTestScripts, this.resolvableExtensionsPattern);
|
|
518
|
-
prepared.set(testSupportJS.relativePath, testSupportJS);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return testSupportJS;
|
|
522
|
-
}
|
|
523
|
-
implicitTestStylesAsset(prepared, application) {
|
|
524
|
-
let asset = prepared.get('assets/test-support.css');
|
|
525
|
-
if (!asset) {
|
|
526
|
-
let implicitTestStyles = this.impliedAssets('implicit-test-styles', application);
|
|
527
|
-
if (implicitTestStyles.length > 0) {
|
|
528
|
-
asset = new ConcatenatedAsset('assets/test-support.css', implicitTestStyles, this.resolvableExtensionsPattern);
|
|
529
|
-
prepared.set(asset.relativePath, asset);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return asset;
|
|
533
307
|
}
|
|
534
308
|
// recurse to find all active addons that don't cross an engine boundary.
|
|
535
309
|
// Inner engines themselves will be returned, but not those engines' children.
|
|
@@ -540,22 +314,31 @@ class CompatAppBuilder {
|
|
|
540
314
|
if (!child.isEngine()) {
|
|
541
315
|
this.findActiveAddons(child, engine, true);
|
|
542
316
|
}
|
|
543
|
-
|
|
317
|
+
let canResolveFrom;
|
|
318
|
+
if (pkg === this.appPackageWithMovedDeps) {
|
|
319
|
+
// we want canResolveFrom to always be a rewritten package path, and our
|
|
320
|
+
// app's package is not rewritten yet here.
|
|
321
|
+
canResolveFrom = (0, path_1.resolve)(this.root, 'package.json');
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// whereas our addons are already moved
|
|
325
|
+
canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
|
|
326
|
+
}
|
|
327
|
+
engine.addons.set(child, canResolveFrom);
|
|
544
328
|
}
|
|
545
329
|
// ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
|
|
546
330
|
if (!isChild) {
|
|
547
|
-
engine.addons = new
|
|
331
|
+
engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
|
|
548
332
|
return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
|
|
549
333
|
}));
|
|
550
334
|
}
|
|
551
335
|
}
|
|
552
|
-
partitionEngines(
|
|
336
|
+
partitionEngines() {
|
|
553
337
|
let queue = [
|
|
554
338
|
{
|
|
555
339
|
package: this.appPackageWithMovedDeps,
|
|
556
|
-
addons: new
|
|
557
|
-
|
|
558
|
-
sourcePath: appJSPath,
|
|
340
|
+
addons: new Map(),
|
|
341
|
+
isApp: true,
|
|
559
342
|
modulePrefix: this.modulePrefix(),
|
|
560
343
|
appRelativePath: '.',
|
|
561
344
|
},
|
|
@@ -568,14 +351,13 @@ class CompatAppBuilder {
|
|
|
568
351
|
break;
|
|
569
352
|
}
|
|
570
353
|
this.findActiveAddons(current.package, current);
|
|
571
|
-
for (let addon of current.addons) {
|
|
354
|
+
for (let addon of current.addons.keys()) {
|
|
572
355
|
if (addon.isEngine() && !seenEngines.has(addon)) {
|
|
573
356
|
seenEngines.add(addon);
|
|
574
357
|
queue.push({
|
|
575
358
|
package: addon,
|
|
576
|
-
addons: new
|
|
577
|
-
|
|
578
|
-
sourcePath: addon.root,
|
|
359
|
+
addons: new Map(),
|
|
360
|
+
isApp: !current,
|
|
579
361
|
modulePrefix: addon.name,
|
|
580
362
|
appRelativePath: (0, core_1.explicitRelative)(this.root, addon.root),
|
|
581
363
|
});
|
|
@@ -601,8 +383,8 @@ class CompatAppBuilder {
|
|
|
601
383
|
updateAppJS(appJSPath) {
|
|
602
384
|
var _a;
|
|
603
385
|
if (!this.engines) {
|
|
604
|
-
this.engines = this.partitionEngines(
|
|
605
|
-
if (engine.
|
|
386
|
+
this.engines = this.partitionEngines().map(engine => {
|
|
387
|
+
if (engine.isApp) {
|
|
606
388
|
// this is the app. We have more to do for the app than for other
|
|
607
389
|
// engines.
|
|
608
390
|
let fastbootSync;
|
|
@@ -624,7 +406,7 @@ class CompatAppBuilder {
|
|
|
624
406
|
// their files, not doing any actual copying or building.
|
|
625
407
|
return {
|
|
626
408
|
engine,
|
|
627
|
-
appSync: new sync_dir_1.SyncDir(engine.
|
|
409
|
+
appSync: new sync_dir_1.SyncDir(engine.package.root, undefined),
|
|
628
410
|
// AFAIK, we've never supported a fastboot overlay directory in an
|
|
629
411
|
// engine. But if we do need that, it would go here.
|
|
630
412
|
fastbootSync: undefined,
|
|
@@ -638,10 +420,15 @@ class CompatAppBuilder {
|
|
|
638
420
|
}
|
|
639
421
|
return this.engines.map(({ engine, appSync, fastbootSync }) => {
|
|
640
422
|
var _a;
|
|
641
|
-
return new app_files_1.AppFiles(engine, appSync.files, (_a = fastbootSync === null || fastbootSync === void 0 ? void 0 : fastbootSync.files) !== null && _a !== void 0 ? _a : new Set(), this.resolvableExtensionsPattern, this.podModulePrefix());
|
|
423
|
+
return new app_files_1.AppFiles(engine, appSync.files, (_a = fastbootSync === null || fastbootSync === void 0 ? void 0 : fastbootSync.files) !== null && _a !== void 0 ? _a : new Set(), this.resolvableExtensionsPattern, this.staticAppPathsPattern, this.podModulePrefix());
|
|
642
424
|
});
|
|
643
425
|
}
|
|
644
|
-
|
|
426
|
+
get staticAppPathsPattern() {
|
|
427
|
+
if (this.options.staticAppPaths.length > 0) {
|
|
428
|
+
return new RegExp('^(?:' + this.options.staticAppPaths.map(staticAppPath => (0, escape_string_regexp_1.default)(staticAppPath)).join('|') + ')(?:$|/)');
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
prepareAsset(asset, appFiles, prepared) {
|
|
645
432
|
if (asset.kind === 'ember') {
|
|
646
433
|
let prior = this.assets.get(asset.relativePath);
|
|
647
434
|
let parsed;
|
|
@@ -653,17 +440,17 @@ class CompatAppBuilder {
|
|
|
653
440
|
else {
|
|
654
441
|
parsed = new ParsedEmberAsset(asset);
|
|
655
442
|
}
|
|
656
|
-
this.insertEmberApp(parsed, appFiles, prepared
|
|
443
|
+
this.insertEmberApp(parsed, appFiles, prepared);
|
|
657
444
|
prepared.set(asset.relativePath, new BuiltEmberAsset(parsed));
|
|
658
445
|
}
|
|
659
446
|
else {
|
|
660
447
|
prepared.set(asset.relativePath, asset);
|
|
661
448
|
}
|
|
662
449
|
}
|
|
663
|
-
prepareAssets(requestedAssets, appFiles
|
|
450
|
+
prepareAssets(requestedAssets, appFiles) {
|
|
664
451
|
let prepared = new Map();
|
|
665
452
|
for (let asset of requestedAssets) {
|
|
666
|
-
this.prepareAsset(asset, appFiles, prepared
|
|
453
|
+
this.prepareAsset(asset, appFiles, prepared);
|
|
667
454
|
}
|
|
668
455
|
return prepared;
|
|
669
456
|
}
|
|
@@ -678,13 +465,6 @@ class CompatAppBuilder {
|
|
|
678
465
|
return prior.kind === 'in-memory' && stringOrBufferEqual(prior.source, asset.source);
|
|
679
466
|
case 'built-ember':
|
|
680
467
|
return prior.kind === 'built-ember' && prior.source === asset.source;
|
|
681
|
-
case 'concatenated-asset':
|
|
682
|
-
return (prior.kind === 'concatenated-asset' &&
|
|
683
|
-
prior.sources.length === asset.sources.length &&
|
|
684
|
-
prior.sources.every((priorFile, index) => {
|
|
685
|
-
let newFile = asset.sources[index];
|
|
686
|
-
return this.assetIsValid(newFile, priorFile);
|
|
687
|
-
}));
|
|
688
468
|
}
|
|
689
469
|
}
|
|
690
470
|
updateOnDiskAsset(asset) {
|
|
@@ -702,35 +482,8 @@ class CompatAppBuilder {
|
|
|
702
482
|
(0, fs_extra_2.ensureDirSync)((0, path_2.dirname)(destination));
|
|
703
483
|
(0, fs_extra_1.writeFileSync)(destination, asset.source, 'utf8');
|
|
704
484
|
}
|
|
705
|
-
async
|
|
706
|
-
let
|
|
707
|
-
outputFile: (0, path_2.join)(this.root, asset.relativePath),
|
|
708
|
-
mapCommentType: asset.relativePath.endsWith('.js') ? 'line' : 'block',
|
|
709
|
-
baseDir: this.root,
|
|
710
|
-
});
|
|
711
|
-
if (process.env.EMBROIDER_CONCAT_STATS) {
|
|
712
|
-
let MeasureConcat = (await Promise.resolve().then(() => __importStar(require('@embroider/core/src/measure-concat')))).default;
|
|
713
|
-
concat = new MeasureConcat(asset.relativePath, concat, this.root);
|
|
714
|
-
}
|
|
715
|
-
for (let source of asset.sources) {
|
|
716
|
-
switch (source.kind) {
|
|
717
|
-
case 'on-disk':
|
|
718
|
-
concat.addFile((0, core_1.explicitRelative)(this.root, source.sourcePath));
|
|
719
|
-
break;
|
|
720
|
-
case 'in-memory':
|
|
721
|
-
if (typeof source.source !== 'string') {
|
|
722
|
-
throw new Error(`attempted to concatenated a Buffer-backed in-memory asset`);
|
|
723
|
-
}
|
|
724
|
-
concat.addSpace(source.source);
|
|
725
|
-
break;
|
|
726
|
-
default:
|
|
727
|
-
(0, assert_never_1.default)(source);
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
await concat.end();
|
|
731
|
-
}
|
|
732
|
-
async updateAssets(requestedAssets, appFiles, emberENV) {
|
|
733
|
-
let assets = this.prepareAssets(requestedAssets, appFiles, emberENV);
|
|
485
|
+
async updateAssets(requestedAssets, appFiles) {
|
|
486
|
+
let assets = this.prepareAssets(requestedAssets, appFiles);
|
|
734
487
|
for (let asset of assets.values()) {
|
|
735
488
|
if (this.assetIsValid(asset, this.assets.get(asset.relativePath))) {
|
|
736
489
|
continue;
|
|
@@ -746,9 +499,6 @@ class CompatAppBuilder {
|
|
|
746
499
|
case 'built-ember':
|
|
747
500
|
this.updateBuiltEmberAsset(asset);
|
|
748
501
|
break;
|
|
749
|
-
case 'concatenated-asset':
|
|
750
|
-
await this.updateConcatenatedAsset(asset);
|
|
751
|
-
break;
|
|
752
502
|
default:
|
|
753
503
|
(0, assert_never_1.default)(asset);
|
|
754
504
|
}
|
|
@@ -759,26 +509,10 @@ class CompatAppBuilder {
|
|
|
759
509
|
}
|
|
760
510
|
}
|
|
761
511
|
this.assets = assets;
|
|
762
|
-
return [...assets.values()];
|
|
763
512
|
}
|
|
764
513
|
gatherAssets(inputPaths) {
|
|
765
514
|
// first gather all the assets out of addons
|
|
766
515
|
let assets = [];
|
|
767
|
-
for (let pkg of this.allActiveAddons) {
|
|
768
|
-
if (pkg.meta['public-assets']) {
|
|
769
|
-
for (let [filename, appRelativeURL] of Object.entries(pkg.meta['public-assets'] || {})) {
|
|
770
|
-
let sourcePath = (0, path_1.resolve)(pkg.root, filename);
|
|
771
|
-
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
772
|
-
assets.push({
|
|
773
|
-
kind: 'on-disk',
|
|
774
|
-
sourcePath,
|
|
775
|
-
relativePath: appRelativeURL,
|
|
776
|
-
mtime: stats.mtimeMs,
|
|
777
|
-
size: stats.size,
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
516
|
if (this.activeFastboot) {
|
|
783
517
|
const source = `
|
|
784
518
|
(function(){
|
|
@@ -807,29 +541,20 @@ class CompatAppBuilder {
|
|
|
807
541
|
this.firstBuild = false;
|
|
808
542
|
}
|
|
809
543
|
let appFiles = this.updateAppJS(inputPaths.appJS);
|
|
810
|
-
let emberENV = this.configTree.readConfig().EmberENV;
|
|
811
544
|
let assets = this.gatherAssets(inputPaths);
|
|
812
|
-
|
|
545
|
+
await this.updateAssets(assets, appFiles);
|
|
813
546
|
let assetPaths = assets.map(asset => asset.relativePath);
|
|
814
547
|
if (this.activeFastboot) {
|
|
815
548
|
// when using fastboot, our own package.json needs to be in the output so fastboot can read it.
|
|
816
549
|
assetPaths.push('package.json');
|
|
817
550
|
}
|
|
818
|
-
for (let asset of finalAssets) {
|
|
819
|
-
// our concatenated assets all have map files that ride along. Here we're
|
|
820
|
-
// telling the final stage packager to be sure and serve the map files
|
|
821
|
-
// too.
|
|
822
|
-
if (asset.kind === 'concatenated-asset') {
|
|
823
|
-
assetPaths.push(asset.sourcemapPath);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
551
|
let meta = {
|
|
827
552
|
type: 'app',
|
|
828
553
|
version: 2,
|
|
829
554
|
assets: assetPaths,
|
|
830
555
|
babel: {
|
|
831
556
|
filename: '_babel_config_.js',
|
|
832
|
-
isParallelSafe: true,
|
|
557
|
+
isParallelSafe: true, // TODO
|
|
833
558
|
majorVersion: this.compatApp.babelMajorVersion(),
|
|
834
559
|
fileFilter: '_babel_filter_.js',
|
|
835
560
|
},
|
|
@@ -841,8 +566,12 @@ class CompatAppBuilder {
|
|
|
841
566
|
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
|
|
842
567
|
let resolverConfig = this.resolverConfig(appFiles);
|
|
843
568
|
this.addResolverConfig(resolverConfig);
|
|
844
|
-
|
|
569
|
+
this.addContentForConfig(this.contentForTree.readContents());
|
|
570
|
+
this.addEmberEnvConfig(this.configTree.readConfig().EmberENV);
|
|
571
|
+
this.addAppBoot(this.compatApp.appBoot.readAppBoot());
|
|
572
|
+
let babelConfig = await this.babelConfig(resolverConfig);
|
|
845
573
|
this.addBabelConfig(babelConfig);
|
|
574
|
+
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'macros-config.json'), JSON.stringify(this.compatApp.macrosConfig.babelPluginConfig()[0], null, 2));
|
|
846
575
|
}
|
|
847
576
|
combinePackageJSON(meta) {
|
|
848
577
|
let pkgLayers = [this.origAppPackage.packageJSON];
|
|
@@ -855,7 +584,7 @@ class CompatAppBuilder {
|
|
|
855
584
|
pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
|
|
856
585
|
return combinePackageJSON(...pkgLayers);
|
|
857
586
|
}
|
|
858
|
-
etcOptions(resolverConfig) {
|
|
587
|
+
async etcOptions(resolverConfig) {
|
|
859
588
|
let transforms = this.compatApp.htmlbarsPlugins;
|
|
860
589
|
let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
|
|
861
590
|
setConfig(this.compatApp.macrosConfig);
|
|
@@ -872,7 +601,7 @@ class CompatAppBuilder {
|
|
|
872
601
|
transforms.push([require.resolve('./resolver-transform'), opts]);
|
|
873
602
|
}
|
|
874
603
|
let resolver = new core_1.Resolver(resolverConfig);
|
|
875
|
-
let resolution = resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
|
|
604
|
+
let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
|
|
876
605
|
if (resolution.type !== 'real') {
|
|
877
606
|
throw new Error(`bug: unable to resolve ember-template-compiler from ${this.root}`);
|
|
878
607
|
}
|
|
@@ -890,7 +619,7 @@ class CompatAppBuilder {
|
|
|
890
619
|
if (i < hint.resolve.length - 1) {
|
|
891
620
|
target = (0, path_2.join)(target, 'package.json');
|
|
892
621
|
}
|
|
893
|
-
cursor =
|
|
622
|
+
cursor = resolve_1.default.sync(target, { basedir: (0, path_2.dirname)(cursor) });
|
|
894
623
|
}
|
|
895
624
|
return {
|
|
896
625
|
requireFile: cursor,
|
|
@@ -909,173 +638,18 @@ class CompatAppBuilder {
|
|
|
909
638
|
addResolverConfig(config) {
|
|
910
639
|
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
|
|
911
640
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
if (typeof pattern === 'string') {
|
|
916
|
-
return pattern === routeName;
|
|
917
|
-
}
|
|
918
|
-
else {
|
|
919
|
-
return pattern.test(routeName);
|
|
920
|
-
}
|
|
921
|
-
}));
|
|
922
|
-
}
|
|
923
|
-
splitRoute(routeName, files, addToParent, addLazyBundle) {
|
|
924
|
-
let shouldSplit = routeName && this.shouldSplitRoute(routeName);
|
|
925
|
-
let ownFiles = [];
|
|
926
|
-
let ownNames = new Set();
|
|
927
|
-
if (files.template) {
|
|
928
|
-
if (shouldSplit) {
|
|
929
|
-
ownFiles.push(files.template);
|
|
930
|
-
ownNames.add(routeName);
|
|
931
|
-
}
|
|
932
|
-
else {
|
|
933
|
-
addToParent(routeName, files.template);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
if (files.controller) {
|
|
937
|
-
if (shouldSplit) {
|
|
938
|
-
ownFiles.push(files.controller);
|
|
939
|
-
ownNames.add(routeName);
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
addToParent(routeName, files.controller);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
if (files.route) {
|
|
946
|
-
if (shouldSplit) {
|
|
947
|
-
ownFiles.push(files.route);
|
|
948
|
-
ownNames.add(routeName);
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
addToParent(routeName, files.route);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
for (let [childName, childFiles] of files.children) {
|
|
955
|
-
this.splitRoute(`${routeName}.${childName}`, childFiles, (childRouteName, childFile) => {
|
|
956
|
-
// this is our child calling "addToParent"
|
|
957
|
-
if (shouldSplit) {
|
|
958
|
-
ownFiles.push(childFile);
|
|
959
|
-
ownNames.add(childRouteName);
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
addToParent(childRouteName, childFile);
|
|
963
|
-
}
|
|
964
|
-
}, (routeNames, files) => {
|
|
965
|
-
addLazyBundle(routeNames, files);
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
if (ownFiles.length > 0) {
|
|
969
|
-
addLazyBundle([...ownNames], ownFiles);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
topAppJSAsset(engines, prepared) {
|
|
973
|
-
let [app, ...childEngines] = engines;
|
|
974
|
-
let relativePath = `assets/${this.origAppPackage.name}.js`;
|
|
975
|
-
return this.appJSAsset(relativePath, app, childEngines, prepared, {
|
|
976
|
-
autoRun: this.compatApp.autoRun,
|
|
977
|
-
appBoot: !this.compatApp.autoRun ? this.compatApp.appBoot.readAppBoot() : '',
|
|
978
|
-
mainModule: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), 'app'),
|
|
979
|
-
appConfig: this.configTree.readConfig().APP,
|
|
641
|
+
addContentForConfig(contentForConfig) {
|
|
642
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
643
|
+
spaces: 2,
|
|
980
644
|
});
|
|
981
645
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
646
|
+
addEmberEnvConfig(emberEnvConfig) {
|
|
647
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
|
|
648
|
+
spaces: 2,
|
|
649
|
+
});
|
|
986
650
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (pattern) {
|
|
990
|
-
return appFiles.otherAppFiles.filter(f => {
|
|
991
|
-
return !pattern.test(f);
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
else {
|
|
995
|
-
return appFiles.otherAppFiles;
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
appJSAsset(relativePath, appFiles, childEngines, prepared, entryParams) {
|
|
999
|
-
let cached = prepared.get(relativePath);
|
|
1000
|
-
if (cached) {
|
|
1001
|
-
return cached;
|
|
1002
|
-
}
|
|
1003
|
-
let eagerModules = [];
|
|
1004
|
-
let requiredAppFiles = [this.requiredOtherFiles(appFiles)];
|
|
1005
|
-
if (!this.options.staticComponents) {
|
|
1006
|
-
requiredAppFiles.push(appFiles.components);
|
|
1007
|
-
}
|
|
1008
|
-
if (!this.options.staticHelpers) {
|
|
1009
|
-
requiredAppFiles.push(appFiles.helpers);
|
|
1010
|
-
}
|
|
1011
|
-
if (!this.options.staticModifiers) {
|
|
1012
|
-
requiredAppFiles.push(appFiles.modifiers);
|
|
1013
|
-
}
|
|
1014
|
-
let styles = [];
|
|
1015
|
-
// only import styles from engines with a parent (this excludeds the parent application) as their styles
|
|
1016
|
-
// will be inserted via a direct <link> tag.
|
|
1017
|
-
if (appFiles.engine.parent && appFiles.engine.package.isLazyEngine()) {
|
|
1018
|
-
let implicitStyles = this.impliedAssets('implicit-styles', appFiles);
|
|
1019
|
-
for (let style of implicitStyles) {
|
|
1020
|
-
styles.push({
|
|
1021
|
-
path: (0, core_1.explicitRelative)('assets/_engine_', style.relativePath),
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
let engineMeta = appFiles.engine.package.meta;
|
|
1025
|
-
if (engineMeta && engineMeta['implicit-styles']) {
|
|
1026
|
-
for (let style of engineMeta['implicit-styles']) {
|
|
1027
|
-
styles.push({
|
|
1028
|
-
path: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), (0, path_2.join)(appFiles.engine.appRelativePath, style)),
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
let lazyEngines = [];
|
|
1034
|
-
for (let childEngine of childEngines) {
|
|
1035
|
-
let asset = this.appJSAsset(`assets/_engine_/${encodeURIComponent(childEngine.engine.package.name)}.js`, childEngine, [], prepared);
|
|
1036
|
-
if (childEngine.engine.package.isLazyEngine()) {
|
|
1037
|
-
lazyEngines.push({
|
|
1038
|
-
names: [childEngine.engine.package.name],
|
|
1039
|
-
path: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), asset.relativePath),
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
else {
|
|
1043
|
-
eagerModules.push((0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), asset.relativePath));
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
let lazyRoutes = [];
|
|
1047
|
-
for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
|
|
1048
|
-
this.splitRoute(routeName, routeFiles, (_, filename) => {
|
|
1049
|
-
requiredAppFiles.push([filename]);
|
|
1050
|
-
}, (routeNames, files) => {
|
|
1051
|
-
let routeEntrypoint = `assets/_route_/${encodeURIComponent(routeNames[0])}.js`;
|
|
1052
|
-
if (!prepared.has(routeEntrypoint)) {
|
|
1053
|
-
prepared.set(routeEntrypoint, this.routeEntrypoint(appFiles, routeEntrypoint, files));
|
|
1054
|
-
}
|
|
1055
|
-
lazyRoutes.push({
|
|
1056
|
-
names: routeNames,
|
|
1057
|
-
path: this.importPaths(appFiles, routeEntrypoint).buildtime,
|
|
1058
|
-
});
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
|
|
1062
|
-
let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
|
|
1063
|
-
let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(appFiles, file));
|
|
1064
|
-
// this is a backward-compatibility feature: addons can force inclusion of
|
|
1065
|
-
// modules.
|
|
1066
|
-
eagerModules.push('./-embroider-implicit-modules.js');
|
|
1067
|
-
let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules, styles };
|
|
1068
|
-
if (entryParams) {
|
|
1069
|
-
Object.assign(params, entryParams);
|
|
1070
|
-
}
|
|
1071
|
-
let source = entryTemplate(params);
|
|
1072
|
-
let asset = {
|
|
1073
|
-
kind: 'in-memory',
|
|
1074
|
-
source,
|
|
1075
|
-
relativePath,
|
|
1076
|
-
};
|
|
1077
|
-
prepared.set(relativePath, asset);
|
|
1078
|
-
return asset;
|
|
651
|
+
addAppBoot(appBoot) {
|
|
652
|
+
(0, fs_extra_1.writeFileSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-app-boot.js'), appBoot !== null && appBoot !== void 0 ? appBoot : '');
|
|
1079
653
|
}
|
|
1080
654
|
importPaths({ engine }, engineRelativePath) {
|
|
1081
655
|
let noHBS = engineRelativePath.replace(this.resolvableExtensionsPattern, '').replace(/\.hbs$/, '');
|
|
@@ -1084,18 +658,6 @@ class CompatAppBuilder {
|
|
|
1084
658
|
buildtime: path_1.posix.join(engine.package.name, engineRelativePath),
|
|
1085
659
|
};
|
|
1086
660
|
}
|
|
1087
|
-
routeEntrypoint(appFiles, relativePath, files) {
|
|
1088
|
-
let [fastboot, nonFastboot] = (0, partition_1.default)(files, file => appFiles.isFastbootOnly.get(file));
|
|
1089
|
-
let asset = {
|
|
1090
|
-
kind: 'in-memory',
|
|
1091
|
-
source: routeEntryTemplate({
|
|
1092
|
-
files: nonFastboot.map(f => this.importPaths(appFiles, f)),
|
|
1093
|
-
fastbootOnlyFiles: fastboot.map(f => this.importPaths(appFiles, f)),
|
|
1094
|
-
}),
|
|
1095
|
-
relativePath,
|
|
1096
|
-
};
|
|
1097
|
-
return asset;
|
|
1098
|
-
}
|
|
1099
661
|
testJSEntrypoint(appFiles, prepared) {
|
|
1100
662
|
let asset = prepared.get(`assets/test.js`);
|
|
1101
663
|
if (asset) {
|
|
@@ -1106,26 +668,15 @@ class CompatAppBuilder {
|
|
|
1106
668
|
// the app.
|
|
1107
669
|
let engine = appFiles[0];
|
|
1108
670
|
const myName = 'assets/test.js';
|
|
1109
|
-
// tests necessarily also include the app. This is where we account for
|
|
1110
|
-
// that. The classic solution was to always include the app's separate
|
|
1111
|
-
// script tag in the tests HTML, but that isn't as easy for final stage
|
|
1112
|
-
// packagers to understand. It's better to express it here as a direct
|
|
1113
|
-
// module dependency.
|
|
1114
|
-
let eagerModules = [
|
|
1115
|
-
'ember-testing',
|
|
1116
|
-
(0, core_1.explicitRelative)((0, path_2.dirname)(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
|
|
1117
|
-
];
|
|
1118
671
|
let amdModules = [];
|
|
1119
|
-
// this is a backward-compatibility feature: addons can force inclusion of
|
|
1120
|
-
// test support modules.
|
|
1121
|
-
eagerModules.push('./-embroider-implicit-test-modules.js');
|
|
1122
672
|
for (let relativePath of engine.tests) {
|
|
1123
673
|
amdModules.push(this.importPaths(engine, relativePath));
|
|
1124
674
|
}
|
|
1125
675
|
let source = entryTemplate({
|
|
1126
676
|
amdModules,
|
|
1127
|
-
eagerModules,
|
|
1128
677
|
testSuffix: true,
|
|
678
|
+
// this is a backward-compatibility feature: addons can force inclusion of test support modules.
|
|
679
|
+
defineModulesFrom: './-embroider-implicit-test-modules.js',
|
|
1129
680
|
});
|
|
1130
681
|
asset = {
|
|
1131
682
|
kind: 'in-memory',
|
|
@@ -1140,9 +691,6 @@ exports.CompatAppBuilder = CompatAppBuilder;
|
|
|
1140
691
|
__decorate([
|
|
1141
692
|
(0, typescript_memoize_1.Memoize)()
|
|
1142
693
|
], CompatAppBuilder.prototype, "fastbootJSSrcDir", null);
|
|
1143
|
-
__decorate([
|
|
1144
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1145
|
-
], CompatAppBuilder.prototype, "findTestemAsset", null);
|
|
1146
694
|
__decorate([
|
|
1147
695
|
(0, typescript_memoize_1.Memoize)()
|
|
1148
696
|
], CompatAppBuilder.prototype, "allActiveAddons", null);
|
|
@@ -1169,10 +717,10 @@ __decorate([
|
|
|
1169
717
|
], CompatAppBuilder.prototype, "fastbootConfig", null);
|
|
1170
718
|
__decorate([
|
|
1171
719
|
(0, typescript_memoize_1.Memoize)()
|
|
1172
|
-
], CompatAppBuilder.prototype, "
|
|
720
|
+
], CompatAppBuilder.prototype, "staticAppPathsPattern", null);
|
|
1173
721
|
__decorate([
|
|
1174
722
|
(0, typescript_memoize_1.Memoize)()
|
|
1175
|
-
], CompatAppBuilder.prototype, "
|
|
723
|
+
], CompatAppBuilder.prototype, "portableHints", null);
|
|
1176
724
|
function defaultAddonPackageRules() {
|
|
1177
725
|
return (0, fs_extra_2.readdirSync)((0, path_2.join)(__dirname, 'addon-dependency-rules'))
|
|
1178
726
|
.map(filename => {
|
|
@@ -1197,9 +745,17 @@ let d = w.define;
|
|
|
1197
745
|
}
|
|
1198
746
|
{{/if}}
|
|
1199
747
|
|
|
1200
|
-
{{#
|
|
1201
|
-
|
|
1202
|
-
|
|
748
|
+
{{#if defineModulesFrom ~}}
|
|
749
|
+
import implicitModules from "{{js-string-escape defineModulesFrom}}";
|
|
750
|
+
|
|
751
|
+
for(const [name, module] of Object.entries(implicitModules)) {
|
|
752
|
+
d(name, function() { return module });
|
|
753
|
+
}
|
|
754
|
+
{{/if}}
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
import "ember-testing";
|
|
758
|
+
import "@embroider/core/entrypoint";
|
|
1203
759
|
|
|
1204
760
|
{{#each amdModules as |amdModule| ~}}
|
|
1205
761
|
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
@@ -1207,9 +763,17 @@ let d = w.define;
|
|
|
1207
763
|
|
|
1208
764
|
{{#if fastbootOnlyAmdModules}}
|
|
1209
765
|
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
766
|
+
let fastbootModules = {};
|
|
767
|
+
|
|
1210
768
|
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
|
1211
|
-
|
|
769
|
+
fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
|
|
1212
770
|
{{/each}}
|
|
771
|
+
|
|
772
|
+
const resolvedValues = await Promise.all(Object.values(fastbootModules));
|
|
773
|
+
|
|
774
|
+
Object.keys(fastbootModules).forEach((k, i) => {
|
|
775
|
+
d(k, function(){ return resolvedValues[i];});
|
|
776
|
+
})
|
|
1213
777
|
}
|
|
1214
778
|
{{/if}}
|
|
1215
779
|
|
|
@@ -1258,21 +822,6 @@ if (!runningTests) {
|
|
|
1258
822
|
EmberENV.TESTS_FILE_LOADED = true;
|
|
1259
823
|
{{/if}}
|
|
1260
824
|
`);
|
|
1261
|
-
const routeEntryTemplate = (0, core_1.jsHandlebarsCompile)(`
|
|
1262
|
-
import { importSync as i } from '@embroider/macros';
|
|
1263
|
-
let d = window.define;
|
|
1264
|
-
{{#each files as |amdModule| ~}}
|
|
1265
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1266
|
-
{{/each}}
|
|
1267
|
-
{{#if fastbootOnlyFiles}}
|
|
1268
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
1269
|
-
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
1270
|
-
{{#each fastbootOnlyFiles as |amdModule| ~}}
|
|
1271
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1272
|
-
{{/each}}
|
|
1273
|
-
}
|
|
1274
|
-
{{/if}}
|
|
1275
|
-
`);
|
|
1276
825
|
function stringOrBufferEqual(a, b) {
|
|
1277
826
|
if (typeof a === 'string' && typeof b === 'string') {
|
|
1278
827
|
return a === b;
|
|
@@ -1321,9 +870,6 @@ function addCachablePlugin(babelConfig) {
|
|
|
1321
870
|
]);
|
|
1322
871
|
}
|
|
1323
872
|
}
|
|
1324
|
-
function excludeDotFiles(files) {
|
|
1325
|
-
return files.filter(file => !file.startsWith('.') && !file.includes('/.'));
|
|
1326
|
-
}
|
|
1327
873
|
class ParsedEmberAsset {
|
|
1328
874
|
constructor(asset) {
|
|
1329
875
|
this.kind = 'parsed-ember';
|
|
@@ -1343,15 +889,4 @@ class BuiltEmberAsset {
|
|
|
1343
889
|
this.relativePath = asset.relativePath;
|
|
1344
890
|
}
|
|
1345
891
|
}
|
|
1346
|
-
class ConcatenatedAsset {
|
|
1347
|
-
constructor(relativePath, sources, resolvableExtensions) {
|
|
1348
|
-
this.relativePath = relativePath;
|
|
1349
|
-
this.sources = sources;
|
|
1350
|
-
this.resolvableExtensions = resolvableExtensions;
|
|
1351
|
-
this.kind = 'concatenated-asset';
|
|
1352
|
-
}
|
|
1353
|
-
get sourcemapPath() {
|
|
1354
|
-
return this.relativePath.replace(this.resolvableExtensions, '') + '.map';
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
892
|
//# sourceMappingURL=compat-app-builder.js.map
|