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

Webpack is using the Ember global in compiled templates #781

Closed
sandydoo opened this issue Apr 27, 2021 · 4 comments · Fixed by #785
Closed

Webpack is using the Ember global in compiled templates #781

sandydoo opened this issue Apr 27, 2021 · 4 comments · Fixed by #785

Comments

@sandydoo
Copy link
Contributor

sandydoo commented Apr 27, 2021

Summary

I think Webpack is turning imports of createTemplateFactory into a reference to Ember.HTMLBars.template, which throws deprecation notices in apps running 3.27+.

In more detail

As of v3.27, accessing the Ember global throws a deprecation notice.

ember-cli-htmlbars was recently updated to replace Ember.HTMLBars.template with module imports.

Now, templates should be compiled with:

import { createTemplateFactory } from '@ember/template-factory';
export default createTemplateFactory(${precompiled});

But in apps built with Embroider specifically, what we see is the following:

const createTemplateFactory = Ember.HTMLBars.template;
...

My hunch is that Webpack is doing this, but I have no proof 🤣.
Any ideas? Am I completely wrong here?

Steps to reproduce

Run ember new with [email protected].
Inspect the console logs. You should see a warning coming from application.hbs.

Versions used for testing

@embroider/*: 0.39.1 && 0.40.0
ember-source: 3.27.0-beta.4
ember-cli-htmlbars: 5.7.1
@ef4
Copy link
Contributor

ef4 commented Apr 27, 2021

This is supposed to be handled here, could you poke around and see what's happening in that spot?

@sandydoo
Copy link
Contributor Author

sandydoo commented Apr 27, 2021

Never mind! I was totally wrong. It was this:

'@ember/template-factory': {
createTemplateFactory(t) {
return t.memberExpression(
t.memberExpression(t.identifier('Ember'), t.identifier('HTMLBars')),
t.identifier('template')
);
},
},

This polyfill is being run in apps on the 3.27.0-beta.x range because this semver check resolves to true for these versions. It’s a bit annoying, but it will resolve itself when 3.27.0 is released.

let emberNeedsModulesPolyfill = semver.satisfies(emberSource.version, '<3.27.0', { includePrerelease: true });

// ¯\(°_o)/¯ I guess
semver.satisfies('3.27.0-beta.4', '<3.27.0', { includePrerelease: true })
// > true
semver.satisfies('3.27.0-beta.4', '<3.27.0-beta.0', { includePrerelease: true })
// > false

@sandydoo
Copy link
Contributor Author

This is supposed to be handled here, could you poke around and see what's happening in that spot?

Just as I’m about to close the issue 😅 Great timing!

@ef4
Copy link
Contributor

ef4 commented Apr 27, 2021

We should probably still change that condition so it allows the beta series. I think semver.satisfies(emberSource.version, '<3.27.0-beta.0', { includePrerelease: true }) would do it and be more correct.

sandydoo added a commit to sandydoo/embroider that referenced this issue Apr 27, 2021
The polyfill uses the Ember global, which is deprecated in `3.27.0`.
This disables the polyfill for the `3.27.0-beta.x` ranges.

Fixes embroider-build#781.
sandydoo added a commit to sandydoo/embroider that referenced this issue Apr 27, 2021
The polyfill uses the Ember global, which is deprecated in `3.27.0`.
This additionally disables the polyfill for the `3.27.0-beta.x` ranges.

Fixes embroider-build#781.
sandydoo added a commit to sandydoo/embroider that referenced this issue Apr 27, 2021
The polyfill uses the Ember global, which is deprecated in `3.27.0`.
This additionally disables the polyfill for the `3.27.0-beta.x` ranges.

Fixes embroider-build#781.
sandydoo added a commit to sandydoo/embroider that referenced this issue Apr 27, 2021
The polyfill uses the Ember global, which is deprecated in `3.27.0`.
This additionally disables the polyfill for the `3.27.0-beta.x` ranges.

Fixes embroider-build#781.
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