-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Missing helpers after latest update #1553
Comments
There are a couple of things that I would like you to try:
and see if it works then. If it doesn't then... then I need additional data to analyze the issue myself.
|
related to #1553 - registering helpers on an instance retrieved via `import`, compiling the template on an instance retrieved via `require` - using `@roundingwellos/babel-plugin-handlebars-inline-precompile` to load plugins inline
I did some testing, with This one seems to work: import * as Handlebars from 'handlebars/runtime'
import hbs from 'handlebars-inline-precompile';
Handlebars.registerHelper('loud', function(text) {
return text.toUpperCase();
});
const template = hbs`{{loud name}}`;
const output = template({name: 'yehuda'}) This one results in the error you decribe: import * as Handlebars from 'handlebars'
import hbs from 'handlebars-inline-precompile';
Handlebars.registerHelper('loud', function(text) {
return text.toUpperCase();
});
const template = hbs`{{loud name}}`;
const output = template({name: 'yehuda'}) The problem with the second example is that the babel-plugin loads Could you check that there is only one version of Handlebars in your dependency tree. There might be a 4.1.2 and a 4.2.0. If |
Thanks for looking into this.. I'll dig in shortly and tell you what I find |
Removing the I don't know that the This ensures that if you Actually after testing and looking at related issues with the angular build that prompted this change #1174 (comment) I believe the correct setting for browser is: "browser": {
".": "./dist/cjs/handlebars.js",
"./runtime": "./dist/cjs/handlebars.runtime.js"
}, While it seems odd that we'd be giving the browser cjs builds, browser is somewhat of a misnomer as this is what we're feeding to browser bundlers. While some users may have been importing built files for angular which solved their problem, it was a wrong solution. They should have been using the cjs builds. |
We should not be using pre-built files for the `browser`. Resolves handlebars-lang#1553
We should not be using pre-built files for the `browser`. Resolves handlebars-lang#1553
We should not be using pre-built files for the `browser`. Resolves #1553
related to #1553 - registering helpers on an instance retrieved via `import`, compiling the template on an instance retrieved via `require` - using `@roundingwellos/babel-plugin-handlebars-inline-precompile` to load plugins inline
@paulfalgout It would still be great to know the exact cause of the problem, so we can add an integration test that tests this issue. |
Is anyone still here? I'm still having this issue with webpack. I import Handlebars in a class like this when I register a helper. Otherwise helper is missing. However, my entry point js uses Handlebar.compile and that only works when I import like this: My distributed js file, however, remains the same size even with the two different imports. |
Before filing issues, please check the following points first:
This will probably help you to get a solution faster.
For bugs, it would be great to have a PR with a failing test-case.
I can try and find a way to reproduce this, but to get it started in case it's somehow obvious. In
4.1.2
everything with the below helpers worked fine. In4.2.0
I get"Missing helper: "far""
... but it only seems to error when I'm instrumenting the code with istanbul.However there are no other changes
npm i handlebars@4.1.2
fixes the issue and@4.2.0
causes it again.The text was updated successfully, but these errors were encountered: