requireDir icon indicating copy to clipboard operation
requireDir copied to clipboard

browserify transform

Open benjamine opened this issue 9 years ago • 4 comments

I use browserify to bundle commonjs modules, browserify does this by detecting calls to require, so it won't work out-of-the-box with requireDir. But this can be done by writing a plugin, aka "browserify transform" specific for require-dir, someone did it here https://www.npmjs.org/package/folderify for the analogous lib "includeFolder". Is there any folderify equivalent for requireDir? any plans on having one?

benjamine avatar Sep 15 '14 23:09 benjamine

Sorry for the delay here, @benjamine!

Great feature request. I don't have much experience with browserify myself, so I probably won't get to this anytime soon, but I would love to support this work if I can.

aseemk avatar Jan 29 '15 00:01 aseemk

This should be mostly easy, just add a "browser" entry on the package.json pointing to a module that export an object with the same API as requireDir, but instead return the requires from an object filled during browserify stage instead of runtime. This last one would be the most difficult part.

piranna avatar Aug 12 '15 09:08 piranna

Is this a feature you're still interested in? I'd take a PR for it if it doesn't add too much surface and is done in a generic way.

yocontra avatar Feb 07 '18 22:02 yocontra

sorry since this I moved away from requireDir and from browserify too, but others might find it useful, since the time I reported this, cross-bundler (browserify/webpack/rollup) standards like what @piranna mentions appeared, so might make this simpler now, and perhaps doable with compatibility for all those bundlers, check https://github.com/defunctzombie/package-browser-field-spec

benjamine avatar Feb 07 '18 23:02 benjamine