requireDir
requireDir copied to clipboard
browserify transform
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?
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.
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.
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.
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