-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds source map support for Chrome. Firefox and Safari don't currently work - along with HMR.
- Loading branch information
Showing
14 changed files
with
171 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<meta | ||
http-equiv="Content-Security-Policy" | ||
content=" object-src 'none'; style-src 'nonce-k0Mp1lEd' | ||
'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:; base-uri 'none';" | ||
content=" object-src 'none'; style-src 'nonce-k0Mp1lEd' 'unsafe-eval' https: http:; base-uri 'none';" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as ts from 'typescript'; | ||
import { SourceMapGenerator } from 'source-map'; | ||
import convert from 'convert-source-map'; | ||
import path from 'path'; | ||
|
||
const getFileName = (sourceFile: ts.SourceFile): string => { | ||
return path.basename(sourceFile.fileName); | ||
}; | ||
|
||
/** | ||
* Used to generate a inline source map for CSS. | ||
* It's input is the TypeScript source file, | ||
* an offset (where we should place the cursor when jumping to the source map) | ||
* and TypeScript context. | ||
* | ||
* Will return something like `/*# sourceMappingURL=...` | ||
*/ | ||
export function getSourceMap( | ||
offset: { | ||
line: number; | ||
character: number; | ||
}, | ||
sourceFile: ts.SourceFile, | ||
context: ts.TransformationContext | ||
): string { | ||
const fileName = getFileName(sourceFile); | ||
const generator = new SourceMapGenerator({ | ||
file: fileName, | ||
sourceRoot: context.getCompilerOptions().sourceRoot, | ||
}); | ||
|
||
generator.setSourceContent(fileName, sourceFile.getFullText()); | ||
generator.addMapping({ | ||
generated: { | ||
line: 1, | ||
column: 0, | ||
}, | ||
source: fileName, | ||
original: { | ||
line: offset.line + 1, | ||
column: offset.character, | ||
}, | ||
}); | ||
|
||
return convert.fromObject(generator).toComment({ multiline: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1725,6 +1725,11 @@ | |
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" | ||
|
||
"@types/convert-source-map@^1.5.1": | ||
version "1.5.1" | ||
resolved "https://registry.yarnpkg.com/@types/convert-source-map/-/convert-source-map-1.5.1.tgz#d4d180dd6adc5cb68ad99bd56e03d637881f4616" | ||
integrity sha512-laiDIXqqthjJlyAMYAXOtN3N8+UlbM+KvZi4BaY5ZOekmVkBs/UxfK5O0HWeJVG2eW8F+Mu2ww13fTX+kY1FlQ== | ||
|
||
"@types/eslint-visitor-keys@^1.0.0": | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" | ||
|
@@ -3596,15 +3601,11 @@ core-js-compat@^3.6.2: | |
browserslist "^4.8.3" | ||
semver "7.0.0" | ||
|
||
core-js-pure@^3.0.0: | ||
core-js-pure@^3.0.0, core-js-pure@^3.0.1: | ||
version "3.6.5" | ||
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813" | ||
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA== | ||
|
||
core-js-pure@^3.0.1: | ||
version "3.6.4" | ||
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.4.tgz#4bf1ba866e25814f149d4e9aaa08c36173506e3a" | ||
|
||
core-js@^1.0.0: | ||
version "1.2.7" | ||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" | ||
|
@@ -8945,11 +8946,7 @@ regenerator-runtime@^0.11.0: | |
version "0.11.1" | ||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" | ||
|
||
regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.3: | ||
version "0.13.3" | ||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" | ||
|
||
regenerator-runtime@^0.13.4: | ||
regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4: | ||
version "0.13.5" | ||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697" | ||
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA== | ||
|
@@ -9122,13 +9119,7 @@ [email protected]: | |
version "1.1.7" | ||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" | ||
|
||
[email protected], resolve@^1.0.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.9.0: | ||
version "1.14.2" | ||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.14.2.tgz#dbf31d0fa98b1f29aa5169783b9c290cb865fea2" | ||
dependencies: | ||
path-parse "^1.0.6" | ||
|
||
resolve@^1.15.1: | ||
[email protected], resolve@^1.0.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.9.0: | ||
version "1.16.0" | ||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.16.0.tgz#063dc704fa3413e13ac1d0d1756a7cbfe95dd1a7" | ||
integrity sha512-LarL/PIKJvc09k1jaeT4kQb/8/7P+qV4qSnN2K80AES+OHdfZELAKVOBjxsvtToT/uLOfFbvYvKfZmV8cee7nA== | ||
|
@@ -9590,6 +9581,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: | |
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" | ||
|
||
source-map@^0.7.3: | ||
version "0.7.3" | ||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" | ||
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== | ||
|
||
space-separated-tokens@^1.0.0: | ||
version "1.1.4" | ||
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.4.tgz#27910835ae00d0adfcdbd0ad7e611fb9544351fa" | ||
|
@@ -10355,15 +10351,11 @@ tsconfig@^7.0.0: | |
strip-bom "^3.0.0" | ||
strip-json-comments "^2.0.0" | ||
|
||
tslib@^1.8.1: | ||
tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: | ||
version "1.11.1" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" | ||
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== | ||
|
||
tslib@^1.9.0, tslib@^1.9.3: | ||
version "1.10.0" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" | ||
|
||
tsutils@^3.17.1: | ||
version "3.17.1" | ||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" | ||
|