Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with ember-cli-htmlbars serialization #754

Merged
merged 1 commit into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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