Non-functioning TypeScript Compilation
Hello, I am the publisher of this package. This is my first package I've published on JSR.
While my TypeScript for this package absolutely works, and I can build it and run it fine both in NodeJS and Deno locally, the transpilation done by JSR fails to produce a functioning library.
I just tried this tiny program in NodeJS to make sure it works:
import { BERElement } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
function main () {
const el = BERElement.fromSequence([
$._encodeUTF8String("hi mom", $.DER),
]);
console.log(el.toBytes());
}
main();
When I run this with Deno, I see:
deno run main.mts
error: Uncaught SyntaxError: The requested module './ABSTRACT-SYNTAX.js' does not provide an export named 'default'
at <anonymous> (file:///[REDACTED]/asn1-ts-test/node_modules/@wildboar/asn1/source/classes/index.js:1:10)
When I compile it, then run it with NodeJS, I see:
ile:///[REDACTED]/asn1-ts-test/node_modules/@wildboar/asn1/source/classes/index.js:1
export { default as ABSTRACT_SYNTAX } from "./ABSTRACT-SYNTAX.js";
^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module './ABSTRACT-SYNTAX.js' does not provide an export named 'default'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:181:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:264:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:583:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5)
ABSTRACT_SYNTAX is an interface (a generic one, in fact), so I expect it to be elided from the ECMAScript output. However, the problem seems to be that the import of that interface still remains in other modules after transpilation. The index.js next door looks like:
export { default as ABSTRACT_SYNTAX } from "./ABSTRACT-SYNTAX.js";
export { default as TYPE_IDENTIFIER } from "./TYPE-IDENTIFIER.js";
//# sourceMappingURL=index.js.map
The expected behavior would be for Deno to elide imports (and re-exports) of symbols that are themselves elided.
you should be using export type on type-only reexports
That's not what TypeScript requires. What I get in index.js when I compile this myself is:
export {};
What JSR is doing is not TypeScript behavior.
It's fine--although not great--if JSR has more stringent requirements in this regard, but this at least needs to be documented if JSR's TypeScript compilation does not behave like normal, and JSR needs to enforce it before the module gets published. This is going to be a big code quality problem if I publish a patch version that "works on my machine" then gets broken by JSR itself and breaks all of its dependents when they upgrade.
https://www.typescriptlang.org/tsconfig/#isolatedModules
Okay, well that looks like that would fix my problem, but in that case, this is the issue:
I will also add that this is disabled by default. Nothing at any point indicated to me that I needed to set this to publish a working Typescript module.