Comments (5)
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.
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.
Ahh, global: true
does what I want. Thanks for reading the readme for me!
from babelify.
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.
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)
- Babel 7 Stable Released HOT 8
- Bundling hyperhtml-element with browserify/babelify not working
- TypeError: extensions.indexOf is not a function
- TypeError: Cannot read property 'canCompile' of undefined HOT 5
- How to get babelify && preset-env to convert 'const' HOT 3
- Boolean options fail (e.g. --compact true) HOT 1
- usage of babel/polyfills HOT 4
- Not working "Why aren't files in node_modules being transformed?" HOT 14
- Use a Bundler for Development? HOT 1
- tsify + babelify + browserify with threejs modules: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (9:0) HOT 17
- Is it possible to disable asyncToGenerator? HOT 2
- TypeError: Cannot read property 'arrayify' of undefined HOT 2
- Is this incompatible with Babel 7? HOT 3
- If I don't specify any Babel plugins or presets, what exactly should happen? HOT 6
- Continued problems with issue #103 ('import' and 'export' may appear only with 'sourceType: module') HOT 4
- How to use with globally installed browserify? HOT 1
- No source being transformed HOT 1
- babelify + gulp with threejs modules: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (9:0)
- 'import' and 'export' may appear only with 'sourceType: module' (14:0)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babelify.