Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown argument: uglify #4820

Closed
borekb opened this issue Apr 3, 2018 · 29 comments · Fixed by #7215
Closed

Unknown argument: uglify #4820

borekb opened this issue Apr 3, 2018 · 29 comments · Fixed by #7215
Assignees
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@borekb
Copy link
Contributor

borekb commented Apr 3, 2018

PR #4755 introduced a --no-uglify flag but it doesn't work for me when invoked from an npm script or via npx:

$ npx gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                       
  --verbose       Turn on verbose output                                          
  --no-color      Turn off the color in output                                    
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).
  --no-uglify     Build site without uglifying JS bundles (for debugging).        
  -v, --version   Show version number                                             

Unknown argument: uglify

As a workaround, it is possible to do

$ npx gatsby build --noUglify

or

{
  "scripts": {
    "build": "gatsby build --noUglify"
  }
}

Note: I previously made it sound like the CLI parsing is incorrect but doing $ gatsby build --no-uglify (using global gatsby-cli) works correctly. Sorry!

@KyleAMathews
Copy link
Contributor

Hmmm I tested it locally without this problem. Wonder why I'm not seeing a problem.

@borekb
Copy link
Contributor Author

borekb commented Apr 3, 2018

I just reproduced on another PC (both are Windows machines if that matters). gatsby@1.9.244

@KyleAMathews
Copy link
Contributor

Hmmm well, I guess we should rename it then. camelCase on command line args offends some aesthetic sense of mine. How about instead we do --disable-uglify? You want to make a PR for this?

@KyleAMathews
Copy link
Contributor

Weird this only shows up on windows.

/cc @tsriram

@borekb
Copy link
Contributor Author

borekb commented Apr 3, 2018

I think the way to handle this is to specify uglify parameter in yargs which will then parse --no-uglify as uglify: false. I'm not 100% sure though. Might try to do a PR but not sooner than this weekend I'm afraid.

@tsriram
Copy link
Contributor

tsriram commented Apr 4, 2018

Yeah, I think --disable-uglify is better and if at all someone wants to use yargs' boolean negation feature, they can use it like --no-disable-uglify. Guess we'll also need to change the --no-color command to --disable-color. I'll put up a quick PR in a while - @borekb hope you don't mind 😄

@tsriram
Copy link
Contributor

tsriram commented Apr 4, 2018

Well, even if I change it to --disable-uglify, --no-disable-uglify doesn't seem to negate it 🤷‍♂️
Anyway, disable sounds better to me than no

@borekb
Copy link
Contributor Author

borekb commented Apr 4, 2018

I actually think that --no- is sort of a standard convention, used by yarn, git, node and others. I'm not saying that it's possible to add --no- to any boolean flag so maybe this yargs feature should be disabled in Gatsby but --no-uglify feels better than --disable-uglify to me.

@cricrio
Copy link
Contributor

cricrio commented Apr 8, 2018

I disabled the boolean negation feature of yargs in #3755 when I work on the no-color flag. It's strange that this problem happened.

@KyleAMathews
Copy link
Contributor

What's weird also is it only seems to happen on windows — I can't reproduce the problem on my mac.

@cricrio
Copy link
Contributor

cricrio commented Apr 8, 2018

Same on linux. I can't reproduce it. The boolean negation is disabled in the package.json. It's possible to disable it at the creation of the parser. https://github.com/yargs/yargs-parser#configuration.
Maybe it will fix this problem.

@KyleAMathews
Copy link
Contributor

Hmm why don't we tackle the actual problem then — @borekb could you file an issue with yargs to try to figure out why --no-uglify isn't working?

@borekb
Copy link
Contributor Author

borekb commented Apr 8, 2018

Agree that if it's indeed an upstream bug, it should be reported there. However, I'm not sure it is (feels quite weird that string parsing should be OS-dependent). I need to find some time to build a repro for the yargs issue, and generally to look more deeply into what's going on in Gatsby. So if you don't mind leaving this issue open for a little longer, I think I should be able to get to it in about a week or two.

@KyleAMathews
Copy link
Contributor

@borekb could you try @cricrio's suggestion locally as well to see if it fixes the problem?

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

@KyleAMathews I'm stuck at step four (yarn test) of https://github.com/gatsbyjs/gatsby/blob/master/CONTRIBUTING.md#contributing-to-the-repo, a lot of tests are failing. Will try again later.

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

I cannot get the dev setup working on my Windows machine, are there any Gatsby devs on Windows who could advise? Or is there a better place (chat?) to ask?

But I can say that --no-color works for me while --no-uglify doesn't. Strange.

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

