Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use browserify without bundling?

I have quite a few co-workers and friends with existing brownfield, messy javascript applications who would like to start transitioning to some sort of js module system. I've tried to help them out in the past by showing them how to refactor to requirejs but I'm starting to think that is a bad approach.

The problem is usually that the nature of their globals-all-over-the-place code conflicts with the asynchronous nature of AMD, and as much as I believe in the AMD approach, they have bigger concerns than my lectures on the "proper" way to do module loading.

Browserify in the meantime removes the async consideration and is more straightforward but adds in a whole build step. For people who are not using bundling or any sort of a build process (or just the default one in visual studio) this is again, too much overhead.

So what I really want is a simple module system that allows people to define and require things. This is a half-step toward getting things working properly, they can include their dependencies with regular script tags and define them into the module system manually. I even wrote such a system because...hey, that's really easy.

Today someone pointed out to me that it should be possible to actually use just the client-side pieces of Browserify to achieve this. I agree. However, I can't really find any documentation anywhere nor just the Browserify client-side stuff in isolation.

like image 690
George Mauer Avatar asked Jul 18 '14 20:07

George Mauer


1 Answers

After sitting down and dissecting a built browserify file I've concluded that no, what I want to do is not possible.

For one thing browserify doesn't seem to expose a define or even a require keyword. For another, it does some minor rewriting of the combined modules which would be very difficult to achieve during runtime.

like image 116
George Mauer Avatar answered Sep 28 '22 07:09

George Mauer