hughsk / disc

:chart_with_upwards_trend: Visualise the module tree of browserify project bundles and track down bloat.
http://hughsk.io/disc
Other
1.33k stars 83 forks source link

webpack support? #18

Open lencioni opened 10 years ago

lencioni commented 10 years ago

I think this project looks really cool, but I'm using webpack for my bundling, not browserify. I'm wondering if you would be interested in adding webpack support?

http://webpack.github.io/ https://github.com/webpack/webpack

Raynos commented 10 years ago

I floated the idea that it would be cool if disc just consumed the JSON stream output of browserify rather then browserify itself.

That way you can get webpack to output a JSON stream and it just works tm.

hughsk commented 10 years ago

Hey @lencioni, thanks, glad you like the project :)

It was just suggested yesterday we add AMD support too. I'm not likely to implement either of these myself, but if you're keen to see this happen you should send through a pull request and I'll be happy to include it!

@Raynos if I understand correctly that would mean we can't handle any transforms applied after a bundle's been browserified, e.g. getting stats after minification. Perhaps supporting both would be the best approach? Good news is the output is pretty close to what disc expects:

[
  {
    "id": "/Users/hughsk/src/github.com/hughsk/gl-context/node_modules/raf-component/index.js",
    "source": "/**\n * Expose `requestAnimationFrame()`.\n */\n\nexports = module.exports = window.requestAnimationFrame\n  || window.webkitRequestAnimationFrame\n  || window.mozRequestAnimationFrame\n  || window.oRequestAnimationFrame\n  || window.msRequestAnimationFrame\n  || fallback;\n\n/**\n * Fallback implementation.\n */\n\nvar prev = new Date().getTime();\nfunction fallback(fn) {\n  var curr = new Date().getTime();\n  var ms = Math.max(0, 16 - (curr - prev));\n  var req = setTimeout(fn, ms);\n  prev = curr;\n  return req;\n}\n\n/**\n * Cancel.\n */\n\nvar cancel = window.cancelAnimationFrame\n  || window.webkitCancelAnimationFrame\n  || window.mozCancelAnimationFrame\n  || window.oCancelAnimationFrame\n  || window.msCancelAnimationFrame\n  || window.clearTimeout;\n\nexports.cancel = function(id){\n  cancel.call(window, id);\n};\n",
    "deps": { },
    "entry": false
  },
  {
    "id": "/Users/hughsk/src/github.com/hughsk/gl-context/index.js",
    "source": "var raf = require('raf-component')\n\nmodule.exports = createContext\n\nfunction createContext(canvas, opts, render) {\n  if (typeof opts === 'function') {\n    render = opts\n    opts = {}\n  } else {\n    opts = opts || {}\n  }\n\n  var gl = (\n    canvas.getContext('webgl', opts) ||\n    canvas.getContext('webgl-experimental', opts)\n  )\n\n  if (!gl) {\n    throw new Error('Unable to initialize WebGL')\n  }\n\n  if (render) raf(tick)\n\n  return gl\n\n  function tick() {\n    render(gl)\n    raf(tick)\n  }\n}\n",
    "deps": {
      "raf-component": "/Users/hughsk/src/github.com/hughsk/gl-context/node_modules/raf-component/index.js"
    },
    "entry": true,
    "order": 0
  }
]
Raynos commented 10 years ago

@hughsk

Perhaps supporting both would be the best approach

:+1:

cowwoc commented 9 years ago

I'm also interested in webpack support.

kyriacos commented 9 years ago

:+1: for webpack support

landonwilkins commented 9 years ago

it appears thomsbg has hacked together some initial webpack support

https://github.com/thomsbg/disc

idris commented 9 years ago

:+1: is anyone working on this? The @thomsbg fork didn't quite work for me

hawkrives commented 8 years ago

I just found https://chrisbateman.github.io/webpack-visualizer/, which is similar.