One difference is that --no-color uses global: true while --no-uglify doesn't. Not sure if that's significant.

}).option(`no-uglify`, {

@pieh
Copy link
Contributor

pieh commented Apr 10, 2018

I tried this on windows and gatsby build --no-uglify works fine for me - this seems unrelated to this feature but probably something in your system but not sure what that could be

@pieh
Copy link
Contributor

pieh commented Apr 10, 2018

Not sure if this could be the problem but try these commands:

npm list gatsby-cli
npm list -g gatsby-cli

maybe one of these packages is not up to date

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

Oh I just realized something – thanks, @pieh! An important detail in the OP, and also my miscommunication (sorry!) is that I'm actually running gatsby build from a package.json so Gatsby used is local. That probably makes a difference. These are exactly the things I can do, now:

$ npx gatsby --version
1.9.244

$ npx gatsby build --noUglify
# ... build output here ...
# it correctly builds which means that the `noUglify` parameter is understood

$ npx gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                                         [boolean]
  --verbose       Turn on verbose output                                           [boolean] [default: false]
  --no-color      Turn off the color in output                                     [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config). [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).         [boolean] [default: false]
  -v, --version   Show version number                                                               [boolean]

Unknown argument: uglify

$ yarn run build
yarn run v1.5.1
$ gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                                         [boolean]
  --verbose       Turn on verbose output                                           [boolean] [default: false]
  --no-color      Turn off the color in output                                     [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config). [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).         [boolean] [default: false]
  -v, --version   Show version number                                                               [boolean]

Unknown argument: uglify

Note how --noUglify works but --no-uglify doesn't so it's still likely a Gatsby issue, I would think.

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

How do I tell in which version (and of which packages) shipped a particular PR? I'd like to check in which versions of gatsby (or gatsby-cli?) shipped #4755.

@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

(I've updated the OP to specifically mention the local Gatsby dependency.)

@pieh
Copy link
Contributor

pieh commented Apr 10, 2018

@borekb you can check merge commit and see tags on github - it was added in gatsby@1.9.244 and gatsby-cli@1.1.50

borekb added a commit to borekb/gatsby-issue-4820-demo that referenced this issue Apr 10, 2018
@borekb
Copy link
Contributor Author

borekb commented Apr 10, 2018

Here is a repo with repro: https://github.com/borekb/gatsby-issue-4820-demo

@KyleAMathews
Copy link
Contributor

Yeah, this looks like a yargs bug — could you file an issue upstream and try to get it fixed there?

@borekb
Copy link
Contributor Author

borekb commented Apr 11, 2018

@cricrio Does this look like a yargs but to you or a Gatsby misconfiguration?

@m-allanson m-allanson removed the review label Apr 13, 2018
@m-allanson
Copy link
Contributor

A PR updating yargs by a couple of major versions was just merged. Maybe we can re-check this once a new version of gatsby-cli has been published.

@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label Apr 25, 2018
@thekevinbrown
Copy link
Contributor

I'm able to reproduce this on my mac if that helps:

$ yarn build
yarn run v1.6.0
$ gatsby build --no-uglify
gatsby build

Build a Gatsby project.

Options:
  --verbose       Turn on verbose output                                                        [boolean] [default: false]
  --no-color      Turn off the color in output                                                  [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).              [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).                      [boolean] [default: false]
  -h, --help      Show help                                                                                      [boolean]
  -v, --version   Show version number                                                                            [boolean]

Unknown argument: uglify

Does the same thing when run by NPM:

$ npm run build

> <project name>@0.1.0 build <project directory>
> gatsby build --no-uglify

gatsby build

Build a Gatsby project.

Options:
  --verbose       Turn on verbose output                                                        [boolean] [default: false]
  --no-color      Turn off the color in output                                                  [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).              [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).                      [boolean] [default: false]
  -h, --help      Show help                                                                                      [boolean]
  -v, --version   Show version number                                                                            [boolean]

Unknown argument: uglify
npm ERR! code ELIFECYCLE
npm ERR! errno 1

<...etc>

If there's any info I can give you guys about my setup I'm happy to.

@tryzniak
Copy link
Contributor

While working on #7187, I ran into the same issue, yarn build --no-uglify, yarn build --no-color don't work for me. My setup:

 System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
    Yarn: 1.7.0 - ~/.yarn/bin/yarn
    npm: 6.3.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
  Browsers:
    Chrome: 68.0.3440.106
    Firefox: 61.0.1
    Safari: 11.1.2
  npmPackages:
    gatsby: next => 2.0.0-beta.93 
    gatsby-image: next => 2.0.0-beta.7 
    gatsby-plugin-catch-links: next => 2.0.2-beta.7 
    gatsby-plugin-glamor: next => 2.0.0-beta.3 
    gatsby-plugin-sharp: next => 2.0.0-beta.7 
    gatsby-plugin-typography: ^1.7.18 => 1.7.19 
    gatsby-remark-autolink-headers: next => 2.0.0-beta.5 
    gatsby-remark-copy-linked-files: next => 2.0.0-beta.3 
    gatsby-remark-images: next => 2.0.1-beta.10 
    gatsby-remark-katex: next => 2.0.0-beta.3 
    gatsby-remark-prismjs: next => 3.0.0-beta.5 
    gatsby-remark-responsive-iframe: next => 2.0.0-beta.3 
    gatsby-remark-smartypants: next => 2.0.0-beta.3 
    gatsby-source-filesystem: next => 2.0.1-beta.10 
    gatsby-transformer-remark: next => 2.1.1-beta.6 
    gatsby-transformer-sharp: next => 2.1.1-beta.6 
    gatsby-transformer-yaml: next => 2.1.1-beta.3 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants