browserify / factor-bundle

factor browser-pack bundles into common shared bundles
Other
402 stars 27 forks source link

Broken command line outpipe #68

Closed ctumolosus closed 7 years ago

ctumolosus commented 9 years ago

According to the command line outpipe example section in the README file I should be able to run this command:

browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglify-js -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js

But I'm getting the following error:

var outputs = defined(outopt, []).map(function (o) {
                                      ^
TypeError: undefined is not a function
    at f (/project/node_modules/factor-bundle/index.js:34:39)
    at Browserify.plugin (/project/node_modules/browserify/index.js:350:9)
    at /project/node_modules/browserify/bin/args.js:102:15
    at Array.forEach (native)
    at module.exports (/project/node_modules/browserify/bin/args.js:97:10)
    at Object.<anonymous> (/project/node_modules/browserify/bin/cmd.js:6:26)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
ghost commented 9 years ago

Try with 2.4.1.

ctumolosus commented 9 years ago

@substack I tried using 2.4.1 and i'm running into a different problem. I'm trying to figure out whether it was caused by something that I missed. I have a feeling that something is treating the value of the --output option as the path of a file to be read.

browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: ENOENT, open 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js'
    at Error (native)

Log in npm-debug.log isn't helping me too much:

0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli   '/user/.nvm/versions/node/v0.12.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build:scripts' ]
2 info using npm@2.7.3
3 info using node@v0.12.0
4 verbose run-script [ 'prebuild:scripts', 'build:scripts', 'postbuild:scripts' ]
5 info prebuild:scripts project@0.1.0
6 info build:scripts project@0.1.0
7 verbose unsafe-perm in lifecycle true
8 info project@0.1.0 Failed to exec build:scripts script
9 verbose stack Error: project@0.1.0 build:scripts: `browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/user/.nvm/versions/node/v0.12.0/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (/user/.nvm/versions/node/v0.12.0/lib/node_modules/npm/lib/utils/spawn.js:14:12)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1008:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
10 verbose pkgid project@0.1.0
11 verbose cwd /user/project
12 error Darwin 13.4.0
13 error argv "node" "/user/.nvm/versions/node/v0.12.0/bin/npm" "run" "build:scripts"
14 error node v0.12.0
15 error npm  v2.7.3
16 error code ELIFECYCLE
17 error project@0.1.0 build:scripts: `browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js`
17 error Exit status 1
18 error Failed at the project@0.1.0 build:scripts script 'browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js'.
18 error This is most likely a problem with the project package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     browserify ./assets/scripts/*.js -p [ factor-bundle -o 'uglifyjs -cm > ./public/scripts/`basename $FILE`.js' ] -o ./public/scripts/common.js
18 error You can get their info via:
18 error     npm owner ls project
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]
paulcpederson commented 9 years ago

+1 in the same boat with both errors.

ghost commented 9 years ago

Do you have uglifyjs and basename in your $PATH? Are you on windows?

paulcpederson commented 9 years ago

both in $PATH I'm on a mac.

I made a simple test repo just as a sanity check thinking it might be something in my setup, but I get the same error. (Same as above). Put the sample on GitHub here: https://github.com/paulcpederson/factor-bundle-test

Been running browserify via an npm script. npm run js to test. Can you spot something I did wrong here?

ctumolosus commented 9 years ago

I have the same setup as @paulcpederson

ctumolosus commented 9 years ago

By the way, I tried with:

npm install substack/factor-bundle#e6c7ceb6c8963bac254c1e4b123c06ac45e99039

and I'm not getting errors.