Skip to content

Commit

Permalink
keep the messier old parallelBabel hacks in order to keep working wit…
Browse files Browse the repository at this point in the history
…h older htmlbars
  • Loading branch information
ef4 committed Dec 23, 2023
1 parent 7651407 commit ed5e09c
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/compat/src/prepare-htmlbars-ast-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
import type { Transform } from 'babel-plugin-ember-template-compilation';
import { join } from 'path';

export default function loadAstPlugins(registry: any): Transform[] {
let plugins = registry.load('htmlbars-ast-plugin').map((wrapper: any) => wrapper.plugin);
let wrappers = registry.load('htmlbars-ast-plugin');
for (let wrapper of wrappers) {
const { plugin, parallelBabel, baseDir, cacheKey } = wrapper;
if (plugin) {
// if the parallelBabel options were set on the wrapper, but not on the plugin, add it
if (parallelBabel && !plugin.parallelBabel) {
plugin.parallelBabel = {
requireFile: join(__dirname, 'htmlbars-unwrapper.js'),
buildUsing: 'unwrapPlugin',
params: parallelBabel,
};
}

// NOTE: `_parallelBabel` (not `parallelBabel`) is expected by broccoli-babel-transpiler
if (plugin.parallelBabel && !plugin._parallelBabel) {
plugin._parallelBabel = plugin.parallelBabel;
}

// if the baseDir is set on the wrapper, but not on the plugin, add it
if (baseDir && !plugin.baseDir) {
plugin.baseDir = baseDir;
}

// if the cacheKey is set on the wrapper, but not on the plugin, add it
if (cacheKey && !plugin.cacheKey) {
plugin.cacheKey = cacheKey;
}
}
}
let plugins = wrappers.map((wrapper: any) => wrapper.plugin);
plugins.reverse();
return plugins;
}

0 comments on commit ed5e09c

Please sign in to comment.