Skip to content

Commit

Permalink
Merge pull request #754 from embroider-build/htmlbars-plugin-serializ…
Browse files Browse the repository at this point in the history
…ation

compatibility with ember-cli-htmlbars serialization
  • Loading branch information
ef4 authored Apr 24, 2021
2 parents 6e427f6 + a47df37 commit ac52706
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/compat/src/htmlbars-unwrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function unwrapPlugin(params: { requireFile: string; buildUsing: string; params: any }) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require(params.requireFile)[params.buildUsing](params.params).plugin;
}
17 changes: 17 additions & 0 deletions packages/compat/src/v1-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,23 @@ export default class V1App {
// even if the app was using @embroider/macros, we drop it from the config
// here in favor of our globally-configured one.
options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));

// The parallelization protocol in ember-cli-htmlbars doesn't actually
// apply to the AST plugins, it applies to wrappers that
// ember-cli-htmlbars keeps around the plugins. Those wrappers aren't
// availble to us when we look at the template compiler configuration, so
// we need to find them directly out of the registry here. And we need to
// provide our own unwrapper shim to pull the real plugin out of the
// wrapper after deserializing.
for (let wrapper of this.app.registry.load('htmlbars-ast-plugin')) {
if (wrapper.parallelBabel && wrapper.plugin && !wrapper.plugin.parallelBabel) {
wrapper.plugin.parallelBabel = {
requireFile: join(__dirname, 'htmlbars-unwrapper.js'),
buildUsing: 'unwrapPlugin',
params: wrapper.parallelBabel,
};
}
}
}
return options.plugins;
}
Expand Down

0 comments on commit ac52706

Please sign in to comment.