@embroider/compat 3.6.2-unstable.a691d39 → 3.6.2-unstable.aa52b09

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.
@@ -1,4 +1,4 @@
1
1
  import V1Addon from '../v1-addon';
2
2
  export default class extends V1Addon {
3
- get packageMeta(): Partial<import("@embroider/core").AddonMeta>;
3
+ get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
4
4
  }
@@ -1,4 +1,4 @@
1
1
  import V1Addon from '../v1-addon';
2
2
  export default class extends V1Addon {
3
- get packageMeta(): Partial<import("@embroider/core").AddonMeta>;
3
+ get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
4
4
  }
@@ -3,12 +3,12 @@ export default class extends V1Addon {
3
3
  get v2Tree(): Node;
4
4
  private get useStaticEmber();
5
5
  private get includedDependencies();
6
- get newPackageJSON(): import("@embroider/core").PackageInfo;
6
+ get newPackageJSON(): import("@embroider/shared-internals").PackageInfo;
7
7
  customizes(treeName: string): boolean;
8
8
  invokeOriginalTreeFor(name: string, opts?: {
9
9
  neuterPreprocessors: boolean;
10
10
  }): any;
11
11
  private customAddonTree;
12
12
  private customVendorTree;
13
- get packageMeta(): Partial<import("@embroider/core").AddonMeta>;
13
+ get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import V1Addon from '../v1-addon';
2
2
  export default class extends V1Addon {
3
3
  static shouldApplyAdapter(addonInstance: any): boolean;
4
- get packageMeta(): Partial<import("@embroider/core").AddonMeta>;
4
+ get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
5
5
  }
@@ -13,27 +13,14 @@ export declare class CompatAppBuilder {
13
13
  private synthVendor;
14
14
  private synthStyles;
15
15
  constructor(origAppPackage: Package, appPackageWithMovedDeps: Package, options: Required<Options>, compatApp: CompatApp, configTree: V1Config, contentForTree: ContentForConfig, synthVendor: Package, synthStyles: Package);
16
- private activeAddonChildren;
17
- private get allActiveAddons();
18
- private isActiveAddon;
19
- private orderAddons;
20
- private resolvableExtensions;
21
16
  private modulePrefix;
22
17
  private podModulePrefix;
23
- private activeRules;
24
- private resolverConfig;
25
- private babelConfig;
26
- private findActiveAddons;
27
- private partitionEngines;
28
- private emberVersion;
29
- private engines;
18
+ private get resolverConfig();
30
19
  build(): Promise<void>;
31
- private etcOptions;
32
20
  private get portableHints();
33
- private addBabelConfig;
21
+ private addBabelCompat;
34
22
  private addResolverConfig;
35
23
  private addContentForConfig;
36
24
  private addEmberEnvConfig;
37
- private addMacrosConfig;
38
25
  private outputAppBootError;
39
26
  }
@@ -11,19 +11,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CompatAppBuilder = void 0;
13
13
  const core_1 = require("@embroider/core");
14
- const path_1 = require("path");
15
14
  const dependency_rules_1 = require("./dependency-rules");
16
- const flatMap_1 = __importDefault(require("lodash/flatMap"));
17
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
18
- const bind_decorator_1 = __importDefault(require("bind-decorator"));
19
15
  const fs_extra_1 = require("fs-extra");
20
- const portable_babel_config_1 = require("@embroider/core/src/portable-babel-config");
21
16
  const portable_1 = require("@embroider/core/src/portable");
22
17
  const typescript_memoize_1 = require("typescript-memoize");
23
- const path_2 = require("path");
18
+ const path_1 = require("path");
24
19
  const resolve_1 = __importDefault(require("resolve"));
25
20
  const fs_extra_2 = require("fs-extra");
26
21
  const node_1 = require("@embroider/macros/src/node");
22
+ const module_resolver_options_1 = require("@embroider/core/src/module-resolver-options");
27
23
  // This exists during the actual broccoli build step. As opposed to CompatApp,
28
24
  // which also exists during pipeline-construction time.
29
25
  class CompatAppBuilder {
@@ -37,292 +33,57 @@ class CompatAppBuilder {
37
33
  this.synthVendor = synthVendor;
38
34
  this.synthStyles = synthStyles;
39
35
  }
40
- activeAddonChildren(pkg) {
41
- let result = pkg.dependencies.filter(this.isActiveAddon).filter(
42
- // When looking for child addons, we want to ignore 'peerDependencies' of
43
- // a given package, to align with how ember-cli resolves addons. So here
44
- // we only include dependencies that are definitely active due to one of
45
- // the other sections.
46
- addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies');
47
- if (pkg === this.appPackageWithMovedDeps) {
48
- let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
49
- result = [...result, ...extras];
50
- }
51
- return result.sort(this.orderAddons);
52
- }
53
- get allActiveAddons() {
54
- let result = this.appPackageWithMovedDeps.findDescendants(this.isActiveAddon);
55
- let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
56
- let extraDescendants = (0, flatMap_1.default)(extras, dep => dep.findDescendants(this.isActiveAddon));
57
- result = [...result, ...extras, ...extraDescendants];
58
- return result.sort(this.orderAddons);
59
- }
60
- isActiveAddon(pkg) {
61
- // stage1 already took care of converting everything that's actually active
62
- // into v2 addons. If it's not a v2 addon, we don't want it.
63
- //
64
- // We can encounter v1 addons here when there is inactive stuff floating
65
- // around in the node_modules that accidentally satisfy something like an
66
- // optional peer dep.
67
- return pkg.isV2Addon();
68
- }
69
- orderAddons(depA, depB) {
70
- let depAIdx = 0;
71
- let depBIdx = 0;
72
- if (depA && depA.meta && depA.isV2Addon()) {
73
- depAIdx = depA.meta['order-index'] || 0;
74
- }
75
- if (depB && depB.meta && depB.isV2Addon()) {
76
- depBIdx = depB.meta['order-index'] || 0;
77
- }
78
- return depAIdx - depBIdx;
79
- }
80
- resolvableExtensions() {
81
- let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;
82
- if (fromEnv) {
83
- return fromEnv.split(',');
84
- }
85
- else {
86
- return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];
87
- }
88
- }
89
36
  modulePrefix() {
90
37
  return this.configTree.readConfig().modulePrefix;
91
38
  }
92
39
  podModulePrefix() {
93
40
  return this.configTree.readConfig().podModulePrefix;
94
41
  }
95
- activeRules() {
96
- return (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
97
- { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },
98
- ...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),
99
- ]);
100
- }
101
- resolverConfig(engines) {
102
- let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
103
- let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
104
- let options = {
105
- staticHelpers: this.options.staticHelpers,
106
- staticModifiers: this.options.staticModifiers,
107
- staticComponents: this.options.staticComponents,
108
- allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
109
- };
110
- let config = {
111
- // this part is the base ModuleResolverOptions as required by @embroider/core
112
- renameModules,
113
- renamePackages,
114
- resolvableExtensions: this.resolvableExtensions(),
115
- appRoot: this.origAppPackage.root,
116
- engines: engines.map(engine => ({
117
- packageName: engine.package.name,
118
- // we need to use the real path here because webpack requests always use the real path i.e. follow symlinks
119
- root: (0, fs_extra_1.realpathSync)(engine.package.root),
120
- fastbootFiles: {},
121
- activeAddons: [...engine.addons]
122
- .map(([addon, canResolveFromFile]) => ({
123
- name: addon.name,
124
- root: addon.root,
125
- canResolveFromFile,
126
- }))
127
- // the traditional order is the order in which addons will run, such
128
- // that the last one wins. Our resolver's order is the order to
129
- // search, so first one wins.
130
- .reverse(),
131
- isLazy: engine.package.isLazyEngine(),
132
- })),
133
- amdCompatibility: this.options.amdCompatibility,
134
- // this is the additional stufff that @embroider/compat adds on top to do
135
- // global template resolving
42
+ get resolverConfig() {
43
+ return (0, module_resolver_options_1.buildResolverOptions)({
44
+ appPackage: this.appPackageWithMovedDeps,
136
45
  modulePrefix: this.modulePrefix(),
137
- splitAtRoutes: this.options.splitAtRoutes,
138
46
  podModulePrefix: this.podModulePrefix(),
139
- activePackageRules: this.activeRules(),
140
- options,
141
- autoRun: this.compatApp.autoRun,
47
+ splitAtRoutes: this.options.splitAtRoutes,
142
48
  staticAppPaths: this.options.staticAppPaths,
143
- };
144
- return config;
145
- }
146
- async babelConfig(resolverConfig) {
147
- let babel = (0, cloneDeep_1.default)(this.compatApp.babelConfig());
148
- if (!babel.plugins) {
149
- babel.plugins = [];
150
- }
151
- // Our stage3 code is always allowed to use dynamic import. We may emit it
152
- // ourself when splitting routes.
153
- babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));
154
- // https://github.com/webpack/webpack/issues/12154
155
- babel.plugins.push(require.resolve('./rename-require-plugin'));
156
- babel.plugins.push([
157
- require.resolve('babel-plugin-ember-template-compilation'),
158
- await this.etcOptions(resolverConfig),
159
- ]);
160
- // this is @embroider/macros configured for full stage3 resolution
161
- babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
162
- let colocationOptions = {
163
- appRoot: this.origAppPackage.root,
164
- // This extra weirdness is a compromise in favor of build performance.
165
- //
166
- // 1. When auto-upgrading an addon from v1 to v2, we definitely want to
167
- // run any custom AST transforms in stage1.
168
- //
169
- // 2. In general case, AST transforms are allowed to manipulate Javascript
170
- // scope. This means that running transforms -- even when we're doing
171
- // source-to-source compilation that emits handlebars and not wire
172
- // format -- implies changing .hbs files into .js files.
173
- //
174
- // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding
175
- // with an existing co-located .js file).
176
- //
177
- // 4. But stage1 doesn't necessarily want to run babel over the
178
- // corresponding JS file. Most of the time, that's just an
179
- // unnecessarily expensive second parse. (We only run it in stage1 to
180
- // eliminate an addon's custom babel plugins, and many addons don't
181
- // have any.)
182
- //
183
- // 5. Therefore, the work of template-colocation gets defered until here,
184
- // and it may see co-located templates named `.hbs.js` instead of the
185
- // usual `.hbs.
186
- templateExtensions: ['.hbs', '.hbs.js'],
187
- // All of the above only applies to auto-upgraded packages that were
188
- // authored in v1. V2 packages don't get any of this complexity, they're
189
- // supposed to take care of colocating their own templates explicitly.
190
- packageGuard: true,
191
- };
192
- babel.plugins.push([core_1.templateColocationPluginPath, colocationOptions]);
193
- babel.plugins.push([
194
- require.resolve('./babel-plugin-adjust-imports'),
195
- (() => {
196
- let pluginConfig = {
197
- appRoot: resolverConfig.appRoot,
49
+ extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles]]]),
50
+ extend: (options, allActiveAddons) => {
51
+ options.activePackageRules = (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
52
+ { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },
53
+ ...allActiveAddons.filter(p => p.meta['auto-upgraded']),
54
+ ]);
55
+ options.options = {
56
+ staticHelpers: this.options.staticHelpers,
57
+ staticModifiers: this.options.staticModifiers,
58
+ staticComponents: this.options.staticComponents,
59
+ allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
198
60
  };
199
- return pluginConfig;
200
- })(),
201
- ]);
202
- // we can use globally shared babel runtime by default
203
- babel.plugins.push([
204
- require.resolve('@babel/plugin-transform-runtime'),
205
- { absoluteRuntime: __dirname, useESModules: true, regenerator: false },
206
- ]);
207
- const portable = (0, portable_babel_config_1.makePortable)(babel, { basedir: this.origAppPackage.root }, this.portableHints);
208
- addCachablePlugin(portable.config);
209
- return portable;
210
- }
211
- // recurse to find all active addons that don't cross an engine boundary.
212
- // Inner engines themselves will be returned, but not those engines' children.
213
- // The output set's insertion order is the proper ember-cli compatible
214
- // ordering of the addons.
215
- findActiveAddons(pkg, engine, isChild = false) {
216
- for (let child of this.activeAddonChildren(pkg)) {
217
- if (!child.isEngine()) {
218
- this.findActiveAddons(child, engine, true);
219
- }
220
- let canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
221
- engine.addons.set(child, canResolveFrom);
222
- }
223
- // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
224
- if (!isChild) {
225
- engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
226
- return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
227
- }));
228
- }
229
- }
230
- partitionEngines() {
231
- let queue = [
232
- {
233
- package: this.appPackageWithMovedDeps,
234
- addons: new Map(),
235
- isApp: true,
236
- modulePrefix: this.modulePrefix(),
237
- appRelativePath: '.',
61
+ return options;
238
62
  },
239
- ];
240
- let done = [];
241
- let seenEngines = new Set();
242
- while (true) {
243
- let current = queue.shift();
244
- if (!current) {
245
- break;
246
- }
247
- this.findActiveAddons(current.package, current);
248
- for (let addon of current.addons.keys()) {
249
- if (addon.isEngine() && !seenEngines.has(addon)) {
250
- seenEngines.add(addon);
251
- queue.push({
252
- package: addon,
253
- addons: new Map(),
254
- isApp: !current,
255
- modulePrefix: addon.name,
256
- appRelativePath: (0, core_1.explicitRelative)(this.origAppPackage.root, addon.root),
257
- });
258
- }
259
- }
260
- done.push(current);
261
- }
262
- return done;
263
- }
264
- emberVersion() {
265
- let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');
266
- if (!pkg) {
267
- throw new Error('no ember version!');
268
- }
269
- return pkg.version;
63
+ });
270
64
  }
