Closed mandarinx closed 9 years ago
It is supposed to. But, 7.0.1 introduced some wacky behavior with transforms, e.g. https://github.com/substack/node-browserify/issues/1032 so it's possible this is a browserify problem. Does your config with with browserify 7.0.0?
I tried 7.0.1, 7.0.0, 6.3.4, 6.0.0 and 5.0.0, and they all gave this error:
/root/node_modules/browserify/node_modules/module-deps/index.js:498
if (typeof tr.read === 'function') return tr;
^
TypeError: Cannot read property 'read' of undefined
at wrapTransform (/root/node_modules/browserify/node_modules/module-deps/index.js:498:18)
at makeTransform (/root/node_modules/browserify/node_modules/module-deps/index.js:232:32)
at /Users/mandarin/root/node_modules/browserify/node_modules/module-deps/index.js:205:9
at Deps.getTransforms (/root/node_modules/browserify/node_modules/module-deps/index.js:210:7)
at /root/node_modules/browserify/node_modules/module-deps/index.js:328:24
at onresolve (/root/node_modules/browserify/node_modules/module-deps/index.js:157:14)
at /root/node_modules/browserify/node_modules/module-deps/index.js:152:17
at onpkg (/root/node_modules/browserify/node_modules/module-deps/index.js:453:27)
at fns (/root/node_modules/browserify/node_modules/module-deps/index.js:443:13)
at fs.js:271:14
I also tried passing require('remapify')
to b.transform()
instead of the remapify variable, but to no avail.
It seems to me there's something wrong with how I use remapify since it didn't work with any of the major versions.
Yup, not a browserify problem. Can you try making your cwd
an absolute path?
I've tried all kinds of combinations, like putting the absolute path in b.add(), cwd, src and expose. I've tried leaving out properties, adding leading and trailing slashes to the paths and change the glob pattern. And I've tried them all with browserify 7.0.0 and 7.0.2.
Could it have something to do with the OS or Node.js? I'm using Node 0.10.33 and OS X 10.10.1.
remapify is a plugin, not a transform. Use b.plugin()
:
b.plugin(remapify, [{
cwd: './src',
src: '**/*.js',
expose: ''
}])
That said, it looks like remapify needs to be updated to work with the new transform pipeline changes in v7 since it internally issues a .transform() after other parts of the pipeline have already executed.
Thanks @substack! You're totally right, it needs to be .plugin
.
I'll take a look at the transform pipeline changes. Cheers.
Ah! Thanks for clearing it up. I got it working by using .plugin
and switching to Browserify 6.0.0.
Here's the file I'm testing with:
I'm using like this:
node browserify.js > test.js
And this is the error message I keep getting (I replaced the full project path with 'root' to make the dirs shorter):
I'm using browserify 7.0.2 and remapify 1.3.0.
Is this supposed to work or am I doing something wrong?