diff --git a/packages/compat/src/prepare-htmlbars-ast-plugins.ts b/packages/compat/src/prepare-htmlbars-ast-plugins.ts
new file mode 100644
index 000000000..092bf5c59
--- /dev/null
+++ b/packages/compat/src/prepare-htmlbars-ast-plugins.ts
@@ -0,0 +1,32 @@
+import { join } from 'path';
+
+export default function prepHtmlbarsAstPluginsForUnwrap(registry: any): void {
+ for (let wrapper of registry.load('htmlbars-ast-plugin')) {
+ 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;
+ }
+ }
+ }
+}
diff --git a/packages/compat/src/v1-addon.ts b/packages/compat/src/v1-addon.ts
index 977e49723..eaedf28a4 100644
--- a/packages/compat/src/v1-addon.ts
+++ b/packages/compat/src/v1-addon.ts
@@ -27,6 +27,7 @@ import { ResolvedDep } from '@embroider/core/src/resolver';
import TemplateCompilerBroccoliPlugin from './template-compiler-broccoli-plugin';
import { fromPairs } from 'lodash';
import { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';
+import prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';
const stockTreeNames = Object.freeze([
'addon',
@@ -132,6 +133,7 @@ export default class V1Addon {
if (options.plugins && options.plugins.ast) {
// our macros don't run here in stage1
options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));
+ prepHtmlbarsAstPluginsForUnwrap(this.addonInstance.registry);
if (options.plugins.ast.length > 0) {
const { cacheKey: compilerChecksum } = getEmberExports(options.templateCompilerPath);
diff --git a/packages/compat/src/v1-app.ts b/packages/compat/src/v1-app.ts
index db93f9372..8dcdb88a4 100644
--- a/packages/compat/src/v1-app.ts
+++ b/packages/compat/src/v1-app.ts
@@ -19,6 +19,7 @@ import Concat from 'broccoli-concat';
import mapKeys from 'lodash/mapKeys';
import SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';
import { isEmberAutoImportDynamic } from './detect-babel-plugins';
+import prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';
// This controls and types the interface between our new world and the classic
// v1 app instance.
@@ -560,23 +561,7 @@ 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,
- };
- }
- }
+ prepHtmlbarsAstPluginsForUnwrap(this.app.registry);
}
return options.plugins;
}
diff --git a/packages/compat/tests/stage1.test.ts b/packages/compat/tests/stage1.test.ts
index 1996db9d9..89b31b8be 100644
--- a/packages/compat/tests/stage1.test.ts
+++ b/packages/compat/tests/stage1.test.ts
@@ -11,6 +11,7 @@ describe('stage1 build', function () {
let expectFile: ExpectFile;
beforeAll(async function () {
+ process.env.THROW_UNLESS_PARALLELIZABLE = '1'; // see https://github.com/embroider-build/embroider/pull/924
// A simple ember app with no tests
let app = Project.emberNew();
@@ -107,6 +108,7 @@ describe('stage1 build', function () {
});
afterAll(async function () {
+ delete process.env.THROW_UNLESS_PARALLELIZABLE;
await build.cleanup();
});