Giter Club home page Giter Club logo

Comments (5)

goto-bus-stop avatar goto-bus-stop commented on May 27, 2024 1

Yes, Browserify runs transforms on application code only by default. There are some pointers for solving this use case in the readme here https://github.com/babel/babelify/blob/master/README.md#why-arent-files-in-node_modules-being-transformed and in #268

from babelify.

lambert-velir avatar lambert-velir commented on May 27, 2024 1

As a follow up, it seems that babelify doesn't automatically load .babelrc anymore when you pass options as the 2nd argument to the transform like this:

browserify()
  .transform(babelify, {
    global: true
  });

As a work around, I used the find-babel-config package like this:

const findBabelConfig = require("find-babel-config");

const babelConfig = findBabelConfig.sync(__dirname);

browserify()
  .transform(babelify, {
    ...babelConfig.config,
    global: true
  });

cc: @goto-bus-stop

from babelify.

lambert-velir avatar lambert-velir commented on May 27, 2024

Ahh, global: true does what I want. Thanks for reading the readme for me!

from babelify.

lambert-velir avatar lambert-velir commented on May 27, 2024

One issue I ran into is that global is a babelify option, not a babel option, so global can't go in .babelrc. However, I found that I can do:

browserify()
.transform(babelify, {
  global: true
});

and have the rest of my babel config inside .babelrc

from babelify.

goto-bus-stop avatar goto-bus-stop commented on May 27, 2024

Yeah, this one's quite specific. It's a Browserify option: https://github.com/browserify/browserify#btransformtr-opts, opts.global is documented below the code sample.
Unlike other browserify transform options, it also doesn't work in the package.json browserify.transform key. It can only be used through the b.transform() API.

(Browserify's opinion is that package.json configuration should only apply to the package, not its dependencies or dependents.)

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.