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

Webpack "Module parse failed" import error due to babelHelpers' extends method #7

Closed
jannisg opened this Issue Mar 30, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@jannisg
Contributor

jannisg commented Mar 30, 2017

I'm trying to upgrade my project from preact-cycle@0.4.1 to 0.5.0 but as of right now my Webpack 1.13 is throwing an error when trying to do:

import { h, render } from 'preact-cycle';

I've diffed the generated dist/preact-cycle.js file between versions (0.4.1 vs 0.5.0) and have found the issue being with the use of the extends function which in 0.4.1 was done via:

function createCycle(renderer) {
        function render() {
            return clearTimeout(debounce), debounce = null, renderer(babelHelpers["extends"]({
                mutate: mutate,
                mutation: mutation
            }, data));
        }
...

but in 0.5.0 the generated code looks like this:

function createCycle(renderer) {
        function render() {
            return clearTimeout(debounce), debounce = null, renderer(extends({
                mutate: mutate,
                mutation: mutation
            }, data));
        }
...

Note that in 0.5.0 the extends is used as a function directly whereas 0.4.1 is calling it from within the babelHelpers object.

The issue with the more recent version seems to be that the definition of the

var extends = (function() { ...

is below the code being executed and when webpack is parsing the file during the import phase it seems to freak out when it hits this function call.

I've been trying to work out how this has happened/changed but I can't explain it since neither package.json nor .babelrc in the preact-cycle project seems to have changed since the bump to 0.5.0.

Any ideas?

@jannisg

This comment has been minimized.

Show comment
Hide comment
@jannisg

jannisg Mar 30, 2017

Contributor

For the time being I can work around this issue by using a webpack alias to the minified file:

resolve: {
  alias: {
    'preact-cycle': __dirname + '/node_modules/preact-cycle/dist/preact-cycle.min.js',
  }
}

which works fine for now.

Contributor

jannisg commented Mar 30, 2017

For the time being I can work around this issue by using a webpack alias to the minified file:

resolve: {
  alias: {
    'preact-cycle': __dirname + '/node_modules/preact-cycle/dist/preact-cycle.min.js',
  }
}

which works fine for now.

@developit

This comment has been minimized.

Show comment
Hide comment
@developit

developit Apr 3, 2017

Owner

Looks like regenerator got turned on by accident.

Owner

developit commented Apr 3, 2017

Looks like regenerator got turned on by accident.

@developit developit closed this in 2733672 Apr 3, 2017

@developit

This comment has been minimized.

Show comment
Hide comment
@developit

developit Apr 3, 2017

Owner

Fixed and released in 0.5.1! :)

Owner

developit commented Apr 3, 2017

Fixed and released in 0.5.1! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment