@ttsc/paths 0.18.4 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/driver/paths.go +14 -6
- package/package.json +1 -1
package/driver/paths.go
CHANGED
|
@@ -264,13 +264,21 @@ func (r *rewriter) outputPathForSource(source string) string {
|
|
|
264
264
|
if err != nil || isOutsideRelativePath(rel) {
|
|
265
265
|
return ""
|
|
266
266
|
}
|
|
267
|
-
return normalizePath(filepath.Join(r.outDir, replaceSourceExtension(rel,
|
|
267
|
+
return normalizePath(filepath.Join(r.outDir, replaceSourceExtension(rel, emittedExtension(rel, r.jsxPreserve))))
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
// emittedExtension returns the output-file extension that TypeScript-Go writes
|
|
271
|
+
// for a given Program source. TypeScript/JavaScript-family sources are
|
|
272
|
+
// transpiled to the matching JavaScript runtime extension. Non-transpiled
|
|
273
|
+
// assets that the compiler copies verbatim — such as `.json` sources pulled in
|
|
274
|
+
// by resolveJsonModule — keep their original extension, so a rewritten
|
|
275
|
+
// specifier names the file the compiler actually emits instead of an invented
|
|
276
|
+
// `.js` sibling that never exists on disk.
|
|
277
|
+
func emittedExtension(source string, jsxPreserve bool) string {
|
|
278
|
+
ext := filepath.Ext(source)
|
|
279
|
+
switch strings.ToLower(ext) {
|
|
280
|
+
case ".ts", ".js":
|
|
281
|
+
return ".js"
|
|
274
282
|
case ".mts", ".mjs":
|
|
275
283
|
return ".mjs"
|
|
276
284
|
case ".cts", ".cjs":
|
|
@@ -281,7 +289,7 @@ func emittedJavaScriptExtension(source string, jsxPreserve bool) string {
|
|
|
281
289
|
}
|
|
282
290
|
return ".js"
|
|
283
291
|
default:
|
|
284
|
-
return
|
|
292
|
+
return ext
|
|
285
293
|
}
|
|
286
294
|
}
|
|
287
295
|
|