mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3d979dd059
PR-URL: https://github.com/nodejs/node/pull/55601 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
25 lines
742 B
JavaScript
25 lines
742 B
JavaScript
"use strict";
|
|
import { transformSync } from "./index.js";
|
|
export async function load(url, context, nextLoad) {
|
|
const { format } = context;
|
|
if (format.endsWith("-typescript")) {
|
|
const { source } = await nextLoad(url, {
|
|
...context,
|
|
format: "module"
|
|
});
|
|
const { code } = transformSync(source.toString(), {
|
|
mode: "strip-only"
|
|
});
|
|
return {
|
|
format: format.replace("-typescript", ""),
|
|
// Source map is not necessary in strip-only mode. However, to map the source
|
|
// file in debuggers to the original TypeScript source, add a sourceURL magic
|
|
// comment to hint that it is a generated source.
|
|
source: `${code}
|
|
|
|
//# sourceURL=${url}`
|
|
};
|
|
}
|
|
return nextLoad(url, context);
|
|
}
|