bundle has no method 'transform'
reggi opened this issue · 11 comments
thomas@workstation:holstee-browserify$ DEBUG=* browserify main.js > bundle.js
/Users/thomas/Desktop/holstee-browserify/node_modules/minifyify/lib/index.js:26
bundle.transform({global: true}, minifier.transformer);
^
TypeError: Object /Users/thomas/Desktop/holstee-browserify/main.js has no method 'transform'
at plugin (/Users/thomas/Desktop/holstee-browserify/node_modules/minifyify/lib/index.js:26:10)
at nr (/Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/module-deps/index.js:281:23)
at /Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/resolve/lib/async.js:44:21
at ondir (/Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/resolve/lib/async.js:187:31)
at /Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/resolve/lib/async.js:159:43
at onex (/Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/resolve/lib/async.js:93:22)
at /Users/thomas/.nvm/v0.10.32/lib/node_modules/browserify/node_modules/resolve/lib/async.js:24:18
at Object.oncomplete (fs.js:107:15)
what version of browserify?
You should use .plugin, not .transform :)
@ben-ng 9.0.3
@StevenLangbroek I should be using plugin? I just added minifyify to my package.json under transforms, is that not right?
@reggi, i just installed it as part of my dev dependencies, then use it as a plugin. Shouldn't need to load it under transforms, no.
@reggi I got the same if I used the minifyify as a transform option like
browserify app.js -t minifyify
So instead of trying to use it as a transform ( because I just replaced the uglifyify transform as first try ) but as a plugin it should be used like this:
browserify app.js -p [ minifyify --output bundle.map.json ] > bundle.min.js
Just as shown under the Usage section at the https://www.npmjs.com/package/minifyify
I am sure you already figured this out. But might be helpful for others.
Thanks @aronbirkir! Very helpful!
If someone can think of a way to detect when the plugin is incorrectly used as a transform, we can display a more useful error before browserify poops out
I am using it as a plugin (with grunt) and getting Cannot find module '[object Object]' from '...' Use --force to continue.
. does my setup look correct? Browserify runs fine without the plugin..
browserify : {
options: {
transform: ['debowerify'],
plugin: [
'minifyify', [{
map: '<%= config.app %>/scripts/main.map.json'
}]
]
// debug: true
},
server : {
files : { '<%= config.app %>/scripts/main.js' : ['<%= config.app %>/scripts/modules/index.js'] }
},
dist : {
files : { '<%= config.dist %>/scripts/main.js' : ['<%= config.app %>/scripts/modules/index.js'] }
}
},
I don't use grunt and haven't seen this error before. Can you post the full stack trace?
I'm fairly certain I'm including it in my gruntfile correctly..
Warning: Cannot find module '[object Object]' from 'mysite' Use --force to
continue.
Error: Cannot find module '[object Object]' from 'mysite'
at Function.module.exports as sync
at Browserify.plugin
(mysite/node_modules/grunt-browserify/node_modules/browserify/index.js:351:29)
at mysite/node_modules/grunt-browserify/lib/runner.js:116:13
at arrayEach
(mysite/node_modules/grunt-browserify/node_modules/lodash/index.js:1289:13)
at Function.
(mysite/node_modules/grunt-browserify/node_modules/lodash/index.js:3345:13)
at GruntBrowserifyRunner._.create.run
(mysite/node_modules/grunt-browserify/lib/runner.js:111:9)
at Function.Task.runTask
(mysite/node_modules/grunt-browserify/tasks/browserify.js:41:10)
at mysite/node_modules/grunt-browserify/tasks/browserify.js:26:12
at
mysite/node_modules/grunt-browserify/node_modules/async/lib/async.js:122:13
at _each
(mysite/node_modules/grunt-browserify/node_modules/async/lib/async.js:46:13)
On Mon, Jul 27, 2015 at 15:56 Ben notifications@github.com wrote:
I don't use grunt and haven't seen this error before. Can you post the
full stack trace?—
Reply to this email directly or view it on GitHub
#82 (comment).