-
Notifications
You must be signed in to change notification settings - Fork 136
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
fix gts in v1 addons #2120
base: stable
Are you sure you want to change the base?
fix gts in v1 addons #2120
Conversation
8cd0ee8
to
0714d84
Compare
This shouldn't be necessary. ember-template-imports pushes a babel plugin, which should mean that |
ah, but that was only merged yesterday :) |
It took me a little while to understand this, because while I think your fix is correct the explanation for it is more subtle. Stage1 will always run custom broccoli preprocessors. So that's enough to convert: import Thing from './thing';
<template><Thing/></template> to import Thing from './thing';
import { template } from '@ember/template-compiler';
export default template("Thing", {
eval: function() { return eval(arguments[0]) } })
}); This is really all we need to do at stage1, since this is now valid Javascript that could appear in a v2 addon. But if the addon is also using TS, we also need to run the typescript transform before it will be valid JS. And if the typescript transform was being truly correct it would not try to delete the import because the Unfortunately the typescript transform is a jerk and will drop the binding anyway, assuming with no evidence that it must have been "type only". Normally we only use babel-plugin-ember-template-compilation in stage1 to run custom AST transforms. Since there are none in the addon, we don't add it. The fix here is helping because there is a new reason to add it. It will further convert the above example to: import Thing from './thing';
import { template } from '@ember/template-compiler';
export default template("Thing", {
scope: () => ({ Thing })
}); which typescript then respects. |
This could really use a test. |
Also, if you can update the comments in the code to align with my explanation above it will help us in the future. |
0714d84
to
3f1ae33
Compare
fixes #2119