Skip to content

Babel on node_modules folder fails when libraries have custom .babelrc #158

@ethanroday

Description

@ethanroday

Steps to reproduce (on latest master):

  1. Run preact create <app-name>
  2. cd <app-name>
  3. npm install --save redux preact-redux
  4. In app.js, initialize a store and hook it up with a <Provider> component
  5. npm run build

Expected result:

The build will succeed.

Actual result:

The build fails, since node_modules/preact-redux has a .babelrc file, which references the transform-node-env-inline plugin. Since #117, ES6 code under node_modules gets run through Babel. Babel picks up the .babelrc file in node_modules/preact-redux and fails, since the transform-node-env-inline dependency is not installed.
Installing the plugin (as well as the react and es2015 presets) fixes the problem, but I certainly don't think the expected behavior should be for the build process to npm i in every library folder that contains ES6 code (especially because most of them, preact-redux included, already ship with a precompiled ES5 version). Then again, you can't just assume that the CLI's Babel config will be sufficient for any given library that doesn't ship with ES5 code.
@prateekbh, thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions