source-map-path-normalizify

WebJar for source-map-path-normalizify

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

source-map-path-normalizify
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

source-map-path-normalizify
WebJar for source-map-path-normalizify
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/fatfisz/source-map-path-normalizify

Download source-map-path-normalizify

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/source-map-path-normalizify/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>source-map-path-normalizify</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/source-map-path-normalizify/
implementation 'org.webjars.npm:source-map-path-normalizify:0.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/source-map-path-normalizify/
implementation ("org.webjars.npm:source-map-path-normalizify:0.0.3")
'org.webjars.npm:source-map-path-normalizify:jar:0.0.3'
<dependency org="org.webjars.npm" name="source-map-path-normalizify" rev="0.0.3">
  <artifact name="source-map-path-normalizify" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='source-map-path-normalizify', version='0.0.3')
)
libraryDependencies += "org.webjars.npm" % "source-map-path-normalizify" % "0.0.3"
[org.webjars.npm/source-map-path-normalizify "0.0.3"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm » browserify-transform-tools jar [1.4.2,2)
org.webjars.npm : convert-source-map jar [1.1.1,2)
org.webjars.npm : object-assign jar [4.0.1,5)

Project Modules

There are no modules declared in this project.

source-map-path-normalizify

Browserify transform that fixes source map paths

The problem

Let's say you use grunt-browserify with a debug option turned on. And you use a transform, e.g. reactify. And you work on Windows!

There is a chance your source maps don't have the right paths. Instead of seeing nice tree like this in your dev tools:

localhost:8080
├─ js
|  ├─ dir1
|  |  ├─ script1.js
|  |  ├─ script2.js
|  ├─ dir2
|  |  ├─ script1.js
|  |  └─ script2.js
|  └─ bundle.js
└─ node-modules
   ├─ grunt-browserify/node_modules/browserify/node_modules
   │  ├─ browser-pack
   |  |  └─ _prelude.js
   |  └─ events
   |     └─ events.js
   ├─ module1
   └─ module2

you see this abomination:

localhost:8080
└─ js
   ├─ node_modules
   |  ├─ grunt-browserify/node_modules/browserify/node_modules/events
   |  |  └─ events.js
   |  ├─ module1
   |  └─ module2
   ├─ D:\LongPathToTheProject\js\dir1\script1.js        The filename is a full absolute path.
   ├─ D:\LongPathToTheProject\js\dir1\script2.js        And where did my directory structure go?
   ├─ D:\LongPathToTheProject\js\dir2\script1.js        Oh no!
   ├─ D:\LongPathToTheProject\js\dir2\script2.js
   ├─ bundle.js
   └─ node_modules\grunt-browserify\node_modules\browserify\node_modules\browser-pack\_prelude.js

The solution

Just use this transform as you'd use any other, preferably as the last one. It will extract the source map and fix the paths.

Options

options.root

Type: String Default: process.cwd()

The path with respect to which we will be resolving the paths saved in the old source map.

E.g. for an old path D:\LongPathToTheProject\js\dir2\script2.js and options.root set to D:\LongPathToTheProject, the resulting path will be js/dir2/script2.js (notice the normalized separators).

options.sourceRoot

Type: String Default: '/'

The new value of the sourceRoot source map property.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

License

Copyright (c) 2015 FatFisz. Licensed under the MIT license.

Versions

Version
0.0.3