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

Minification with source maps fails with current Uglify-JS #59

Closed
PatTheMav opened this issue Jun 2, 2017 · 7 comments
Closed

Minification with source maps fails with current Uglify-JS #59

PatTheMav opened this issue Jun 2, 2017 · 7 comments

Comments

@PatTheMav
Copy link

Apparently Uglify-JS 2 has changed their command line scheme for source map creation - it breaks with the current version of Minify:

error: uglifyjs test.js -o test.min.js -m -c --source-map test.min.js.map --source-map-url test.min.js.map --source-map-root ./ -p relative

Supported options:
{ content: null,
  filename: null,
  includeSources: false,
  root: null,
  url: null }
ERROR: `test.min.js.map` is not a supported option
    at DefaultsError.get (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:86:23)
    at fatal (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:286:52)
    at run (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:241:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:171:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)

Here's the associated part of the uglify-js documentation:

    --source-map [options]      Enable source map/specify source map options:
                                `base`  Path to compute relative paths from input files.
                                `content`  Input source map, useful if you're compressing
                                           JS that was generated from some other original
                                           code. Specify "inline" if the source map is
                                           included within the sources.
                                `filename`  Name and/or location of the output source.
                                `includeSources`  Pass this flag if you want to include
                                                  the content of source files in the
                                                  source map as sourcesContent property.
                                `root`  Path to the original source to be included in
                                        the source map.
                                `url`  If specified, path to the source map to append in
                                       `//# sourceMappingURL`.

As I have a daily task that updates my NPM modules, they are kept up2date and as such the version was upgraded automatically.

@tssajo
Copy link
Owner

tssajo commented Jun 2, 2017

@PatTheMav Thanks for reporting this to me!

These backward incompatible changes are killing me, because if I fix the CLI parameters in my program then everyone else will complain start to complain who are not yet upgraded to the latest version of UglifyJS ...

Also, there are changed / incompatible CLI options between UglifyJS 2 and UglifyJS 3 , those are already causing problems for me. IMHO, the author(s) of UglifyJS shouldn't change CLI options which were there for years.

I leave this issue open for now and will deal with it later. When possibly more people upgrade to the new incompatible version of UglifyJS.

@PatTheMav
Copy link
Author

@tssajo - I feel you - maybe parsing the output of uglifyjs -V to check for the installed version (and using the correct CLI parameters) might be an intermediary "fix".

@AshokkumarBalasubramanian

Hi @tssajo

We also have this problem on upgrade UglifyJS.

@sormagupta
Copy link

I am also getting same error what should be the approach to resolve this.

@gregoryforel
Copy link

In case you're still looking for a solution, I think in v3 you don't have to specify the name of the "mapped" file:
uglifyjs test.js -o test.min.js -m -c --source-map --source-map-url --source-map-root ./ -p relative

I'm not sure about the --source-map-url as I don't need this myself, but this works for me:
uglifyjs ./dist/dist/bundle.js -c -m -o ./dist/dist/bundle.min.js --source-map

It generates bundle.min.js and bundle.min.js.map

@PatTheMav
Copy link
Author

@gregoryforel Thanks, works like a charm. Alas no official update of the Package since I reported this bug.. 😞

@tssajo
Copy link
Owner

tssajo commented Mar 16, 2019

@ashucg 's fix is now released. Please do not forgot to upgrade to UglifyJS 3 !

I am closing this Issue now.

@tssajo tssajo closed this as completed Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants