Code Monkey home page Code Monkey logo

Comments (3)

Jimbly avatar Jimbly commented on May 18, 2024 3

I was having this issue as well, and since Google results for "browserify babel node_modules" comes to this issue, and lots of other issues link here, I'm updating it with details on the other solution (using a global transform), which seems to work better than trying to ask every single modern module I require to add something to their package.json.

After figuring this out through other means, I see it's actually in the FAQ for babelify, so I'm quoting that section here:

Another solution (proceed with caution!) is to run babelify as a global transform. Use the babel ignore option to narrow the number of files transformed:

browserify().transform("babelify", {
  global: true,
  ignore: /\/node_modules\/(?!app\/)/
});

The above example will result in a transform that also includes the app module in node_modules: the global flag transform all files, and the ignore regular expression then excludes all those in the node_modules directory except those that are in node_modules/app (since ?! will match if the given suffix is absent).

In my use, I find the ignore is not required, as for every module that exports ES5 code, babelify is effectively a no-op, and for those that are not, I want it to run them though babelify. Seems safer to opt-out of babelify if it breaks a particular module (which will be noticed in development) rather than need to opt-in (which will only be noticed in production/testing on old browsers).

from babelify.

ecurtis avatar ecurtis commented on May 18, 2024

I am having the same issue.

from babelify.

sebmck avatar sebmck commented on May 18, 2024

This is built-in browserify behaviour and can not be overridden, an alternative is to add:

{
  "browserify": {
    "transform": ["babelify"]
  }
}

to your node_modules package.json.

In the future please search the issues before creating a new one, thanks! See #44 and #38.

from babelify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.