cleanup after landing #450

This commit is contained in:
Evan Wallace
2020-10-13 00:34:15 -07:00
parent 351e7e76e7
commit a19eb2aa13
4 changed files with 16 additions and 6 deletions

View File

@@ -2,6 +2,6 @@
indent_style = tab
indent_size = 2
[*.js]
[*.{js,ts}]
indent_style = space
indent_size = 2

View File

@@ -42,6 +42,14 @@
The `importsNotUsedAsValues` field in `tsconfig.json` is now respected. Setting it to `"preserve"` means esbuild will no longer remove unused imports in TypeScript files. This field was added in TypeScript 3.8.
* Fix relative paths in generated source maps ([#444](https://github.com/evanw/esbuild/issues/444))
Currently paths in generated source map files don't necessarily correspond to real file system paths. They are really only meant to be human-readable when debugging in the browser.
However, the Visual Studio Code debugger expects these paths to point back to the original files on the file system. With this release, it should now always be possible to get back to the original source file by joining the directory containing the source map file with the relative path in the source map.
This fix was contributed by [@yoyo930021](https://github.com/yoyo930021).
## 0.7.14
* Fix a bug with compound import statements ([#446](https://github.com/evanw/esbuild/issues/446))

View File

@@ -3809,12 +3809,13 @@ func (c *linkerContext) generateSourceMapForChunk(relDir string, results []compi
j.AddString("]")
// Write the sourceRoot
j.AddString(",\n \"sourceRoot\": \"")
sourceRoot := ""
if rel, ok := c.fs.Rel(c.fs.Join(c.options.AbsOutputDir, relDir), c.fs.Cwd()); ok {
// Replace Windows backward slashes with standard forward slashes.
j.AddString(strings.ReplaceAll(rel, "\\", "/"))
sourceRoot = strings.ReplaceAll(rel, "\\", "/")
}
j.AddString("\"")
j.AddString(",\n \"sourceRoot\": ")
j.AddBytes(js_printer.QuoteForJSON(sourceRoot))
// Write the sourcesContent
j.AddString(",\n \"sourcesContent\": [")

View File

@@ -260,7 +260,8 @@ async function check(kind, testCase, toSearch, { flags, entryPoints, crlf }) {
const inSource = isStdin ? '<stdin>' : files.find(x => path.basename(x).startsWith(id[0]))
const expectedSource = path.join(relativeTo, inSource).replace(/\\/g, '/')
recordCheck(source === expectedSource, `expected: ${expectedSource} observed: ${source}`)
const observedSource = path.join(relativeTo, source).replace(/\\/g, '/')
recordCheck(observedSource === expectedSource, `expected: ${expectedSource} observed: ${observedSource}`)
const inJs = map.sourceContentFor(source)
const inIndex = inJs.indexOf(`"${id}"`)
@@ -314,7 +315,7 @@ async function check(kind, testCase, toSearch, { flags, entryPoints, crlf }) {
const out2JsMap = await readFileAsync(path.join(tempDir, 'out2.js.map'), 'utf8')
const out2Map = await new SourceMapConsumer(out2JsMap)
checkMap(out2Js, out2Map, path.join(path.relative(tempDir, testDir), path.basename(tempDir)))
checkMap(out2Js, out2Map, tempDir)
}
if (!failed) rimraf.sync(tempDir, { disableGlob: true })