271
65
  async build() {
272
66
  // on the first build, we lock down the macros config. on subsequent builds,
273
67
  // this doesn't do anything anyway because it's idempotent.
274
68
  this.compatApp.macrosConfig.finalize();
275
- if (!this.engines) {
276
- this.engines = this.partitionEngines();
277
- }
278
- let resolverConfig = this.resolverConfig(this.engines);
69
+ let resolverConfig = this.resolverConfig;
279
70
  let config = this.configTree.readConfig();
280
71
  let contentForConfig = this.contentForTree.readContents();
281
72
  this.addResolverConfig(resolverConfig);
282
73
  this.addContentForConfig(contentForConfig);
283
74
  this.addEmberEnvConfig(config.EmberENV);
284
75
  this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);
285
- let babelConfig = await this.babelConfig(resolverConfig);
286
- this.addBabelConfig(babelConfig);
287
- this.addMacrosConfig(this.compatApp.macrosConfig.babelPluginConfig()[0]);
288
- }
289
- async etcOptions(resolverConfig) {
290
- let transforms = this.compatApp.htmlbarsPlugins;
291
- let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
292
- setConfig(this.compatApp.macrosConfig);
293
- for (let macroPlugin of macroPlugins) {
294
- transforms.push(macroPlugin);
295
- }
296
- if (this.options.staticComponents ||
297
- this.options.staticHelpers ||
298
- this.options.staticModifiers ||
299
- globalThis.embroider_audit) {
300
- let opts = {
301
- appRoot: resolverConfig.appRoot,
302
- emberVersion: this.emberVersion(),
303
- };
304
- transforms.push([require.resolve('./resolver-transform'), opts]);
305
- }
306
- let resolver = new core_1.Resolver(resolverConfig);
307
- let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.origAppPackage.root, 'package.json'));
308
- if (resolution.type !== 'real') {
309
- throw new Error(`bug: unable to resolve ember-template-compiler from ${this.origAppPackage.root}`);
310
- }
311
- return {
312
- transforms,
313
- compilerPath: resolution.filename,
314
- enableLegacyModules: ['ember-cli-htmlbars', 'ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile'],
315
- };
76
+ this.addBabelCompat();
316
77
  }
