question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add browserify in package.json for ES6

See original GitHub issue

Now that with v3.x my app is breaking since it’s browserify + babelify configuration doesn’t transform node_modules by default.

See https://github.com/babel/babelify#faq for background.

Suggestion is to add this in your package.json

{
  "browserify": {
    "transform": [["babelify", { "presets": ["@babel/preset-env"] }]]
  }
}

This will ensure that any app using async and building it with browserify + babelify gets transpiled correctly.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
aearlycommented, Aug 1, 2019

I’m considering removing the browserify-specific config. I didn’t like doing it in the first place.

1reaction
nappycommented, Feb 21, 2020

What are you thinking? Why do I need to add “babelify” “@babel/core” and “@babel/preset-env” to my project. I do not want to use babel. I just want to bundle my dependencies.

Even if I would use a transpiler, this whole concept does not work with devDependencies. Why should every library provide its own rollup/webpack/browserify config and then require downstream to include their dev dependencies manually?

Also now that I am doing that, I am not able to change the configuration. For example how am I supposed to manage polyfills (regenerator-runtime in this case), if I cannot even change the @babel/preset-env configuration (for example to “usage”), or the target?

This is madness. I will just stick with v2. Thanks. Babelify my ass. (humour)

A more resonable approach would be to target a specific node version, and if you want to use newer features in your source, then transpile it yourself prior to publishing to npm, or just leave them in and leave it to downstream how they want to transpile it for their environment as necessary.

This approach (sorry if I repeat mysdelf) is complete nonsense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve your client-side-javascript workflow more by using ES6
So add the following attribute to your package.json: ... To call babel from browserify we're going to use the babelify browserify transform ...
Read more >
How should I transform ES6 node_modules with browserify ...
In short, the two possibilities are: Add a browserify option to the affected node_module's package.json; Configure gulp, so that browserify tries to transform ......
Read more >
Compile and Bundle Javascript es6 with Browserify ...
I used gulp-babel to compile ES6 to ES5. The problem is that require is not defined in the browser and in the ES5...
Read more >
Quickly Setting up an ES6 Project with Browserify, Babel & ...
npm i -D browserify babelify watchify serve ... Add these into package.json so Browserify will use Babel transform in a specified stage.
Read more >
Browserify
Bundle up your first module ... Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found