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

Helpers fail to resolve from .hbs.js file with embroider 2.x and static helpers #1296

Closed
bendemboski opened this issue Nov 29, 2022 · 2 comments · Fixed by #1299
Closed

Helpers fail to resolve from .hbs.js file with embroider 2.x and static helpers #1296

bendemboski opened this issue Nov 29, 2022 · 2 comments · Fixed by #1299

Comments

@bendemboski
Copy link
Contributor

Broken off of #1293

When building with embroider 2.x and static helpers, <BasicDropdown> fails to render because it fails to resolve any of its helpers (starting with ensure-safe-component). It looks like a template compilation problem, perhaps specific to files that end up with the .hbs.js extension.

this repo demonstrates the issue, and its README describes what I've found through my investigation.

@ef4
Copy link
Contributor

ef4 commented Nov 29, 2022

Thanks for the reproduction, I see the bug. When @embroider/compat is detecting what babel plugins are present in a v1 addon, it needs to remove any template compiler that's already present so that we can use our own. But it's failing to detect the template compiler installed by the newest ember-cli-htmlbars on new-enough ember versions.

This will be the fix, I just need to look through our test suite to see why this wasn't already being covered.

diff --git a/packages/compat/src/detect-babel-plugins.ts b/packages/compat/src/detect-babel-plugins.ts
index dbcd663e..1e65a7ba 100644
--- a/packages/compat/src/detect-babel-plugins.ts
+++ b/packages/compat/src/detect-babel-plugins.ts
@@ -76,4 +76,5 @@ const htmlbarPathMatches = [
   ['ember-cli-htmlbars', 'lib', 'require-from-worker.js'].join(sep),
   ['ember-cli-htmlbars', 'index'].join(sep),
   ['ember-cli-htmlbars', 'lib', 'require-from-worker'].join(sep),
+  ['babel-plugin-ember-template-compilation', 'src', 'node-main.js'].join(sep),
 ];

@ef4
Copy link
Contributor

ef4 commented Nov 29, 2022

I figured out why the tests don't notice this -- it's because this case only happens if some other babel plugin is preventing ember-cli-babel from parallelizing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants