Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: require URIs #1103

Open
samholmes opened this issue Feb 3, 2015 · 4 comments
Open

Feature: require URIs #1103

samholmes opened this issue Feb 3, 2015 · 4 comments

Comments

@samholmes
Copy link

Wouldn't it be awesome if you could do:

var jquery = require("http://code.jquery.com/jquery-1.11.2.min.js");

and it would just work. That would be awesome!

I could see this as a definite possibility, but is this already a functionality supported by transforms (is there a project that is doing this already?)?

Also, discuss if this is even a good idea.

@guybrush
Copy link
Contributor

i think its a bad idea, also browserify is so flexible you can basically do all the things with it.

if you want to get that feature into your bundle-pipeline just write a transform or plugin.

for example take a look at https://github.com/substack/brfs - just fetch your file instead of reading from disk (like in brfs). then you could use it like that:

var fetch = require('fetch') // your browserify-plugin provides this
var jquery = fetch('http://code.jquery.com/jquery-1.11.2.min.js')

your plugin could even wrap the fetched code so you can make it export only the jquery-object, or you could provide an api like fetch(url,{export:'jquery'}), or you could .. the point is that browserify should be used as a part of your build-pipeline instead of being your whole build-pipeline.

also i think i have even seen such a browserify-plugin on npm, its always worth 5 minutes to look if someone else already solved the problem :)

edit: although with this approach (like brfs) it would put the string into your bundle multiple times if you fetch() it multiple times, you could add some tracking to it in order to point to the same string all the time. or even do some hashing or checksums :D

@junosuarez
Copy link
Contributor

This is proposing a change to how node's require works, which is out of scope of Browserify. Since node require's api is frozen this is not going to happen.

@jmm
Copy link
Collaborator

jmm commented Feb 26, 2015

@jden I don't know how good of an idea the OP's suggestion is, but require() in browserify already isn't node's require().

@goto-bus-stop
Copy link
Member

a plugin that does this would be great! i don't think it'll be good for core browserify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants