Skip to content

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

@jannisg

Description

@jannisg

I'm trying to upgrade my project from [email protected] 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions