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.

Does not work at all

See original GitHub issue

Excuse me, I’m totally stuck.

That’s my main.jsx, it has to be converted to main.min.js:

import React, { Component } from "react";
import ReactDOM from "react-dom";
ReactDOM.render(<div>lala</div>,document.getElementById("root"));

That’s my build.js script:

var fs = require("fs");
var browserify = require("browserify");
browserify("./main.jsx")
  .transform("babelify",{
    presets: ["react","es2015","babili"]
  })
  .bundle()
  .pipe(fs.createWriteStream("./main.min.js"));

These are my package.json dependencies:

"babel-minify": "^0.1.12",
"babel-plugin-uglify": "^1.0.2",
"babel-preset-babili": "0.0.4",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babelify": "^7.3.0",
"bootstrap-sass": "^3.3.7",
"browserify": "^13.1.0",
"classnames": "^2.2.5",
"extend": "^3.0.0",
"mobx": "^2.5.2",
"mobx-react": "^3.5.7",
"mobx-react-devtools": "^4.2.6",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"uglify": "^0.1.5"

The result is main.min.jsx with filesize ~ 730KB. If I cut off babili from presets, the result is the same.

What do I do wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
boopathicommented, Oct 31, 2016

For those who are using babili with webpack, you can try babili-webpack-plugin.

  • A webpack loader operates on single files and babili preset as a webpack loader is going to consider each file to be executed directly in the browser global scope (by default) and will not optimize some things in the toplevel scope. This is going to change and you can opt-in to optimize toplevel scope - #210, #203, …
  • When you exclude node_modules from being run through the babel-loader, babili optimizations are not applied to the excluded files as it doesn’t pass through the minifier.
  • When you use the babel-loader with webpack, the code generated by webpack for the module system doesn’t go through the loader and is not optimized by babili.
  • A webpack plugin can operate on the entire chunk/bundle output and can optimize the whole bundle and you can see some differences in minified output. But this will be a lot slower as the file size is usually really huge. So there is another idea where we can apply some optimizations as a part of the loader and some optimizations in a plugin (for webpack). For that, there is some more work that is done on babili’s side (#162).

Comments

Also, one more thing to note is that by default the preset doesn’t remove comments. So in your babelrc or babel config that you use for babili, you can set comments to false.

{
  presets: ["babili"],
  comments: false
}

I’ve not tried babili with browserify yet, so I can’t comment much there.

3reactions
davidgilbertsoncommented, Jan 2, 2017

I was getting poor results too because it was only doing a per-file minification. The webpack edition matched the size of UglifyJS (thanks @boopathi)

Chart for the curious.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

not work at all - English translation - Linguee
Many translated example sentences containing "not work at all" – English-Spanish dictionary and search engine for English translations.
Read more >
no work at all | English examples in context - Ludwig
High quality example sentences with “no work at all” in context from reliable sources - Ludwig is the linguistic search engine that helps...
Read more >
Is there any difference between "it's not working" and "it doesn ...
"It doesn't work" means that something is permanently broken, or is never effective. Here are some example situations: Your television is broken. A...
Read more >
How do I understand "It doesn't work all the time"?
It would be more idiomatic to say 'It doesn't work at any time', but in either case the meaning would be 'It never...
Read more >
Is there something wrong if you are not working? - Quora
No, there is nothing wrong with you. No one wants to work. That's why companies have to pay people to do all of...
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