@embroider/compat 3.4.8 → 3.4.9-unstable.3d20631
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.js +5 -5
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +1 -1
- package/src/babel-plugin-adjust-imports.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-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-app-builder.d.ts +5 -5
- package/src/compat-app-builder.js +98 -183
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +2 -0
- package/src/compat-app.js +32 -6
- package/src/compat-app.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/default-pipeline.d.ts +2 -2
- package/src/default-pipeline.js +22 -1
- package/src/default-pipeline.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/options.d.ts +1 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/resolver-transform.js +3 -0
- package/src/resolver-transform.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
|
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.CompatAppBuilder = void 0;
|
|
36
36
|
const core_1 = require("@embroider/core");
|
|
37
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
38
37
|
const path_1 = require("path");
|
|
39
38
|
const dependency_rules_1 = require("./dependency-rules");
|
|
40
39
|
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
@@ -62,13 +61,14 @@ const sync_dir_1 = require("./sync-dir");
|
|
|
62
61
|
// This exists during the actual broccoli build step. As opposed to CompatApp,
|
|
63
62
|
// which also exists during pipeline-construction time.
|
|
64
63
|
class CompatAppBuilder {
|
|
65
|
-
constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, synthVendor, synthStyles) {
|
|
64
|
+
constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, contentForTree, synthVendor, synthStyles) {
|
|
66
65
|
this.root = root;
|
|
67
66
|
this.origAppPackage = origAppPackage;
|
|
68
67
|
this.appPackageWithMovedDeps = appPackageWithMovedDeps;
|
|
69
68
|
this.options = options;
|
|
70
69
|
this.compatApp = compatApp;
|
|
71
70
|
this.configTree = configTree;
|
|
71
|
+
this.contentForTree = contentForTree;
|
|
72
72
|
this.synthVendor = synthVendor;
|
|
73
73
|
this.synthStyles = synthStyles;
|
|
74
74
|
// for each relativePath, an Asset we have already emitted
|
|
@@ -83,22 +83,6 @@ class CompatAppBuilder {
|
|
|
83
83
|
}
|
|
84
84
|
extractAssets(treePaths) {
|
|
85
85
|
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
86
|
// ember-cli traditionally outputs a dummy testem.js file to prevent
|
|
103
87
|
// spurious errors when running tests under "ember s".
|
|
104
88
|
if (this.compatApp.shouldBuildTests) {
|
|
@@ -177,7 +161,7 @@ class CompatAppBuilder {
|
|
|
177
161
|
// For TS, we defer to ember-cli-babel, and the setting for
|
|
178
162
|
// "enableTypescriptTransform" can be set with and without
|
|
179
163
|
// ember-cli-typescript
|
|
180
|
-
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];
|
|
164
|
+
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js', '.gjs', '.gts'];
|
|
181
165
|
}
|
|
182
166
|
*emberEntrypoints(htmlTreePath) {
|
|
183
167
|
let classicEntrypoints = [
|
|
@@ -233,10 +217,6 @@ class CompatAppBuilder {
|
|
|
233
217
|
resolverConfig(engines) {
|
|
234
218
|
let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
235
219
|
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
220
|
let options = {
|
|
241
221
|
staticHelpers: this.options.staticHelpers,
|
|
242
222
|
staticModifiers: this.options.staticModifiers,
|
|
@@ -245,7 +225,6 @@ class CompatAppBuilder {
|
|
|
245
225
|
};
|
|
246
226
|
let config = {
|
|
247
227
|
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
248
|
-
activeAddons,
|
|
249
228
|
renameModules,
|
|
250
229
|
renamePackages,
|
|
251
230
|
resolvableExtensions: this.resolvableExtensions(),
|
|
@@ -257,14 +236,16 @@ class CompatAppBuilder {
|
|
|
257
236
|
root: (0, fs_extra_1.realpathSync)(index === 0 ? this.root : appFiles.engine.package.root),
|
|
258
237
|
fastbootFiles: appFiles.fastbootFiles,
|
|
259
238
|
activeAddons: [...appFiles.engine.addons]
|
|
260
|
-
.map(
|
|
261
|
-
name:
|
|
262
|
-
root:
|
|
239
|
+
.map(([addon, canResolveFromFile]) => ({
|
|
240
|
+
name: addon.name,
|
|
241
|
+
root: addon.root,
|
|
242
|
+
canResolveFromFile,
|
|
263
243
|
}))
|
|
264
244
|
// the traditional order is the order in which addons will run, such
|
|
265
245
|
// that the last one wins. Our resolver's order is the order to
|
|
266
246
|
// search, so first one wins.
|
|
267
247
|
.reverse(),
|
|
248
|
+
isLazy: appFiles.engine.package.isLazyEngine(),
|
|
268
249
|
})),
|
|
269
250
|
amdCompatibility: this.options.amdCompatibility,
|
|
270
251
|
// this is the additional stufff that @embroider/compat adds on top to do
|
|
@@ -289,7 +270,7 @@ class CompatAppBuilder {
|
|
|
289
270
|
get resolvableExtensionsPattern() {
|
|
290
271
|
return (0, core_1.extensionsPattern)(this.resolvableExtensions());
|
|
291
272
|
}
|
|
292
|
-
impliedAssets(type, engine
|
|
273
|
+
impliedAssets(type, engine) {
|
|
293
274
|
let result = this.impliedAddonAssets(type, engine).map((sourcePath) => {
|
|
294
275
|
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
295
276
|
return {
|
|
@@ -300,52 +281,11 @@ class CompatAppBuilder {
|
|
|
300
281
|
size: stats.size,
|
|
301
282
|
};
|
|
302
283
|
});
|
|
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
284
|
return result;
|
|
345
285
|
}
|
|
346
286
|
impliedAddonAssets(type, { engine }) {
|
|
347
287
|
let result = [];
|
|
348
|
-
for (let addon of (0, sortBy_1.default)(Array.from(engine.addons), this.scriptPriority.bind(this))) {
|
|
288
|
+
for (let addon of (0, sortBy_1.default)(Array.from(engine.addons.keys()), this.scriptPriority.bind(this))) {
|
|
349
289
|
let implicitScripts = addon.meta[type];
|
|
350
290
|
if (implicitScripts) {
|
|
351
291
|
let styles = [];
|
|
@@ -368,7 +308,7 @@ class CompatAppBuilder {
|
|
|
368
308
|
}
|
|
369
309
|
return result;
|
|
370
310
|
}
|
|
371
|
-
babelConfig(resolverConfig) {
|
|
311
|
+
async babelConfig(resolverConfig) {
|
|
372
312
|
let babel = (0, cloneDeep_1.default)(this.compatApp.babelConfig());
|
|
373
313
|
if (!babel.plugins) {
|
|
374
314
|
babel.plugins = [];
|
|
@@ -378,7 +318,10 @@ class CompatAppBuilder {
|
|
|
378
318
|
babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));
|
|
379
319
|
// https://github.com/webpack/webpack/issues/12154
|
|
380
320
|
babel.plugins.push(require.resolve('./rename-require-plugin'));
|
|
381
|
-
babel.plugins.push([
|
|
321
|
+
babel.plugins.push([
|
|
322
|
+
require.resolve('babel-plugin-ember-template-compilation'),
|
|
323
|
+
await this.etcOptions(resolverConfig),
|
|
324
|
+
]);
|
|
382
325
|
// this is @embroider/macros configured for full stage3 resolution
|
|
383
326
|
babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
|
|
384
327
|
let colocationOptions = {
|
|
@@ -430,7 +373,7 @@ class CompatAppBuilder {
|
|
|
430
373
|
addCachablePlugin(portable.config);
|
|
431
374
|
return portable;
|
|
432
375
|
}
|
|
433
|
-
insertEmberApp(asset, appFiles, prepared
|
|
376
|
+
insertEmberApp(asset, appFiles, prepared) {
|
|
434
377
|
let html = asset.html;
|
|
435
378
|
if (this.fastbootConfig) {
|
|
436
379
|
// ignore scripts like ember-cli-livereload.js which are not really associated with
|
|
@@ -454,11 +397,8 @@ class CompatAppBuilder {
|
|
|
454
397
|
}
|
|
455
398
|
}
|
|
456
399
|
html.insertStyleLink(html.styles, `assets/${this.origAppPackage.name}.css`);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (vendorJS) {
|
|
460
|
-
html.insertScriptTag(html.implicitScripts, vendorJS.relativePath);
|
|
461
|
-
}
|
|
400
|
+
// virtual-vendor entrypoint
|
|
401
|
+
html.insertScriptTag(html.implicitScripts, '@embroider/core/vendor.js');
|
|
462
402
|
if (this.fastbootConfig) {
|
|
463
403
|
// any extra fastboot vendor files get inserted into our
|
|
464
404
|
// html.implicitScripts section, after the regular implicit script
|
|
@@ -467,69 +407,17 @@ class CompatAppBuilder {
|
|
|
467
407
|
html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
|
|
468
408
|
}
|
|
469
409
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
|
|
473
|
-
}
|
|
410
|
+
// virtual vendor.css entrypoint
|
|
411
|
+
html.insertStyleLink(html.implicitStyles, '@embroider/core/vendor.css');
|
|
474
412
|
if (!asset.fileAsset.includeTests) {
|
|
475
413
|
return;
|
|
476
414
|
}
|
|
477
415
|
// Test-related assets happen below this point
|
|
478
416
|
let testJS = this.testJSEntrypoint(appFiles, prepared);
|
|
479
417
|
html.insertScriptTag(html.testJavascript, testJS.relativePath, { type: 'module' });
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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;
|
|
418
|
+
// virtual test-support.js
|
|
419
|
+
html.insertScriptTag(html.implicitTestScripts, '@embroider/core/test-support.js');
|
|
420
|
+
html.insertStyleLink(html.implicitTestStyles, '@embroider/core/test-support.css');
|
|
533
421
|
}
|
|
534
422
|
// recurse to find all active addons that don't cross an engine boundary.
|
|
535
423
|
// Inner engines themselves will be returned, but not those engines' children.
|
|
@@ -540,22 +428,31 @@ class CompatAppBuilder {
|
|
|
540
428
|
if (!child.isEngine()) {
|
|
541
429
|
this.findActiveAddons(child, engine, true);
|
|
542
430
|
}
|
|
543
|
-
|
|
431
|
+
let canResolveFrom;
|
|
432
|
+
if (pkg === this.appPackageWithMovedDeps) {
|
|
433
|
+
// we want canResolveFrom to always be a rewritten package path, and our
|
|
434
|
+
// app's package is not rewritten yet here.
|
|
435
|
+
canResolveFrom = (0, path_1.resolve)(this.root, 'package.json');
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
// whereas our addons are already moved
|
|
439
|
+
canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
|
|
440
|
+
}
|
|
441
|
+
engine.addons.set(child, canResolveFrom);
|
|
544
442
|
}
|
|
545
443
|
// ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
|
|
546
444
|
if (!isChild) {
|
|
547
|
-
engine.addons = new
|
|
445
|
+
engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
|
|
548
446
|
return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
|
|
549
447
|
}));
|
|
550
448
|
}
|
|
551
449
|
}
|
|
552
|
-
partitionEngines(
|
|
450
|
+
partitionEngines() {
|
|
553
451
|
let queue = [
|
|
554
452
|
{
|
|
555
453
|
package: this.appPackageWithMovedDeps,
|
|
556
|
-
addons: new
|
|
557
|
-
|
|
558
|
-
sourcePath: appJSPath,
|
|
454
|
+
addons: new Map(),
|
|
455
|
+
isApp: true,
|
|
559
456
|
modulePrefix: this.modulePrefix(),
|
|
560
457
|
appRelativePath: '.',
|
|
561
458
|
},
|
|
@@ -568,14 +465,13 @@ class CompatAppBuilder {
|
|
|
568
465
|
break;
|
|
569
466
|
}
|
|
570
467
|
this.findActiveAddons(current.package, current);
|
|
571
|
-
for (let addon of current.addons) {
|
|
468
|
+
for (let addon of current.addons.keys()) {
|
|
572
469
|
if (addon.isEngine() && !seenEngines.has(addon)) {
|
|
573
470
|
seenEngines.add(addon);
|
|
574
471
|
queue.push({
|
|
575
472
|
package: addon,
|
|
576
|
-
addons: new
|
|
577
|
-
|
|
578
|
-
sourcePath: addon.root,
|
|
473
|
+
addons: new Map(),
|
|
474
|
+
isApp: !current,
|
|
579
475
|
modulePrefix: addon.name,
|
|
580
476
|
appRelativePath: (0, core_1.explicitRelative)(this.root, addon.root),
|
|
581
477
|
});
|
|
@@ -601,8 +497,8 @@ class CompatAppBuilder {
|
|
|
601
497
|
updateAppJS(appJSPath) {
|
|
602
498
|
var _a;
|
|
603
499
|
if (!this.engines) {
|
|
604
|
-
this.engines = this.partitionEngines(
|
|
605
|
-
if (engine.
|
|
500
|
+
this.engines = this.partitionEngines().map(engine => {
|
|
501
|
+
if (engine.isApp) {
|
|
606
502
|
// this is the app. We have more to do for the app than for other
|
|
607
503
|
// engines.
|
|
608
504
|
let fastbootSync;
|
|
@@ -624,7 +520,7 @@ class CompatAppBuilder {
|
|
|
624
520
|
// their files, not doing any actual copying or building.
|
|
625
521
|
return {
|
|
626
522
|
engine,
|
|
627
|
-
appSync: new sync_dir_1.SyncDir(engine.
|
|
523
|
+
appSync: new sync_dir_1.SyncDir(engine.package.root, undefined),
|
|
628
524
|
// AFAIK, we've never supported a fastboot overlay directory in an
|
|
629
525
|
// engine. But if we do need that, it would go here.
|
|
630
526
|
fastbootSync: undefined,
|
|
@@ -641,7 +537,7 @@ class CompatAppBuilder {
|
|
|
641
537
|
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());
|
|
642
538
|
});
|
|
643
539
|
}
|
|
644
|
-
prepareAsset(asset, appFiles, prepared
|
|
540
|
+
prepareAsset(asset, appFiles, prepared) {
|
|
645
541
|
if (asset.kind === 'ember') {
|
|
646
542
|
let prior = this.assets.get(asset.relativePath);
|
|
647
543
|
let parsed;
|
|
@@ -653,17 +549,17 @@ class CompatAppBuilder {
|
|
|
653
549
|
else {
|
|
654
550
|
parsed = new ParsedEmberAsset(asset);
|
|
655
551
|
}
|
|
656
|
-
this.insertEmberApp(parsed, appFiles, prepared
|
|
552
|
+
this.insertEmberApp(parsed, appFiles, prepared);
|
|
657
553
|
prepared.set(asset.relativePath, new BuiltEmberAsset(parsed));
|
|
658
554
|
}
|
|
659
555
|
else {
|
|
660
556
|
prepared.set(asset.relativePath, asset);
|
|
661
557
|
}
|
|
662
558
|
}
|
|
663
|
-
prepareAssets(requestedAssets, appFiles
|
|
559
|
+
prepareAssets(requestedAssets, appFiles) {
|
|
664
560
|
let prepared = new Map();
|
|
665
561
|
for (let asset of requestedAssets) {
|
|
666
|
-
this.prepareAsset(asset, appFiles, prepared
|
|
562
|
+
this.prepareAsset(asset, appFiles, prepared);
|
|
667
563
|
}
|
|
668
564
|
return prepared;
|
|
669
565
|
}
|
|
@@ -729,8 +625,8 @@ class CompatAppBuilder {
|
|
|
729
625
|
}
|
|
730
626
|
await concat.end();
|
|
731
627
|
}
|
|
732
|
-
async updateAssets(requestedAssets, appFiles
|
|
733
|
-
let assets = this.prepareAssets(requestedAssets, appFiles
|
|
628
|
+
async updateAssets(requestedAssets, appFiles) {
|
|
629
|
+
let assets = this.prepareAssets(requestedAssets, appFiles);
|
|
734
630
|
for (let asset of assets.values()) {
|
|
735
631
|
if (this.assetIsValid(asset, this.assets.get(asset.relativePath))) {
|
|
736
632
|
continue;
|
|
@@ -764,21 +660,6 @@ class CompatAppBuilder {
|
|
|
764
660
|
gatherAssets(inputPaths) {
|
|
765
661
|
// first gather all the assets out of addons
|
|
766
662
|
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
663
|
if (this.activeFastboot) {
|
|
783
664
|
const source = `
|
|
784
665
|
(function(){
|
|
@@ -807,9 +688,8 @@ class CompatAppBuilder {
|
|
|
807
688
|
this.firstBuild = false;
|
|
808
689
|
}
|
|
809
690
|
let appFiles = this.updateAppJS(inputPaths.appJS);
|
|
810
|
-
let emberENV = this.configTree.readConfig().EmberENV;
|
|
811
691
|
let assets = this.gatherAssets(inputPaths);
|
|
812
|
-
let finalAssets = await this.updateAssets(assets, appFiles
|
|
692
|
+
let finalAssets = await this.updateAssets(assets, appFiles);
|
|
813
693
|
let assetPaths = assets.map(asset => asset.relativePath);
|
|
814
694
|
if (this.activeFastboot) {
|
|
815
695
|
// when using fastboot, our own package.json needs to be in the output so fastboot can read it.
|
|
@@ -841,8 +721,11 @@ class CompatAppBuilder {
|
|
|
841
721
|
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
|
|
842
722
|
let resolverConfig = this.resolverConfig(appFiles);
|
|
843
723
|
this.addResolverConfig(resolverConfig);
|
|
844
|
-
|
|
724
|
+
this.addContentForConfig(this.contentForTree.readContents());
|
|
725
|
+
this.addEmberEnvConfig(this.configTree.readConfig().EmberENV);
|
|
726
|
+
let babelConfig = await this.babelConfig(resolverConfig);
|
|
845
727
|
this.addBabelConfig(babelConfig);
|
|
728
|
+
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'macros-config.json'), JSON.stringify(this.compatApp.macrosConfig.babelPluginConfig()[0], null, 2));
|
|
846
729
|
}
|
|
847
730
|
combinePackageJSON(meta) {
|
|
848
731
|
let pkgLayers = [this.origAppPackage.packageJSON];
|
|
@@ -855,7 +738,7 @@ class CompatAppBuilder {
|
|
|
855
738
|
pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
|
|
856
739
|
return combinePackageJSON(...pkgLayers);
|
|
857
740
|
}
|
|
858
|
-
etcOptions(resolverConfig) {
|
|
741
|
+
async etcOptions(resolverConfig) {
|
|
859
742
|
let transforms = this.compatApp.htmlbarsPlugins;
|
|
860
743
|
let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
|
|
861
744
|
setConfig(this.compatApp.macrosConfig);
|
|
@@ -872,7 +755,7 @@ class CompatAppBuilder {
|
|
|
872
755
|
transforms.push([require.resolve('./resolver-transform'), opts]);
|
|
873
756
|
}
|
|
874
757
|
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'));
|
|
758
|
+
let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
|
|
876
759
|
if (resolution.type !== 'real') {
|
|
877
760
|
throw new Error(`bug: unable to resolve ember-template-compiler from ${this.root}`);
|
|
878
761
|
}
|
|
@@ -909,6 +792,16 @@ class CompatAppBuilder {
|
|
|
909
792
|
addResolverConfig(config) {
|
|
910
793
|
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
|
|
911
794
|
}
|
|
795
|
+
addContentForConfig(contentForConfig) {
|
|
796
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
797
|
+
spaces: 2,
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
addEmberEnvConfig(emberEnvConfig) {
|
|
801
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
|
|
802
|
+
spaces: 2,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
912
805
|
shouldSplitRoute(routeName) {
|
|
913
806
|
return (!this.options.splitAtRoutes ||
|
|
914
807
|
this.options.splitAtRoutes.find(pattern => {
|
|
@@ -1014,7 +907,7 @@ class CompatAppBuilder {
|
|
|
1014
907
|
let styles = [];
|
|
1015
908
|
// only import styles from engines with a parent (this excludeds the parent application) as their styles
|
|
1016
909
|
// will be inserted via a direct <link> tag.
|
|
1017
|
-
if (appFiles.engine.
|
|
910
|
+
if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
|
|
1018
911
|
let implicitStyles = this.impliedAssets('implicit-styles', appFiles);
|
|
1019
912
|
for (let style of implicitStyles) {
|
|
1020
913
|
styles.push({
|
|
@@ -1061,10 +954,16 @@ class CompatAppBuilder {
|
|
|
1061
954
|
let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
|
|
1062
955
|
let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
|
|
1063
956
|
let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(appFiles, file));
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
957
|
+
let params = {
|
|
958
|
+
amdModules,
|
|
959
|
+
fastbootOnlyAmdModules,
|
|
960
|
+
lazyRoutes,
|
|
961
|
+
lazyEngines,
|
|
962
|
+
eagerModules,
|
|
963
|
+
styles,
|
|
964
|
+
// this is a backward-compatibility feature: addons can force inclusion of modules.
|
|
965
|
+
defineModulesFrom: './-embroider-implicit-modules.js',
|
|
966
|
+
};
|
|
1068
967
|
if (entryParams) {
|
|
1069
968
|
Object.assign(params, entryParams);
|
|
1070
969
|
}
|
|
@@ -1116,9 +1015,6 @@ class CompatAppBuilder {
|
|
|
1116
1015
|
(0, core_1.explicitRelative)((0, path_2.dirname)(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
|
|
1117
1016
|
];
|
|
1118
1017
|
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
1018
|
for (let relativePath of engine.tests) {
|
|
1123
1019
|
amdModules.push(this.importPaths(engine, relativePath));
|
|
1124
1020
|
}
|
|
@@ -1126,6 +1022,8 @@ class CompatAppBuilder {
|
|
|
1126
1022
|
amdModules,
|
|
1127
1023
|
eagerModules,
|
|
1128
1024
|
testSuffix: true,
|
|
1025
|
+
// this is a backward-compatibility feature: addons can force inclusion of test support modules.
|
|
1026
|
+
defineModulesFrom: './-embroider-implicit-test-modules.js',
|
|
1129
1027
|
});
|
|
1130
1028
|
asset = {
|
|
1131
1029
|
kind: 'in-memory',
|
|
@@ -1197,6 +1095,15 @@ let d = w.define;
|
|
|
1197
1095
|
}
|
|
1198
1096
|
{{/if}}
|
|
1199
1097
|
|
|
1098
|
+
{{#if defineModulesFrom ~}}
|
|
1099
|
+
import implicitModules from "{{js-string-escape defineModulesFrom}}";
|
|
1100
|
+
|
|
1101
|
+
for(const [name, module] of Object.entries(implicitModules)) {
|
|
1102
|
+
d(name, function() { return module });
|
|
1103
|
+
}
|
|
1104
|
+
{{/if}}
|
|
1105
|
+
|
|
1106
|
+
|
|
1200
1107
|
{{#each eagerModules as |eagerModule| ~}}
|
|
1201
1108
|
i("{{js-string-escape eagerModule}}");
|
|
1202
1109
|
{{/each}}
|
|
@@ -1207,9 +1114,17 @@ let d = w.define;
|
|
|
1207
1114
|
|
|
1208
1115
|
{{#if fastbootOnlyAmdModules}}
|
|
1209
1116
|
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
1117
|
+
let fastbootModules = {};
|
|
1118
|
+
|
|
1210
1119
|
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
|
1211
|
-
|
|
1120
|
+
fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
|
|
1212
1121
|
{{/each}}
|
|
1122
|
+
|
|
1123
|
+
const resolvedValues = await Promise.all(Object.values(fastbootModules));
|
|
1124
|
+
|
|
1125
|
+
Object.keys(fastbootModules).forEach((k, i) => {
|
|
1126
|
+
d(k, function(){ return resolvedValues[i];});
|
|
1127
|
+
})
|
|
1213
1128
|
}
|
|
1214
1129
|
{{/if}}
|
|
1215
1130
|
|