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

Support for ES2015 default exports with Webpack 2 in helpers #115

Open
TomOne opened this issue Nov 7, 2016 · 2 comments
Open

Support for ES2015 default exports with Webpack 2 in helpers #115

TomOne opened this issue Nov 7, 2016 · 2 comments

Comments

@TomOne
Copy link

TomOne commented Nov 7, 2016

If a helper uses ES2015 default exports with Webpack 2 (2.1.0-beta.25), the following setup fails:

.babelrc:

{
    "presets": [
        ["es2015", { "modules": false }]
    ]
}

template.handlebars:

{{my-helper}}

my-helper.js:

export default function () {
  return 'test'
}

Attempting to to provide a context to the imported template results in this error:

import template from './template.handlebars'

template({}) // <-- Error __default(...).call is not a function

However, if the ES2015 default export is replaced by a CommonJS export, everything works fine:

my-helper.js:

module.exports = function () {
  return 'test'
}

It would it be great for handlebars-loader to support ES2015 exports using Webpack 2. Or is this issue caused by Webpack’s loader API?

@mteodori
Copy link

same problem here, thanks @TomOne for the workaround provided

@daslicht
Copy link

daslicht commented Nov 12, 2016

I have the same question, any solution yet , please?

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

No branches or pull requests

3 participants