Skip to content

Commit

Permalink
Remove xssi trap from sourcemaps as Firefox doesn't support it.
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Graham Clark committed Dec 19, 2017
1 parent 31d40d9 commit 7d9151b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ For most projects, it is better to configure `language-babel` via project-based
```

* #### Create Map
If transpiled output is being saved a separate source map can be also be saved. The source file name will be used with a new suffix of `.js.map` and sent to a directory specified in `Babel Maps Path`. To avoid any possible XSSI issues the map file is prefixed with `)]}`
If transpiled output is being saved a separate source map can be also be saved. The source file name will be used with a new suffix of `.js.map` and sent to a directory specified in `Babel Maps Path`.

If `.babelrc` files use the `sourceMaps: inline` or `sourceMaps both` option, turn this `createMap` option off as the map data is stored as part of the source file.

Expand Down
7 changes: 3 additions & 4 deletions lib/transpiler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,8 @@ class Transpiler
file: f
names: msgRet.result.map.names
mappings: msgRet.result.map.mappings
xssiProtection = ')]}\n'
fs.writeFileSync pathTo.mapFile,
xssiProtection + JSON.stringify mapJson, null, ' '
#xssiProtection = ')]}\n' # removed this line as Firefox doesn't support removal of xssi prefix!
fs.writeFileSync pathTo.mapFile, JSON.stringify mapJson, null, ' '

# clean notification messages
cleanNotifications: (pathTo) ->
Expand Down Expand Up @@ -391,7 +390,7 @@ class Transpiler

sourceFileName = parsedSourceFile.name + fnExt
mapFileName = parsedSourceFile.name + fnExt + '.map'

absTranspiledFile = path.normalize(path.join(absTranspileRoot, relSourceRootToSourceFile , sourceFileName ))
absMapFile = path.normalize(path.join(absMapsRoot, relSourceRootToSourceFile, mapFileName ))

Expand Down

0 comments on commit 7d9151b

Please sign in to comment.