Closed psychobolt closed 4 months ago
Didn't look into too deeply, but I suspect on Windows the file url would be backslash'd and have a lowercase drive letter. Since there is a check here, I simply patched the url before short circuit is sent e.g.
return addShortCircuitSignal({
// for lazy: ts-node think format would undefined, actually it should not, keep it as original temporarily
format: resolvedFormat,
source: compiled,
+ responseURL: new URL(url).href
});
};
could you please provide a minimal reproduction
https://codesandbox.io/p/devbox/swc-register-import-query-gq2hpq . If you run this sandbox you will get ERR_UNKNOWN_FILE_EXTENSION
for query import. However if I prefix with file://
to import, there is no issues.
Updated to @swc-node/register v1.10.0
I have a file imported in one of my sub-packages using the following url specifier path with query e.g.
import(`my/project/foo.ts?${timestamp}`)
. However, seems like my compiled output is same as original source in debug inspection. This led to my vite plugin to throwSyntaxError
e.g.log ref
Changing
url
to filePath usingfileURLtoPath
, seems to resolve my main issue. e.g.However, after applying the above suggested fix, I would get another error which seems to only fail on Windows:
Expected Behavior
All TS files with URL specifier should be compiled and resolved without any issues.