@embroider/compat 3.5.0 → 3.5.1-unstable.1ea1c86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/package.json +13 -13
  2. package/src/audit/babel-visitor.js +5 -3
  3. package/src/audit/babel-visitor.js.map +1 -1
  4. package/src/audit/build.js.map +1 -1
  5. package/src/audit-cli.js.map +1 -1
  6. package/src/audit.d.ts +6 -54
  7. package/src/audit.js +86 -275
  8. package/src/audit.js.map +1 -1
  9. package/src/babel-plugin-adjust-imports.d.ts +2 -1
  10. package/src/babel-plugin-adjust-imports.js +1 -1
  11. package/src/babel-plugin-adjust-imports.js.map +1 -1
  12. package/src/build-compat-addon.js.map +1 -1
  13. package/src/compat-adapters/@ember/test-waiters.js.map +1 -1
  14. package/src/compat-adapters/@ember-data/store.d.ts +1 -5
  15. package/src/compat-adapters/@ember-data/store.js +3 -15
  16. package/src/compat-adapters/@ember-data/store.js.map +1 -1
  17. package/src/compat-adapters/ember-asset-loader.js.map +1 -1
  18. package/src/compat-adapters/ember-cli-babel.js.map +1 -1
  19. package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
  20. package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
  21. package/src/compat-adapters/ember-composable-helpers.js.map +1 -1
  22. package/src/compat-adapters/ember-data.js.map +1 -1
  23. package/src/compat-adapters/ember-engines.js.map +1 -1
  24. package/src/compat-adapters/ember-fetch.d.ts +5 -0
  25. package/src/compat-adapters/ember-fetch.js +19 -0
  26. package/src/compat-adapters/ember-fetch.js.map +1 -0
  27. package/src/compat-adapters/ember-macro-helpers.js.map +1 -1
  28. package/src/compat-adapters/ember-scroll-modifiers.js.map +1 -1
  29. package/src/compat-adapters/ember-source.js.map +1 -1
  30. package/src/compat-adapters/ember-svg-jar.js.map +1 -1
  31. package/src/compat-addons.js.map +1 -1
  32. package/src/compat-app-builder.d.ts +5 -5
  33. package/src/compat-app-builder.js +97 -184
  34. package/src/compat-app-builder.js.map +1 -1
  35. package/src/compat-app.d.ts +2 -0
  36. package/src/compat-app.js +35 -8
  37. package/src/compat-app.js.map +1 -1
  38. package/src/compat-utils.js.map +1 -1
  39. package/src/content-for-config.d.ts +11 -0
  40. package/src/content-for-config.js +66 -0
  41. package/src/content-for-config.js.map +1 -0
  42. package/src/dasherize-component-name.js.map +1 -1
  43. package/src/default-pipeline.d.ts +2 -2
  44. package/src/default-pipeline.js +22 -1
  45. package/src/default-pipeline.js.map +1 -1
  46. package/src/dependency-rules.js.map +1 -1
  47. package/src/detect-babel-plugins.js.map +1 -1
  48. package/src/detect-compact-reexports.js.map +1 -1
  49. package/src/dummy-package.js.map +1 -1
  50. package/src/empty-package-tree.js.map +1 -1
  51. package/src/get-real-addon.js.map +1 -1
  52. package/src/hbs-to-js-broccoli-plugin.js.map +1 -1
  53. package/src/http-audit.d.ts +13 -0
  54. package/src/http-audit.js +43 -0
  55. package/src/http-audit.js.map +1 -0
  56. package/src/index.d.ts +1 -1
  57. package/src/index.js +2 -1
  58. package/src/index.js.map +1 -1
  59. package/src/merges.js.map +1 -1
  60. package/src/module-visitor.d.ts +53 -0
  61. package/src/module-visitor.js +286 -0
  62. package/src/module-visitor.js.map +1 -0
  63. package/src/options.d.ts +1 -0
  64. package/src/options.js +1 -0
  65. package/src/options.js.map +1 -1
  66. package/src/prepare-htmlbars-ast-plugins.js.map +1 -1
  67. package/src/rename-require-plugin.js.map +1 -1
  68. package/src/resolver-transform.js +3 -0
  69. package/src/resolver-transform.js.map +1 -1
  70. package/src/rewrite-addon-tree.js.map +1 -1
  71. package/src/smoosh-package-json.js.map +1 -1
  72. package/src/snitch.js.map +1 -1
  73. package/src/standalone-addon-build.js.map +1 -1
  74. package/src/sync-dir.js.map +1 -1
  75. package/src/synthesize-template-only-components.js.map +1 -1
  76. package/src/v1-addon.js.map +1 -1
  77. package/src/v1-appboot.js.map +1 -1
  78. package/src/v1-config.js.map +1 -1
  79. package/src/v1-instance-cache.js.map +1 -1
  80. package/LICENSE +0 -21
  81. package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
  82. package/src/compat-adapters/@ember-data/debug.js +0 -22
  83. 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(a => ({
261
- name: a.name,
262
- root: a.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, emberENV) {
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([require.resolve('babel-plugin-ember-template-compilation'), this.etcOptions(resolverConfig)]);
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, emberENV) {
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,6 @@ class CompatAppBuilder {
454
397
  }
455
398
  }
456
399
  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
400
  if (this.fastbootConfig) {
463
401
  // any extra fastboot vendor files get inserted into our
464
402
  // html.implicitScripts section, after the regular implicit script
@@ -467,69 +405,17 @@ class CompatAppBuilder {
467
405
  html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
468
406
  }
469
407
  }
470
- let implicitStyles = this.implicitStylesAsset(prepared, parentEngine);
471
- if (implicitStyles) {
472
- html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
473
- }
408
+ // virtual vendor.css entrypoint
409
+ html.insertStyleLink(html.implicitStyles, '@embroider/core/vendor.css');
474
410
  if (!asset.fileAsset.includeTests) {
475
411
  return;
476
412
  }
477
413
  // Test-related assets happen below this point
478
414
  let testJS = this.testJSEntrypoint(appFiles, prepared);
479
415
  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;
416
+ // virtual test-support.js
417
+ html.insertScriptTag(html.implicitTestScripts, '@embroider/core/test-support.js');
418
+ html.insertStyleLink(html.implicitTestStyles, '@embroider/core/test-support.css');
533
419
  }
534
420
  // recurse to find all active addons that don't cross an engine boundary.
535
421
  // Inner engines themselves will be returned, but not those engines' children.
@@ -540,22 +426,31 @@ class CompatAppBuilder {
540
426
  if (!child.isEngine()) {
541
427
  this.findActiveAddons(child, engine, true);
542
428
  }
543
- engine.addons.add(child);
429
+ let canResolveFrom;
430
+ if (pkg === this.appPackageWithMovedDeps) {
431
+ // we want canResolveFrom to always be a rewritten package path, and our
432
+ // app's package is not rewritten yet here.
433
+ canResolveFrom = (0, path_1.resolve)(this.root, 'package.json');
434
+ }
435
+ else {
436
+ // whereas our addons are already moved
437
+ canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
438
+ }
439
+ engine.addons.set(child, canResolveFrom);
544
440
  }
545
441
  // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
546
442
  if (!isChild) {
547
- engine.addons = new Set([...engine.addons].sort((a, b) => {
443
+ engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
548
444
  return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
549
445
  }));
550
446
  }
551
447
  }
