minifyify icon indicating copy to clipboard operation
minifyify copied to clipboard

bundle has no method 'transform'

Open reggi opened this issue 10 years ago • 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)

reggi avatar Feb 25 '15 05:02 reggi

what version of browserify?

ben-ng avatar Feb 25 '15 10:02 ben-ng

You should use .plugin, not .transform :)

StevenLangbroek avatar Feb 25 '15 14:02 StevenLangbroek

@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 avatar Feb 25 '15 16:02 reggi

@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.

cdaringe avatar Mar 05 '15 18:03 cdaringe

@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.

aronbirkir avatar Mar 19 '15 11:03 aronbirkir

Thanks @aronbirkir! Very helpful!

reggi avatar Mar 19 '15 13:03 reggi

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

ben-ng avatar Mar 19 '15 19:03 ben-ng

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'] }
            }
        },

thedamon avatar Jul 27 '15 18:07 thedamon

I don't use grunt and haven't seen this error before. Can you post the full stack trace?

ben-ng avatar Jul 27 '15 19:07 ben-ng

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 [email protected] 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 https://github.com/ben-ng/minifyify/issues/82#issuecomment-125325865.

thedamon avatar Jul 29 '15 14:07 thedamon

@thedamon I'm fairly certain that the browserify grunt plugin requires you to pass a list of tuples to plugin, i.e.

plugin: [
  ['minifyify', [{
    ...opts...
  }]] 
]

instead of

plugin: [
  'minifyify', [{
    ...opts...
  }] 
]

hnovikov avatar Aug 12 '15 19:08 hnovikov