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

Refactor template factory #18096

Merged
merged 1 commit into from
Jun 27, 2019
Merged

Refactor template factory #18096

merged 1 commit into from
Jun 27, 2019

Conversation

chancancode
Copy link
Member

@chancancode chancancode commented Jun 13, 2019

Per RFC #481, we want to align the factory signature between templates and component managers. Since the factories for component managers are just a function that takes the owner, we decided to move template factories in the same direction here as well.

@rwjblue
Copy link
Member

rwjblue commented Jun 13, 2019

Failed on linting:

$ tsc --noEmit
packages/@ember/-internals/glimmer/lib/component-managers/root.ts(27,22): error TS2554: Expected 1 arguments, but got 2.
error Command failed with exit code 1.

Need to fix this one manually I think.

@rwjblue
Copy link
Member

rwjblue commented Jun 14, 2019

I just rebased and fixed the linting failure.

@pzuraq / @krisselden - I'd love review here when y'all have a minute.

Per RFC #481, we want to align the factory signature between templates
and component managers. Since the factories for component managers are
just a function that takes the owner, we decided to move template
factories in the same direction here as well.

Co-authored-by: Robert Jackson <me@rwjblue.com>
@rwjblue
Copy link
Member

rwjblue commented Jun 18, 2019

CI is green now, still needs some review though...

Ping again @krisselden / @pzuraq 😸

registry.register('view:-outlet', OutletView);
registry.register('template:-outlet', OutletTemplate);
registry.register('template:-outlet', OutletTemplate as any);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need as any?

{
componentDefinitionCount: 1,
// 1 from this.render, 1 from component-one
templateCacheMisses: 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prior to this change, this path was only used for late bound templates that were cached because their lifetime wasn't in the DI system's container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thats correct. Are you saying this is bad/wrong/etc?

@rwjblue rwjblue merged commit 321370e into master Jun 27, 2019
@rwjblue rwjblue deleted the refactor-template-factory branch June 27, 2019 17:04
buschtoens added a commit to ember-decorators/ember-decorators that referenced this pull request Jul 1, 2019
emberjs/ember.js#18096

This PR changed how templates get transpiled under the hood.
The export from templates are now factory functions which expect to be
passed the `owner`.
buschtoens added a commit to buschtoens/ember-css-modules that referenced this pull request Jul 1, 2019
emberjs/ember.js#18096

This PR changed how templates are used under the hood. Template modules
now export a factory function that expects to be called with the
`owner`.
@buschtoens
Copy link
Contributor

buschtoens commented Jul 1, 2019

if (DEBUG) {
this._pushToDebugStack(`template:${definition.template.referrer.moduleName}`, environment);
}

definition.template is a Factory now and this breaks. Where is the error? Should this actually be typed and used as a Factory, which would entail changes in quite a few files, e.g.:

    if (DEBUG) {
      let owner = getOwner(this);
      let template = definition.template(owner);
      this._pushToDebugStack(`template:${template.referrer.moduleName}`, environment);
    }

Or should this class actually still be instantiated with an OwnedTemplate, like before?

buschtoens added a commit to buschtoens/ember-css-modules that referenced this pull request Jul 1, 2019
emberjs/ember.js#18096

This PR changed how templates are used under the hood. Template modules
now export a factory function that expects to be called with the
`owner`.
@buschtoens
Copy link
Contributor

Example of a test suite failure: https://travis-ci.org/salsify/ember-css-modules/jobs/552819509

@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2019

@ember/test-helpers needs a corresponding change (with feature detection) to avoid the error. FWIW, this is why we did this change early in the canary cycle so we can shake out any issues prior to beta.

@buschtoens
Copy link
Contributor

@rwjblue Thanks for the pointer! I submitted a PR: emberjs/ember-test-helpers#677

buschtoens added a commit to buschtoens/ember-test-helpers that referenced this pull request Jul 2, 2019
@rwjblue
Copy link
Member

rwjblue commented Jul 3, 2019

#18168 should fix the specific issue that @buschtoens ran into (without necessarily coupling it to an @ember/test-helpers update).

josemarluedke pushed a commit to josemarluedke/ember-decorators that referenced this pull request Aug 12, 2019
emberjs/ember.js#18096

This PR changed how templates get transpiled under the hood.
The export from templates are now factory functions which expect to be
passed the `owner`.
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 this pull request may close these issues.

4 participants