GithubHelp home page GithubHelp logo

Comments (11)

ben-ng avatar ben-ng commented on May 22, 2024

Any news on this, or pointers to get me started on a PR? (:

from browserify-deoptimizer.

domenic avatar domenic commented on May 22, 2024

No news really... a PR would be amazing. @thlorenz has some ideas, I know, but I forgot most of them.

The new browserify v2 flow is pretty amenable to this sort of thing, I think, although I'm not 100% sure it exposes the right hooks...

from browserify-deoptimizer.

thlorenz avatar thlorenz commented on May 22, 2024

Technically you could pull the entire source of the bundle along with paths from the source maps. mold-source-map and/or convert-source-map would help you with that.
Then add routes for each to a server and add script tags that pull'em in.

Of course this only works with the --debug option.

The other thing that may help is that browserify now has an option to list all files (last advanced option) that are being bundled.

from browserify-deoptimizer.

ben-ng avatar ben-ng commented on May 22, 2024

Awesome info @thlorenz! That helps a lot. I'll see what I can do. Thanks!

from browserify-deoptimizer.

domenic avatar domenic commented on May 22, 2024

There's also this b.on('file', ...) thing, I've never used it but it seems possibly relevant.

@thlorenz any ideas on where in the process we can hook in? It sounds like source map work would be done after the conversion to a string; is there anywhere earlier in the process that you think would work well? (But the source map idea is pretty compelling I think, since it means the source map-creator has already done most of the work for us.)

from browserify-deoptimizer.

ben-ng avatar ben-ng commented on May 22, 2024

I've been working on this. So far the most reliable option has been through the source map, but I'll try the new advanced option too.

The file and package events won't fire for browserify's special shims, so you get an incomplete tree of files doing that.

from browserify-deoptimizer.

thlorenz avatar thlorenz commented on May 22, 2024

b.on('file'... may work, but I'm not sure how well it plays with transforms, since you'd need to run them manually if you use the original file content. This btw would also be the case with the 'list all files' approach.

The source map approach may be simpler here since the source map will point you to the exact lines in the bundle to find the source code after all the modifications, including transforms.

from browserify-deoptimizer.

domenic avatar domenic commented on May 22, 2024

Of course the next problem is what the output format should be, given browserify v2's new super-compact thing.

Honestly at this point the best idea I have is a bunch of amd modules, plus a massive require.config that uses the browserify data to create per-file mappings. Combine this with almond or something and you'd be good to go.

Hopefully someone has a better idea :P

from browserify-deoptimizer.

ben-ng avatar ben-ng commented on May 22, 2024

Just a small progress update, i've managed to reliably extract a dependency map (correctly, with transforms that add require) from browserify thanks to @thlorenz's info on the advanced option.

from browserify-deoptimizer.

domenic avatar domenic commented on May 22, 2024

This is awesome, I'm really excited :D.

from browserify-deoptimizer.

aldendaniels avatar aldendaniels commented on May 22, 2024

Another possibility:

  1. Use browserify --list to get a list of all files
  2. Create a separate bundle for each file
  3. For each bundle, use browserify's external() option to exclude all other files

This approach has the potential to be faster than using source maps. When used in conjunction with watchify, only the affected single-file bundle would need to be updated when a source file is changed.

Thoughts?

from browserify-deoptimizer.

Related Issues (3)

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.