@embroider/compat 3.5.0 → 3.5.1-unstable.3beedad

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 -8
  33. package/src/compat-app-builder.js +93 -240
  34. package/src/compat-app-builder.js.map +1 -1
  35. package/src/compat-app.d.ts +2 -3
  36. package/src/compat-app.js +35 -18
  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 +46 -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,11 +34,9 @@ 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"));
41
- const sortBy_1 = __importDefault(require("lodash/sortBy"));
42
40
  const flatten_1 = __importDefault(require("lodash/flatten"));
43
41
  const partition_1 = __importDefault(require("lodash/partition"));
44
42
  const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
@@ -62,13 +60,14 @@ const sync_dir_1 = require("./sync-dir");
62
60
  // This exists during the actual broccoli build step. As opposed to CompatApp,
63
61
  // which also exists during pipeline-construction time.
64
62
  class CompatAppBuilder {
65
- constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, synthVendor, synthStyles) {
63
+ constructor(root, origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, contentForTree, synthVendor, synthStyles) {
66
64
  this.root = root;
67
65
  this.origAppPackage = origAppPackage;
68
66
  this.appPackageWithMovedDeps = appPackageWithMovedDeps;
69
67
  this.options = options;
70
68
  this.compatApp = compatApp;
71
69
  this.configTree = configTree;
70
+ this.contentForTree = contentForTree;
72
71
  this.synthVendor = synthVendor;
73
72
  this.synthStyles = synthStyles;
74
73
  // for each relativePath, an Asset we have already emitted
@@ -83,22 +82,6 @@ class CompatAppBuilder {
83
82
  }
84
83
  extractAssets(treePaths) {
85
84
  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
85
  // ember-cli traditionally outputs a dummy testem.js file to prevent
103
86
  // spurious errors when running tests under "ember s".
104
87
  if (this.compatApp.shouldBuildTests) {
@@ -177,7 +160,7 @@ class CompatAppBuilder {
177
160
  // For TS, we defer to ember-cli-babel, and the setting for
178
161
  // "enableTypescriptTransform" can be set with and without
179
162
  // ember-cli-typescript
180
- return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];
163
+ return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js', '.gjs', '.gts'];
181
164
  }
182
165
  *emberEntrypoints(htmlTreePath) {
183
166
  let classicEntrypoints = [
@@ -205,10 +188,7 @@ class CompatAppBuilder {
205
188
  javascript: this.compatApp.findAppScript(scripts, entrypoint),
206
189
  styles: this.compatApp.findAppStyles(styles, entrypoint),
207
190
  implicitScripts: this.compatApp.findVendorScript(scripts, entrypoint),
208
- implicitStyles: this.compatApp.findVendorStyles(styles, entrypoint),
209
191
  testJavascript: this.compatApp.findTestScript(scripts),
210
- implicitTestScripts: this.compatApp.findTestSupportScript(scripts),
211
- implicitTestStyles: this.compatApp.findTestSupportStyles(styles),
212
192
  };
213
193
  },
214
194
  };
@@ -233,10 +213,6 @@ class CompatAppBuilder {
233
213
  resolverConfig(engines) {
234
214
  let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
235
215
  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
216
  let options = {
241
217
  staticHelpers: this.options.staticHelpers,
242
218
  staticModifiers: this.options.staticModifiers,
@@ -245,7 +221,6 @@ class CompatAppBuilder {
245
221
  };
246
222
  let config = {
247
223
  // this part is the base ModuleResolverOptions as required by @embroider/core
248
- activeAddons,
249
224
  renameModules,
250
225
  renamePackages,
251
226
  resolvableExtensions: this.resolvableExtensions(),
@@ -257,14 +232,16 @@ class CompatAppBuilder {
257
232
  root: (0, fs_extra_1.realpathSync)(index === 0 ? this.root : appFiles.engine.package.root),
258
233
  fastbootFiles: appFiles.fastbootFiles,
259
234
  activeAddons: [...appFiles.engine.addons]
260
- .map(a => ({
261
- name: a.name,
262
- root: a.root,
235
+ .map(([addon, canResolveFromFile]) => ({
236
+ name: addon.name,
237
+ root: addon.root,
238
+ canResolveFromFile,
263
239
  }))
264
240
  // the traditional order is the order in which addons will run, such
265
241
  // that the last one wins. Our resolver's order is the order to
266
242
  // search, so first one wins.
267
243
  .reverse(),
244
+ isLazy: appFiles.engine.package.isLazyEngine(),
268
245
  })),
269
246
  amdCompatibility: this.options.amdCompatibility,
270
247
  // this is the additional stufff that @embroider/compat adds on top to do
@@ -276,99 +253,10 @@ class CompatAppBuilder {
276
253
  };
277
254
  return config;
278
255
  }
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
256
  get resolvableExtensionsPattern() {
290
257
  return (0, core_1.extensionsPattern)(this.resolvableExtensions());
291
258
  }
292
- impliedAssets(type, engine, emberENV) {
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) {
259
+ async babelConfig(resolverConfig) {
372
260
  let babel = (0, cloneDeep_1.default)(this.compatApp.babelConfig());
373
261
  if (!babel.plugins) {
374
262
  babel.plugins = [];
@@ -378,7 +266,10 @@ class CompatAppBuilder {
378
266
  babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));
379
267
  // https://github.com/webpack/webpack/issues/12154
380
268
  babel.plugins.push(require.resolve('./rename-require-plugin'));
381
- babel.plugins.push([require.resolve('babel-plugin-ember-template-compilation'), this.etcOptions(resolverConfig)]);
269
+ babel.plugins.push([
270
+ require.resolve('babel-plugin-ember-template-compilation'),
271
+ await this.etcOptions(resolverConfig),
272
+ ]);
382
273
  // this is @embroider/macros configured for full stage3 resolution
383
274
  babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
384
275
  let colocationOptions = {
@@ -430,7 +321,7 @@ class CompatAppBuilder {
430
321
  addCachablePlugin(portable.config);
431
322
  return portable;
432
323
  }
433
- insertEmberApp(asset, appFiles, prepared, emberENV) {
324
+ insertEmberApp(asset, appFiles, prepared) {
434
325
  let html = asset.html;
435
326
  if (this.fastbootConfig) {
436
327
  // ignore scripts like ember-cli-livereload.js which are not really associated with
@@ -454,11 +345,6 @@ class CompatAppBuilder {
454
345
  }
455
346
  }
456
347
  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
348
  if (this.fastbootConfig) {
463
349
  // any extra fastboot vendor files get inserted into our
464
350
  // html.implicitScripts section, after the regular implicit script
@@ -467,69 +353,12 @@ class CompatAppBuilder {
467
353
  html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
468
354
  }
469
355
  }
470
- let implicitStyles = this.implicitStylesAsset(prepared, parentEngine);
471
- if (implicitStyles) {
472
- html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
473
- }
474
356
  if (!asset.fileAsset.includeTests) {
475
357
  return;
476
358
  }
477
359
  // Test-related assets happen below this point
478
360
  let testJS = this.testJSEntrypoint(appFiles, prepared);
479
361
  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
362
  }
534
363
  // recurse to find all active addons that don't cross an engine boundary.
535
364
  // Inner engines themselves will be returned, but not those engines' children.
@@ -540,22 +369,31 @@ class CompatAppBuilder {
540
369
  if (!child.isEngine()) {
541
370
  this.findActiveAddons(child, engine, true);
542
371
  }
543
- engine.addons.add(child);
372
+ let canResolveFrom;
373
+ if (pkg === this.appPackageWithMovedDeps) {
374
+ // we want canResolveFrom to always be a rewritten package path, and our
375
+ // app's package is not rewritten yet here.
376
+ canResolveFrom = (0, path_1.resolve)(this.root, 'package.json');
377
+ }
378
+ else {
379
+ // whereas our addons are already moved
380
+ canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
381
+ }
382
+ engine.addons.set(child, canResolveFrom);
544
383
  }
545
384
  // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
546
385
  if (!isChild) {
547
- engine.addons = new Set([...engine.addons].sort((a, b) => {
386
+ engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
548
387
  return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
549
388
  }));
550
389
  }
551
390
  }
552
- partitionEngines(appJSPath) {
391
+ partitionEngines() {
553
392
  let queue = [
554
393
  {
555
394
  package: this.appPackageWithMovedDeps,
556
- addons: new Set(),
557
- parent: undefined,
558
- sourcePath: appJSPath,
395
+ addons: new Map(),
396
+ isApp: true,
559
397
  modulePrefix: this.modulePrefix(),
560
398
  appRelativePath: '.',
561
399
  },
@@ -568,14 +406,13 @@ class CompatAppBuilder {
568
406
  break;
569
407
  }
570
408
  this.findActiveAddons(current.package, current);
571
- for (let addon of current.addons) {
409
+ for (let addon of current.addons.keys()) {
572
410
  if (addon.isEngine() && !seenEngines.has(addon)) {
573
411
  seenEngines.add(addon);
574
412
  queue.push({
575
413
  package: addon,
576
- addons: new Set(),
577
- parent: current,
578
- sourcePath: addon.root,
414
+ addons: new Map(),
415
+ isApp: !current,
579
416
  modulePrefix: addon.name,
580
417
  appRelativePath: (0, core_1.explicitRelative)(this.root, addon.root),
581
418
  });
@@ -601,8 +438,8 @@ class CompatAppBuilder {
601
438
  updateAppJS(appJSPath) {
602
439
  var _a;
603
440
  if (!this.engines) {
604
- this.engines = this.partitionEngines(appJSPath).map(engine => {
605
- if (engine.sourcePath === appJSPath) {
441
+ this.engines = this.partitionEngines().map(engine => {
442
+ if (engine.isApp) {
606
443
  // this is the app. We have more to do for the app than for other
607
444
  // engines.
608
445
  let fastbootSync;
@@ -624,7 +461,7 @@ class CompatAppBuilder {
624
461
  // their files, not doing any actual copying or building.
625
462
  return {
626
463
  engine,
627
- appSync: new sync_dir_1.SyncDir(engine.sourcePath, undefined),
464
+ appSync: new sync_dir_1.SyncDir(engine.package.root, undefined),
628
465
  // AFAIK, we've never supported a fastboot overlay directory in an
629
466
  // engine. But if we do need that, it would go here.
630
467
  fastbootSync: undefined,
@@ -641,7 +478,7 @@ class CompatAppBuilder {
641
478
  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
479
  });
643
480
  }
644
- prepareAsset(asset, appFiles, prepared, emberENV) {
481
+ prepareAsset(asset, appFiles, prepared) {
645
482
  if (asset.kind === 'ember') {
646
483
  let prior = this.assets.get(asset.relativePath);
647
484
  let parsed;
@@ -653,17 +490,17 @@ class CompatAppBuilder {
653
490
  else {
654
491
  parsed = new ParsedEmberAsset(asset);
655
492
  }
656
- this.insertEmberApp(parsed, appFiles, prepared, emberENV);
493
+ this.insertEmberApp(parsed, appFiles, prepared);
657
494
  prepared.set(asset.relativePath, new BuiltEmberAsset(parsed));
658
495
  }
659
496
  else {
660
497
  prepared.set(asset.relativePath, asset);
661
498
  }
662
499
  }
663
- prepareAssets(requestedAssets, appFiles, emberENV) {
500
+ prepareAssets(requestedAssets, appFiles) {
664
501
  let prepared = new Map();
665
502
  for (let asset of requestedAssets) {
666
- this.prepareAsset(asset, appFiles, prepared, emberENV);
503
+ this.prepareAsset(asset, appFiles, prepared);
667
504
  }
668
505
  return prepared;
669
506
  }
@@ -729,8 +566,8 @@ class CompatAppBuilder {
729
566
  }
730
567
  await concat.end();
731
568
  }
732
- async updateAssets(requestedAssets, appFiles, emberENV) {
733
- let assets = this.prepareAssets(requestedAssets, appFiles, emberENV);
569
+ async updateAssets(requestedAssets, appFiles) {
570
+ let assets = this.prepareAssets(requestedAssets, appFiles);
734
571
  for (let asset of assets.values()) {
735
572
  if (this.assetIsValid(asset, this.assets.get(asset.relativePath))) {
736
573
  continue;
@@ -764,21 +601,6 @@ class CompatAppBuilder {
764
601
  gatherAssets(inputPaths) {
765
602
  // first gather all the assets out of addons
766
603
  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
604
  if (this.activeFastboot) {
783
605
  const source = `
784
606
  (function(){
@@ -807,9 +629,8 @@ class CompatAppBuilder {
807
629
  this.firstBuild = false;
808
630
  }
809
631
  let appFiles = this.updateAppJS(inputPaths.appJS);
810
- let emberENV = this.configTree.readConfig().EmberENV;
811
632
  let assets = this.gatherAssets(inputPaths);
812
- let finalAssets = await this.updateAssets(assets, appFiles, emberENV);
633
+ let finalAssets = await this.updateAssets(assets, appFiles);
813
634
  let assetPaths = assets.map(asset => asset.relativePath);
814
635
  if (this.activeFastboot) {
815
636
  // when using fastboot, our own package.json needs to be in the output so fastboot can read it.
@@ -829,7 +650,7 @@ class CompatAppBuilder {
829
650
  assets: assetPaths,
830
651
  babel: {
831
652
  filename: '_babel_config_.js',
832
- isParallelSafe: true,
653
+ isParallelSafe: true, // TODO
833
654
  majorVersion: this.compatApp.babelMajorVersion(),
834
655
  fileFilter: '_babel_filter_.js',
835
656
  },
@@ -841,8 +662,11 @@ class CompatAppBuilder {
841
662
  (0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
842
663
  let resolverConfig = this.resolverConfig(appFiles);
843
664
  this.addResolverConfig(resolverConfig);
844
- let babelConfig = this.babelConfig(resolverConfig);
665
+ this.addContentForConfig(this.contentForTree.readContents());
666
+ this.addEmberEnvConfig(this.configTree.readConfig().EmberENV);
667
+ let babelConfig = await this.babelConfig(resolverConfig);
845
668
  this.addBabelConfig(babelConfig);
669
+ (0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'macros-config.json'), JSON.stringify(this.compatApp.macrosConfig.babelPluginConfig()[0], null, 2));
846
670
  }
847
671
  combinePackageJSON(meta) {
848
672
  let pkgLayers = [this.origAppPackage.packageJSON];
@@ -855,7 +679,7 @@ class CompatAppBuilder {
855
679
  pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
856
680
  return combinePackageJSON(...pkgLayers);
857
681
  }
858
- etcOptions(resolverConfig) {
682
+ async etcOptions(resolverConfig) {
859
683
  let transforms = this.compatApp.htmlbarsPlugins;
860
684
  let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
861
685
  setConfig(this.compatApp.macrosConfig);
@@ -872,7 +696,7 @@ class CompatAppBuilder {
872
696
  transforms.push([require.resolve('./resolver-transform'), opts]);
873
697
  }
874
698
  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'));
699
+ let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
876
700
  if (resolution.type !== 'real') {
877
701
  throw new Error(`bug: unable to resolve ember-template-compiler from ${this.root}`);
878
702
  }
@@ -909,6 +733,16 @@ class CompatAppBuilder {
909
733
  addResolverConfig(config) {
910
734
  (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
911
735
  }
736
+ addContentForConfig(contentForConfig) {
737
+ (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
738
+ spaces: 2,
739
+ });
740
+ }
741
+ addEmberEnvConfig(emberEnvConfig) {
742
+ (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
743
+ spaces: 2,
744
+ });
745
+ }
912
746
  shouldSplitRoute(routeName) {
913
747
  return (!this.options.splitAtRoutes ||
914
748
  this.options.splitAtRoutes.find(pattern => {
@@ -1014,13 +848,10 @@ class CompatAppBuilder {
1014
848
  let styles = [];
1015
849
  // only import styles from engines with a parent (this excludeds the parent application) as their styles
1016
850
  // 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
- }
851
+ if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
852
+ styles.push({
853
+ path: '@embroider/core/vendor.css',
854
+ });
1024
855
  let engineMeta = appFiles.engine.package.meta;
1025
856
  if (engineMeta && engineMeta['implicit-styles']) {
1026
857
  for (let style of engineMeta['implicit-styles']) {
@@ -1061,10 +892,16 @@ class CompatAppBuilder {
1061
892
  let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
1062
893
  let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
1063
894
  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 };
895
+ let params = {
896
+ amdModules,
897
+ fastbootOnlyAmdModules,
898
+ lazyRoutes,
899
+ lazyEngines,
900
+ eagerModules,
901
+ styles,
902
+ // this is a backward-compatibility feature: addons can force inclusion of modules.
903
+ defineModulesFrom: './-embroider-implicit-modules.js',
904
+ };
1068
905
  if (entryParams) {
1069
906
  Object.assign(params, entryParams);
1070
907
  }
@@ -1116,9 +953,6 @@ class CompatAppBuilder {
1116
953
  (0, core_1.explicitRelative)((0, path_2.dirname)(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
1117
954
  ];
1118
955
  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
956
  for (let relativePath of engine.tests) {
1123
957
  amdModules.push(this.importPaths(engine, relativePath));
1124
958
  }
@@ -1126,6 +960,8 @@ class CompatAppBuilder {
1126
960
  amdModules,
1127
961
  eagerModules,
1128
962
  testSuffix: true,
963
+ // this is a backward-compatibility feature: addons can force inclusion of test support modules.
964
+ defineModulesFrom: './-embroider-implicit-test-modules.js',
1129
965
  });
1130
966
  asset = {
1131
967
  kind: 'in-memory',
@@ -1197,6 +1033,15 @@ let d = w.define;
1197
1033
  }
1198
1034
  {{/if}}
1199
1035
 
1036
+ {{#if defineModulesFrom ~}}
1037
+ import implicitModules from "{{js-string-escape defineModulesFrom}}";
1038
+
1039
+ for(const [name, module] of Object.entries(implicitModules)) {
1040
+ d(name, function() { return module });
1041
+ }
1042
+ {{/if}}
1043
+
1044
+
1200
1045
  {{#each eagerModules as |eagerModule| ~}}
1201
1046
  i("{{js-string-escape eagerModule}}");
1202
1047
  {{/each}}
@@ -1207,9 +1052,17 @@ let d = w.define;
1207
1052
 
1208
1053
  {{#if fastbootOnlyAmdModules}}
1209
1054
  if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
1055
+ let fastbootModules = {};
1056
+
1210
1057
  {{#each fastbootOnlyAmdModules as |amdModule| ~}}
1211
- d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
1058
+ fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
1212
1059
  {{/each}}
1060
+
1061
+ const resolvedValues = await Promise.all(Object.values(fastbootModules));
1062
+
1063
+ Object.keys(fastbootModules).forEach((k, i) => {
1064
+ d(k, function(){ return resolvedValues[i];});
1065
+ })
1213
1066
  }
1214
1067
  {{/if}}
1215
1068