@danielx/civet 0.5.91 → 0.5.93

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/dist/civet CHANGED
@@ -265,7 +265,6 @@ cli = async function() {
265
265
  if (options.run) {
266
266
  options.js = true;
267
267
  options.inlineMap = true;
268
- require("../register.js");
269
268
  }
270
269
  if (options.repl) {
271
270
  return repl(options);
@@ -353,6 +352,7 @@ cli = async function() {
353
352
  }
354
353
  results.push(process.exit(child.status));
355
354
  } else {
355
+ require("../register.js");
356
356
  try {
357
357
  module.filename = await fs.realpath(filename);
358
358
  } catch (error1) {
package/dist/esm.mjs CHANGED
@@ -44,7 +44,7 @@ function ensureRegister () {
44
44
  let path = pathOrUrl
45
45
  // If it's a file URL, convert to local path
46
46
  // I could not find a way to handle non-URLs except to swallow an error
47
- if (path.startsWith('file://')) {
47
+ if (path.startsWith('file:')) {
48
48
  try {
49
49
  path = fileURLToPath(path)
50
50
  } catch(e) {}
@@ -85,10 +85,11 @@ export async function load(url, context, next) {
85
85
  js: true,
86
86
  })
87
87
 
88
- const transpiledPath = url + ".tsx"
88
+ // NOTE: Append .tsx to URL so ts-node treats as TypeScript
89
+ const transpiledUrl = url + ".tsx"
89
90
 
90
91
  // NOTE: Assuming ts-node hook follows load hook
91
- const result = await next(transpiledPath, {
92
+ const result = await next(transpiledUrl, {
92
93
  // ts-node won't transpile unless this is module
93
94
  // can't use commonjs since we don't rewrite imports
94
95
  format: "module",
@@ -99,9 +100,13 @@ export async function load(url, context, next) {
99
100
  // NOTE: we must install our source map support after ts-node does to take priority
100
101
  ensureRegister()
101
102
 
103
+ // Remove .tsx extension for final URL
104
+ result.responseURL = (result.responseURL ?? transpiledUrl)
105
+ .replace(/.tsx$/, '')
106
+
102
107
  // parse source map from downstream (ts-node) result
103
108
  // compose with civet source map
104
- result.source = SourceMap.remap(result.source, sourceMap, url, "")
109
+ result.source = SourceMap.remap(result.source, sourceMap, url, result.responseURL)
105
110
  // NOTE: This path needs to match what ts-node uses so we can override the source map
106
111
  outputCache.set(normalizeSlashes(path), result.source)
107
112