317
78
  get portableHints() {
318
79
  return this.options.pluginHints.map(hint => {
319
- let cursor = (0, path_2.join)(this.origAppPackage.root, 'package.json');
80
+ let cursor = (0, path_1.join)(this.origAppPackage.root, 'package.json');
320
81
  for (let i = 0; i < hint.resolve.length; i++) {
321
82
  let target = hint.resolve[i];
322
83
  if (i < hint.resolve.length - 1) {
323
- target = (0, path_2.join)(target, 'package.json');
84
+ target = (0, path_1.join)(target, 'package.json');
324
85
  }
325
- cursor = resolve_1.default.sync(target, { basedir: (0, path_2.dirname)(cursor) });
86
+ cursor = resolve_1.default.sync(target, { basedir: (0, path_1.dirname)(cursor) });
326
87
  }
327
88
  return {
328
89
  requireFile: cursor,
@@ -331,18 +92,32 @@ class CompatAppBuilder {
331
92
  };
332
93
  });
333
94
  }
334
- addBabelConfig(pconfig) {
335
- if (!pconfig.isParallelSafe) {
336
- (0, core_1.warn)('Your build is slower because some babel plugins are non-serializable');
95
+ addBabelCompat() {
96
+ let plugins = this.compatApp.extraBabelPlugins();
97
+ let templateTransforms = this.compatApp.htmlbarsPlugins;
98
+ let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();
99
+ let { plugins: templateMacros, setConfig } = node_1.MacrosConfig.transforms();
100
+ setConfig(this.compatApp.macrosConfig);
101
+ let config = {
102
+ plugins,
103
+ templateTransforms,
104
+ babelMacros,
105
+ templateMacros: templateMacros,
106
+ };
107
+ let portableConfig = new portable_1.Portable({ hints: this.portableHints }).dehydrate(config);
108
+ if (!portableConfig.isParallelSafe) {
109
+ throw new Error(`non-serializble babel plugins or AST transforms found in your app`);
337
110
  }
338
- (0, fs_extra_1.writeFileSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_config_.js'), `module.exports = ${JSON.stringify(pconfig.config, null, 2)}`, 'utf8');
339
- (0, fs_extra_1.writeFileSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_filter_.js'), babelFilterTemplate({ skipBabel: this.options.skipBabel, appRoot: this.origAppPackage.root }), 'utf8');
111
+ (0, fs_extra_1.writeFileSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_compat_.js'), `
112
+ const { Portable } = require('@embroider/core/src/portable');
113
+ module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});
114
+ `, 'utf8');
340
115
  }
341
116
  addResolverConfig(config) {
342
- (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
117
+ (0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
343
118
  }
344
119
  addContentForConfig(contentForConfig) {
345
- (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
120
+ (0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
346
121
  spaces: 2,
347
122
  });
348
123
  // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.
@@ -370,12 +145,7 @@ class CompatAppBuilder {
370
145
  }
371
146
  }
372
147
  addEmberEnvConfig(emberEnvConfig) {
373
- (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
374
- spaces: 2,
375
- });
376
- }
377
- addMacrosConfig(macrosConfig) {
378
- (0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'macros-config.json'), macrosConfig, {
148
+ (0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
379
149
  spaces: 2,
380
150
  });
381
151
  }
@@ -412,60 +182,19 @@ class CompatAppBuilder {
412
182
  exports.CompatAppBuilder = CompatAppBuilder;
413
183
  __decorate([
414
184
  (0, typescript_memoize_1.Memoize)()
415
- ], CompatAppBuilder.prototype, "allActiveAddons", null);
416
- __decorate([
417
- bind_decorator_1.default
418
- ], CompatAppBuilder.prototype, "isActiveAddon", null);
419
- __decorate([
420
- bind_decorator_1.default
421
- ], CompatAppBuilder.prototype, "orderAddons", null);
422
- __decorate([
423
- (0, typescript_memoize_1.Memoize)()
424
- ], CompatAppBuilder.prototype, "activeRules", null);
425
- __decorate([
426
- (0, typescript_memoize_1.Memoize)()
427
- ], CompatAppBuilder.prototype, "babelConfig", null);
185
+ ], CompatAppBuilder.prototype, "resolverConfig", null);
428
186
  __decorate([
429
187
  (0, typescript_memoize_1.Memoize)()
430
188
  ], CompatAppBuilder.prototype, "portableHints", null);
431
189
  function defaultAddonPackageRules() {
432
- return (0, fs_extra_2.readdirSync)((0, path_2.join)(__dirname, 'addon-dependency-rules'))
190
+ return (0, fs_extra_2.readdirSync)((0, path_1.join)(__dirname, 'addon-dependency-rules'))
433
191
  .map(filename => {
434
192
  if (filename.endsWith('.js')) {
435
193
  // eslint-disable-next-line @typescript-eslint/no-require-imports
436
- return require((0, path_2.join)(__dirname, 'addon-dependency-rules', filename)).default;
194
+ return require((0, path_1.join)(__dirname, 'addon-dependency-rules', filename)).default;
437
195
  }
438
196
  })
439
197
  .filter(Boolean)
440
198
  .reduce((a, b) => a.concat(b), []);
441
199
  }
442
- const babelFilterTemplate = (0, core_1.jsHandlebarsCompile)(`
443
- const { babelFilter } = require(${JSON.stringify(require.resolve('@embroider/core'))});
444
- module.exports = babelFilter({{json-stringify skipBabel}}, "{{js-string-escape appRoot}}");
445
- `);
446
- function addCachablePlugin(babelConfig) {
447
- if (Array.isArray(babelConfig.plugins) && babelConfig.plugins.length > 0) {
448
- const plugins = Object.create(null);
449
- plugins[core_1.cacheBustingPluginPath] = core_1.cacheBustingPluginVersion;
450
- for (const plugin of babelConfig.plugins) {
451
- let absolutePathToPlugin;
452
- if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
453
- absolutePathToPlugin = plugin[0];
454
- }
455
- else if (typeof plugin === 'string') {
456
- absolutePathToPlugin = plugin;
457
- }
458
- else {
459
- throw new Error(`[Embroider] a babel plugin without an absolute path was from: ${plugin}`);
460
- }
461
- plugins[absolutePathToPlugin] = (0, portable_1.maybeNodeModuleVersion)(absolutePathToPlugin);
462
- }
463
- babelConfig.plugins.push([
464
- core_1.cacheBustingPluginPath,
465
- {
466
- plugins,
467
- },
468
- ]);
469
- }
470
- }
471
200
  //# sourceMappingURL=compat-app-builder.js.map