552
- partitionEngines(appJSPath) {
448
+ partitionEngines() {
553
449
  let queue = [
554
450
  {
555
451
  package: this.appPackageWithMovedDeps,
556
- addons: new Set(),
557
- parent: undefined,
558
- sourcePath: appJSPath,
452
+ addons: new Map(),
453
+ isApp: true,
559
454
  modulePrefix: this.modulePrefix(),
560
455
  appRelativePath: '.',
561
456
  },
@@ -568,14 +463,13 @@ class CompatAppBuilder {
568
463
  break;
569
464
  }
570
465
  this.findActiveAddons(current.package, current);
571
- for (let addon of current.addons) {
466
+ for (let addon of current.addons.keys()) {
572
467
  if (addon.isEngine() && !seenEngines.has(addon)) {
573
468
  seenEngines.add(addon);
574
469
  queue.push({
575
470
  package: addon,
576
- addons: new Set(),
577
- parent: current,
578
- sourcePath: addon.root,
471
+ addons: new Map(),
472
+ isApp: !current,
579
473
  modulePrefix: addon.name,
580
474
  appRelativePath: (0, core_1.explicitRelative)(this.root, addon.root),
581
475
  });
@@ -601,8 +495,8 @@ class CompatAppBuilder {
601
495
  updateAppJS(appJSPath) {
602
496
  var _a;
603
497
  if (!this.engines) {
604
- this.engines = this.partitionEngines(appJSPath).map(engine => {
605
- if (engine.sourcePath === appJSPath) {
498
+ this.engines = this.partitionEngines().map(engine => {
499
+ if (engine.isApp) {
606
500
  // this is the app. We have more to do for the app than for other
607
501
  // engines.
608
502
  let fastbootSync;
@@ -624,7 +518,7 @@ class CompatAppBuilder {
624
518
  // their files, not doing any actual copying or building.
625
519
  return {
626
520
  engine,
627
- appSync: new sync_dir_1.SyncDir(engine.sourcePath, undefined),
521
+ appSync: new sync_dir_1.SyncDir(engine.package.root, undefined),
628
522
  // AFAIK, we've never supported a fastboot overlay directory in an
629
523
  // engine. But if we do need that, it would go here.
630
524
  fastbootSync: undefined,
@@ -641,7 +535,7 @@ class CompatAppBuilder {
641
535
  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
536
  });
643
537
  }
644
- prepareAsset(asset, appFiles, prepared, emberENV) {
538
+ prepareAsset(asset, appFiles, prepared) {
645
539
  if (asset.kind === 'ember') {
646
540
  let prior = this.assets.get(asset.relativePath);
647
541
  let parsed;
@@ -653,17 +547,17 @@ class CompatAppBuilder {
653
547
  else {
654
548
  parsed = new ParsedEmberAsset(asset);
655
549
  }
656
- this.insertEmberApp(parsed, appFiles, prepared, emberENV);
550
+ this.insertEmberApp(parsed, appFiles, prepared);
657
551
  prepared.set(asset.relativePath, new BuiltEmberAsset(parsed));
658
552
  }
659
553
  else {
660
554
  prepared.set(asset.relativePath, asset);
661
555
  }
662
556
  }
663
- prepareAssets(requestedAssets, appFiles, emberENV) {
557
+ prepareAssets(requestedAssets, appFiles) {
664
558
  let prepared = new Map();
665
559
  for (let asset of requestedAssets) {
666
- this.prepareAsset(asset, appFiles, prepared, emberENV);
560
+ this.prepareAsset(asset, appFiles, prepared);
667
561
  }
668
562
  return prepared;
669
563
  }
@@ -729,8 +623,8 @@ class CompatAppBuilder {
729
623
  }
730
624
  await concat.end();
731
625
  }
732
- async updateAssets(requestedAssets, appFiles, emberENV) {
733
- let assets = this.prepareAssets(requestedAssets, appFiles, emberENV);
626
+ async updateAssets(requestedAssets, appFiles) {
627
+ let assets = this.prepareAssets(requestedAssets, appFiles);
734
628
  for (let asset of assets.values()) {
735
629
  if (this.assetIsValid(asset, this.assets.get(asset.relativePath))) {
736
630
  continue;
@@ -764,21 +658,6 @@ class CompatAppBuilder {
764
658
  gatherAssets(inputPaths) {
765
659
  // first gather all the assets out of addons
766
660
  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
661
  if (this.activeFastboot) {
783
662
  const source = `
784
663
  (function(){
@@ -807,9 +686,8 @@ class CompatAppBuilder {
807
686
  this.firstBuild = false;
808
687
  }
809
688
  let appFiles = this.updateAppJS(inputPaths.appJS);
810
- let emberENV = this.configTree.readConfig().EmberENV;
811
689
  let assets = this.gatherAssets(inputPaths);
812
- let finalAssets = await this.updateAssets(assets, appFiles, emberENV);
690
+ let finalAssets = await this.updateAssets(assets, appFiles);
813
691
  let assetPaths = assets.map(asset => asset.relativePath);
814
692
  if (this.activeFastboot) {
815
693
  // when using fastboot, our own package.json needs to be in the output so fastboot can read it.
@@ -829,7 +707,7 @@ class CompatAppBuilder {
829
707
  assets: assetPaths,
830
708
  babel: {
831
709
  filename: '_babel_config_.js',
832
- isParallelSafe: true,
710
+ isParallelSafe: true, // TODO
833
711
  majorVersion: this.compatApp.babelMajorVersion(),
834
712
  fileFilter: '_babel_filter_.js',
835
713
  },
@@ -841,8 +719,11 @@ class CompatAppBuilder {
841
719
  (0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
842
720
  let resolverConfig = this.resolverConfig(appFiles);
843
721
  this.addResolverConfig(resolverConfig);
844
- let babelConfig = this.babelConfig(resolverConfig);
722
+ this.addContentForConfig(this.contentForTree.readContents());
723
+ this.addEmberEnvConfig(this.configTree.readConfig().EmberENV);
724
+ let babelConfig = await this.babelConfig(resolverConfig);
845
725
  this.addBabelConfig(babelConfig);
726
+ (0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'macros-config.json'), JSON.stringify(this.compatApp.macrosConfig.babelPluginConfig()[0], null, 2));
846
727
  }
847
728
  combinePackageJSON(meta) {
848
729
  let pkgLayers = [this.origAppPackage.packageJSON];
@@ -855,7 +736,7 @@ class CompatAppBuilder {
855
736
  pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
856
737
  return combinePackageJSON(...pkgLayers);
857
738
  }
858
- etcOptions(resolverConfig) {
739
+ async etcOptions(resolverConfig) {
859
740
  let transforms = this.compatApp.htmlbarsPlugins;
860
741
  let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
861
742
  setConfig(this.compatApp.macrosConfig);
@@ -872,7 +753,7 @@ class CompatAppBuilder {
872
753
  transforms.push([require.resolve('./resolver-transform'), opts]);
873
754
  }
874
755
  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'));
756
+ let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
876
757
  if (resolution.type !== 'real') {
877
758
  throw new Error(`bug: unable to resolve ember-template-compiler from ${this.root}`);
878
759
  }
@@ -909,6 +790,16 @@ class CompatAppBuilder {
909
790
  addResolverConfig(config) {
910
791
  (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
911
792
  }
793
+ addContentForConfig(contentForConfig) {
794
+ (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
795
+ spaces: 2,
796
+ });
797
+ }
798
+ addEmberEnvConfig(emberEnvConfig) {
799
+ (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
800
+ spaces: 2,
801
+ });
802
+ }
912
803
  shouldSplitRoute(routeName) {
913
804
  return (!this.options.splitAtRoutes ||
914
805
  this.options.splitAtRoutes.find(pattern => {
@@ -1014,7 +905,7 @@ class CompatAppBuilder {
1014
905
  let styles = [];
1015
906
  // only import styles from engines with a parent (this excludeds the parent application) as their styles
1016
907
  // will be inserted via a direct <link> tag.
1017
- if (appFiles.engine.parent && appFiles.engine.package.isLazyEngine()) {
908
+ if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
1018
909
  let implicitStyles = this.impliedAssets('implicit-styles', appFiles);
1019
910
  for (let style of implicitStyles) {
1020
911
  styles.push({
@@ -1061,10 +952,16 @@ class CompatAppBuilder {
1061
952
  let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
1062
953
  let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
1063
954
  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 };
955
+ let params = {
956
+ amdModules,
957
+ fastbootOnlyAmdModules,
958
+ lazyRoutes,
959
+ lazyEngines,
960
+ eagerModules,
961
+ styles,
962
+ // this is a backward-compatibility feature: addons can force inclusion of modules.
963
+ defineModulesFrom: './-embroider-implicit-modules.js',
964
+ };
1068
965
  if (entryParams) {
1069
966
  Object.assign(params, entryParams);
1070
967
  }
@@ -1116,9 +1013,6 @@ class CompatAppBuilder {
1116
1013
  (0, core_1.explicitRelative)((0, path_2.dirname)(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
1117
1014
  ];
1118
1015
  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
1016
  for (let relativePath of engine.tests) {
1123
1017
  amdModules.push(this.importPaths(engine, relativePath));
1124
1018
  }
@@ -1126,6 +1020,8 @@ class CompatAppBuilder {
1126
1020
  amdModules,
1127
1021
  eagerModules,
1128
1022
  testSuffix: true,
1023
+ // this is a backward-compatibility feature: addons can force inclusion of test support modules.
1024
+ defineModulesFrom: './-embroider-implicit-test-modules.js',
1129
1025
  });
1130
1026
  asset = {
1131
1027
  kind: 'in-memory',
@@ -1197,6 +1093,15 @@ let d = w.define;
1197
1093
  }
1198
1094
  {{/if}}
1199
1095
 
1096
+ {{#if defineModulesFrom ~}}
1097
+ import implicitModules from "{{js-string-escape defineModulesFrom}}";
1098
+
1099
+ for(const [name, module] of Object.entries(implicitModules)) {
1100
+ d(name, function() { return module });
1101
+ }
1102
+ {{/if}}
1103
+
1104
+
1200
1105
  {{#each eagerModules as |eagerModule| ~}}
1201
1106
  i("{{js-string-escape eagerModule}}");
1202
1107
  {{/each}}
@@ -1207,9 +1112,17 @@ let d = w.define;
1207
1112
 
1208
1113
  {{#if fastbootOnlyAmdModules}}
1209
1114
  if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
1115
+ let fastbootModules = {};
1116
+
1210
1117
  {{#each fastbootOnlyAmdModules as |amdModule| ~}}
1211
- d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
1118
+ fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
1212
1119
  {{/each}}
1120
+
1121
+ const resolvedValues = await Promise.all(Object.values(fastbootModules));
1122
+
1123
+ Object.keys(fastbootModules).forEach((k, i) => {
1124
+ d(k, function(){ return resolvedValues[i];});
1125
+ })
1213
1126
  }
1214
1127
  {{/if}}
1215
1128