@ttsc/paths 0.18.4 → 0.19.0

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.
Files changed (2) hide show
  1. package/driver/paths.go +14 -6
  2. 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, emittedJavaScriptExtension(rel, r.jsxPreserve))))
267
+ return normalizePath(filepath.Join(r.outDir, replaceSourceExtension(rel, emittedExtension(rel, r.jsxPreserve))))
268
268
  }
269
269
 
270
- // emittedJavaScriptExtension returns the JavaScript file extension that TypeScript
271
- // emits for a given source path.
272
- func emittedJavaScriptExtension(source string, jsxPreserve bool) string {
273
- switch strings.ToLower(filepath.Ext(source)) {
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 ".js"
292
+ return ext
285
293
  }
286
294
  }
287
295
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/paths",
3
- "version": "0.18.4",
3
+ "version": "0.19.0",
4
4
  "description": "First-party ttsc plugin that rewrites emitted module specifiers from tsconfig paths.",
5
5
  "main": "src/index.cjs",
6
6
  "exports": {