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

Solve ts related double setComponentTemplate #1134

Conversation

NullVoxPopuli
Copy link
Collaborator

Depends on: #1126
(Only because my reproduction repos cover both TS and template-only)

Reproduction repo: https://github.com/NullVoxPopuli/ember-addon-v2-typescript-demo/

This PR aims to solve the problem discovered here: #1099
Where prior to the changes in this PR, component output for TS files (using rollup-plugin-ts) included two setComponentTemplate calls, such as:

 cat dist/components/demo/index.js
import { setComponentTemplate } from '@ember/component';
import { hbs } from 'ember-cli-htmlbars';
import { __decorate } from 'tslib';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

var TEMPLATE = setComponentTemplate(TEMPLATE, hbs`Hello there!

<out>{{this.active}}</out>

<button {{on 'click' this.flip}}>
  flip
</button>
`);

class Demo extends Component {
  constructor(...args) {
    super(...args);
    this.active = false;

    this.flip = () => this.active = !this.active;
  }

}

__decorate([tracked], Demo.prototype, "active", void 0);

setComponentTemplate(TEMPLATE, Demo);

export { Demo as default };
//# sourceMappingURL=index.js.map

The line that has:

var TEMPLATE = setComponentTemplate(TEMPLATE, hbs`Hello there!

erroneously has setComponentTemplate doing a self-reference, which wouldn't cause a an error during app boot, but would cause additional boot time for apps (the less to do during boot the bett)

@NullVoxPopuli NullVoxPopuli changed the title Solve ts related double set component template Solve ts related double setComponentTemplate Feb 19, 2022
return code;
}

function getTemplateFactory(hbsPath: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@NullVoxPopuli am I missing something or looks like this does not actually solve the problem with double setComponentTemplate call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. The diff is goofy becauso the upsteam PR that handles template only components hass't been merged

@NullVoxPopuli NullVoxPopuli force-pushed the solve-ts-related-double-setComponentTemplate branch from 64e0733 to 2ecc04c Compare April 10, 2022 17:55
@NullVoxPopuli
Copy link
Collaborator Author

It looks like the latest changes to how co-located templates and template-only components are handled fixed this! yay!

There is another issue I ran in to at runtime about ember-cli-htmlbars not being found -- so I'm going to start with other PR with a failing test for that (if I can get a reproduction figured out)

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.

2 participants