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

-p relative not working correctly #261

Closed
bdkjones opened this issue Aug 8, 2013 · 0 comments · Fixed by #1811
Closed

-p relative not working correctly #261

bdkjones opened this issue Aug 8, 2013 · 0 comments · Fixed by #1811

Comments

@bdkjones
Copy link

bdkjones commented Aug 8, 2013

Gave the new -p relative functionality a go, but things still don't look right. First, here's the file structure for the project:

screen shot 2013-08-08 at 11 49 55

I first compile "arrays.coffee" into "arrays-out.js" and have CoffeeScript generate a corresponding source map that gets saved to "arrays-out.map". (CoffeeScript is retarded, so I manually write that source map's file paths --- in other words, I know the paths in the source map I get from CoffeeScript are correct because I set them myself.)

Next, I tell Uglify to minify the "arrays-out.js" file and write it back to the exact same spot. I also tell Uglify to create a source map and write that map file to the exact same spot (arrays-out.map). I pass arrays-out.map as the --in-source-map parameter.

I pass -p relative to the Uglify command and I get the following source map file (I've deleted the mappings data for brevity):

screen shot 2013-08-08 at 11 53 26

There are a few problems:

  1. The "file" path is not relative at all. When the relative flag is passed, this path should be relative to the map file's location. In this example, the path should be: "./arrays-out.js" or just "arrays-out.js" because the map file is right next to the output file.

  2. The files in the "sources" array are indeed relative to the location of the map file, but Uglify has also included the optional sourceRoot parameter and set sourceRoot equal to: "./../" This is incorrect because the files in the sources array already have that prefix appended to them. Right now, when the browser loads this source map, it's going to take the sourceRoot value and prefix that to every item in the sources array, so it will look for sources at this path: "./.././../arrays.coffee". Obviously, this will break.

The solution is EITHER:

A) the sourceRoot parameter (which is optional according to the source map spec) needs to be omitted if the file paths in the sources array are ALREADY relative to the map file.

OR

B) if a sourceRoot path is included, the file paths in the sources array must be set relative to the SOURCE ROOT folder, not the *.map file itself.

Hopefully that all makes sense!

alexlamsl added a commit that referenced this issue Apr 15, 2017
- rename `screw_ie8` to `ie8`
- rename `mangle.except` to `mangle.reserved`
- rename `mangle.properties.ignore_quoted` to `mangle.properties.keep_quoted` 
- compact `sourceMap` options
- more stringent verification on input `options`
- toplevel shorthands
  - `ie8`
  - `keep_fnames`
  - `toplevel`
  - `warnings`
- support arrays and unquoted string values on CLI
- drop `fromString` from `minify()`
  - `minify()` no longer handles any `fs` operations
- unify order of operations for `mangle_properties()` on CLI & API
  - `bin/uglifyjs` used to `mangle_properties()` before even `Compressor`
  - `minify()` used to `mangle_properties()` after `Compressor` but before `mangle_names()`
  - both will now do `Compressor`, `mangle_names()` then `mangle_properties()`
- `options.parse` / `--parse` for parser options beyond `bare_returns`
- add `mangle.properties.builtins` to disable built-in reserved list
  - disable with `--mangle-props builtins` on CLI
- `warnings` now off by default
- add `--warn` and `--verbose` on CLI
- drop `--enclose`
- drop `--export-all`
- drop `--reserved-file`
  - use `--mangle reserved` instead
- drop `--reserve-domprops`
  - enabled by default, disable with `--mangle-props domprops`
- drop `--prefix`
  - use `--source-map base` instead
- drop `--lint`
- remove `bin/extract-props.js`
- limit exposure of internal APIs
- update documentations

closes #96
closes #102
closes #136
closes #166
closes #243
closes #254
closes #261
closes #311
closes #700
closes #748
closes #912
closes #1072
closes #1366
fixes #101
fixes #123
fixes #124
fixes #263
fixes #379
fixes #419
fixes #423
fixes #461
fixes #465
fixes #576
fixes #737
fixes #772
fixes #958
fixes #1036
fixes #1142
fixes #1175
fixes #1220
fixes #1223
fixes #1280
fixes #1359
fixes #1368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants