mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
//// [tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emitModuleCommonJS.ts] ////
|
|
|
|
//// [a.js]
|
|
{
|
|
require("" + "./foo.ts");
|
|
import("" + "./foo.ts");
|
|
require("./foo.ts");
|
|
import("./foo.ts");
|
|
}
|
|
|
|
//// [b.ts]
|
|
{
|
|
import("" + "./foo.ts");
|
|
import("./foo.ts");
|
|
}
|
|
|
|
|
|
//// [a.js]
|
|
"use strict";
|
|
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
});
|
|
}
|
|
return path;
|
|
};
|
|
{
|
|
require(__rewriteRelativeImportExtension("" + "./foo.ts"));
|
|
import(__rewriteRelativeImportExtension("" + "./foo.ts"));
|
|
require("./foo.js");
|
|
import("./foo.js");
|
|
}
|
|
//// [b.js]
|
|
"use strict";
|
|
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
});
|
|
}
|
|
return path;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
{
|
|
import(__rewriteRelativeImportExtension("" + "./foo.ts"));
|
|
import("./foo.js");
|
|
}
|