Open mrosenberg opened 5 years ago
I ran into this as well. In my application these boils down to it looking for -css-blocks-classnames
inside a registry that contains only helpers from my own application. The css blocks ember-cli addon does in fact have this helper, not sure why the registry doesn't contain it.
This helper is only used when there is a dynamic bit, static values are fine.
Fine:
state:selected=true
Errors:
state:selected={{someBool}}
This makes sense given what I saw. I was working on a toy app and have shelved this for the time being though.
Okay @mrosenberg You're not going to like this hack lolol:
// in src/index.ts
// hax until runtime helpers are properly imported in css-blocks for glimmer
import { classnames } from '@css-blocks/glimmer/dist/cjs/src/helpers/classnames';
app.registerInitializer({
initialize(registry) {
registry._resolver.registry._entries[
`helper:/<root-name-of-your-app>/components/-css-blocks-classnames`
] = classnames;
}
});
Then if you want tests to pass:
// create a setupRenderingTest helper in src/utils/test-helpers/setup-rendering-test.ts
import { classnames } from '@css-blocks/glimmer/dist/cjs/src/helpers/classnames';
import { setupRenderingTest as originalSetupRenderingTest } from '@glimmer/test-helpers';
export const setupRenderingTest = function(hooks) {
originalSetupRenderingTest(hooks);
hooks.beforeEach(function beforeEach() {
this.app.registerInitializer({
initialize(registry) {
// tslint:disable-next-line
registry._resolver.registry._entries[
`helper:/glimmer-pdp-viewer/components/-css-blocks-classnames`
] = classnames;
}
});
});
};
This just hacks the resolver to lookup up our runtime helper imported at the top of the file and return it.
Please help @amiller-gh, save me from myself lol (all kidding aside, excellent work you've been doing :beers:)
Oh hello! Sorry, didn't see this pass by! Looking 👀
We might be able to have a quick repro in the mono repo by adding something like state:colllapsed={{true}}
to https://github.com/linkedin/css-blocks/blob/07a44b91d0e7b2291bf6131b02705d258a6b81e9/packages/%40css-blocks/glimmer/test/fixtures/readme-app/src/ui/components/page-layout/template.hbs.
Well I'm having trouble even getting a basic test case to run 😅 Going to have to spend some more time on this later tonight!
The relevant helper import code lives here – and go figure its Ember only! Would love a PR that automates Glimmer helper delivery.
https://github.com/linkedin/css-blocks/blob/master/packages/%40css-blocks/ember-cli/index.js#L134
@amiller-gh I'll give it a try tomorrow. I'm not sure what to register it as though, my solution relies on putting the registration into helper:/glimmer-pdp-viewer/components/-css-blocks-classnames
. and I'm not sure how to get the rootName
of the project at that stage.
That would be amazing 👍 I think the add-on already has code to discover the project rootDir
in getEnv()
. I would't be surprised if we can fetch rootName
from either the app instance (parent
), somewhere in the moduleConfig, or from the package.json in that same method. Would be nice to normalize in getEnv()
across Ember and Glimmer.
I didn't continue my comments here, but I think the correct solution is to rename the -css-blocks-classnames
helper to css-blocks-classnames
so that consuming applciations can re-export it from their own application. Then we could make the blueprint install the re-export.
The crux of the problem is that glimmer applications disallow helpers prefixed with a -
dash.
ember-cli: 3.3.0 node: 8.11.4 os: darwin x64
I have an ember-cli Glimmer app up and running and using the .20.0beta.0 and I'm running into a roadblock when trying to use states. I get this message. It looks like the template engine is looking for a helper that isn't there. Here's the console output.
CSS-Blocks has a lot of moving parts with the Ember-Cli part wrapping the Glimmer part wrapping the Core logic and I'm having trouble figuring out where this is breaking down.
I have a repo here that demonstrates the problem.