-
Notifications
You must be signed in to change notification settings - Fork 26
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
[FEATURE] Ember/Glimmer interop #58
Conversation
084ef34
to
937446b
Compare
packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/output.js
Outdated
Show resolved
Hide resolved
const precompileTemplate = (templateString, templateTokens, options) => { | ||
let compiled = templateCompiler.precompile(templateString, options); | ||
|
||
return `Ember.HTMLBars.template(${compiled})`; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leverage ember-cli-htmlbars here? We know the host will already have it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you mean exactly? Instead of loading the template compiler here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the template compiler loading is "tricky". The current implementation will not support the app having AST tranforms (e.g. for {{t
/{{t-def
, et al) because it doesn't load plugins.
This is fine for now, but I'd like to add an API to ember-cli-htmlbars that we can just use directly.
51b6d85
to
6305589
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM. Super happy we can finally have some form of interop between glimmerjs and ember
@@ -1 +1,3 @@ | |||
export { service } from './src/decorator'; | |||
|
|||
export default class Service {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan to add more things here? or is this class needed to match the default export from @ember/service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class is just needed to match the default export for the time being. We can consider adding more in the future, but for now an empty class is probably fine, don't want to commit to more API space before we think it through.
6305589
to
fddad85
Compare
This PR adds basic Ember/Glimmer interop for GlimmerX. This allows users to write libraries and components using GlimmerX in both frameworks. It works by providing alternative implementations for each package, one for standard Glimmer/TS/Webpack builds, one for Ember builds. Eventually the goal is to unify these as much as possible, but for now this unlocks experimentation and cross-compatiblity. Changes include: - Babel plugin has been updated to include an `ember` option and the ability to pass a custom `precompileTemplate` function, for the Ember side to use. - Most Glimmer imports have been replaced with no-ops (like `on` and `fn`). Ember templates and components still rely on resolution, so these "just work" anyways. - User "imports" will continue to work in Ember, as long as the files are exported in the correct place, since Ember still relies on resolution and doesn't have true imports. - Services work, and an empty base `Service` class has been added so that users can import and extend it, like they would in Ember. In the Ember side, services need to be exported from the `/services` folder like normal. In the Glimmer side, they need to be instantiated and passed to `renderComponent`. The PR also adds smoke tests for the new functionality, to make sure we don't accidentally break it.
fddad85
to
62e46f0
Compare
This PR adds basic Ember/Glimmer interop for GlimmerX. This allows users
to write libraries and components using GlimmerX in both frameworks. It
works by providing alternative implementations for each package, one for
standard Glimmer/TS/Webpack builds, one for Ember builds. Eventually the
goal is to unify these as much as possible, but for now this unlocks
experimentation and cross-compatiblity.
Changes include:
ember
option and theability to pass a custom
precompileTemplate
function, for the Emberside to use.
on
andfn
). Ember templates and components still rely on resolution, sothese "just work" anyways.
are exported in the correct place, since Ember still relies on
resolution and doesn't have true imports.
Service
class has been added sothat users can import and extend it, like they would in Ember. In the
Ember side, services need to be exported from the
/services
folderlike normal. In the Glimmer side, they need to be instantiated and
passed to
renderComponent
.The PR also adds smoke tests for the new functionality, to make sure we
don't accidentally break it.