Skip to content

Commit ed755e1

Browse files
committed
Do not massage declaration import paths
These are now correctly produced and work. But the path stuff does still need to be stripped. It is not supported and requires downstream projects to also define the paths. Refer: https://stackoverflow.com/a/52501384 microsoft/TypeScript#15479
1 parent a013a6d commit ed755e1

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

sknpm/src/main.sk

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ fun manage(
698698
if (bc.env.verbose) {
699699
print_string(">> Copy types declaration files.");
700700
};
701-
declFiles.each(f -> copyToDir(f, distDir, ".mjs"));
701+
declFiles.each(f -> copyToDir(f, distDir));
702702
srcDir = Path.join(npmDir, "src");
703703
checkDir(srcDir);
704704
if (bc.env.verbose) {
@@ -708,7 +708,7 @@ fun manage(
708708
tsDir,
709709
f -> f.endsWith(".ts"),
710710
_f -> false,
711-
).each(f -> copyToDir(f, srcDir, ""));
711+
).each(f -> copyToDir(f, srcDir));
712712
if (bc.env.verbose) {
713713
print_string(">> Manage license and package files.");
714714
};
@@ -825,25 +825,23 @@ fun tsc(tsDir: String, link: ?(String, String), verbose: Bool): void {
825825
Skargo.run(Array["tsc", "--project", tsconfig], verbose);
826826
}
827827

828-
fun copyToDir(tsFile: String, dir: String, ext: String = ".ts"): void {
828+
fun copyToDir(tsFile: String, dir: String): void {
829829
contents = FileSystem.readTextFile(tsFile);
830830
target = Path.join(dir, Path.basename(tsFile));
831831
lines = contents.split("\n").map(line -> {
832-
if (line.startsWith("import ") || line.startsWith("export {")) {
832+
if (
833+
line.startsWith("import ") ||
834+
line.startsWith("export {") ||
835+
line.startsWith("export type {")
836+
) {
833837
elements = line.split(" from ");
834838
if (elements.size() == 2) {
835839
imported = elements[1].split("\"");
836840
if (imported.size() == 3) {
837841
elems = imported[1].split("/");
838842
size = elems.size();
839843
if (size > 1 && elems[0].startsWith("#")) {
840-
!elems = elems.mapWithIndex((idx, v) ->
841-
if (idx == 0) "." else if (idx == size - 1) {
842-
`${v}${ext}`
843-
} else {
844-
v
845-
}
846-
);
844+
!elems = elems.mapWithIndex((idx, v) -> if (idx == 0) "." else v);
847845
!line = `${elements[0]} from "${elems.join("/")}"`
848846
}
849847
}

0 commit comments

Comments
 (0)