-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep the messier old parallelBabel hacks in order to keep working wit…
…h older htmlbars
- Loading branch information
Showing
1 changed file
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |