commit 4cf763bcd16f72b167a4daea5bf3265450abb70e
parent f3d9049e8848c4b0f6cc9f73f4a05c59b8173be7
Author: Florian Dold <dold@taler.net>
Date: Tue, 21 Jul 2026 00:43:01 +0200
util: fix the package export map
exports named ./lib/not-implemented.js as the fallback for ./compat and
./qtart, but no such module exists; #compat-impl and #twrpc-impl had no
default at all, and both #compat-impl and #http-impl spelled the types
condition "type", which is not a condition and was ignored. Add the missing
stub modules and correct the conditions.
Also delete src/helpers.test.d.ts, a build artifact committed into src/.
Diffstat:
4 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json
@@ -18,10 +18,10 @@
"default": "./lib/twrpc.js"
},
"./compat": {
- "types": "./lib/compat.node.js",
+ "types": "./lib/compat.node.d.ts",
"node": "./lib/compat.node.js",
"qtart": "./lib/compat.qtart.js",
- "default": "./lib/not-implemented.js"
+ "default": "./lib/compat.missing.js"
},
"./clk": {
"default": "./lib/clk.js"
@@ -30,23 +30,25 @@
"default": "./lib/http.js"
},
"./qtart": {
- "types": "./lib/qtart.js",
+ "types": "./lib/qtart.d.ts",
"qtart": "./lib/qtart.js",
- "default": "./lib/not-implemented.js"
+ "default": "./lib/qtart.missing.js"
}
},
"imports": {
"#twrpc-impl": {
"node": "./lib/twrpc-impl.node.js",
- "qtart": "./lib/twrpc-impl.qtart.js"
+ "qtart": "./lib/twrpc-impl.qtart.js",
+ "default": "./lib/twrpc-impl.missing.js"
},
"#compat-impl": {
+ "types": "./lib/compat.node.d.ts",
"node": "./lib/compat.node.js",
"qtart": "./lib/compat.qtart.js",
- "type": "./lib/compat.d.ts"
+ "default": "./lib/compat.missing.js"
},
"#http-impl": {
- "type": "./lib/http-impl.node.js",
+ "types": "./lib/http-impl.node.d.ts",
"node": "./lib/http-impl.node.js",
"qtart": "./lib/http-impl.qtart.js",
"default": "./lib/http-impl.missing.js"
diff --git a/packages/taler-util/src/compat.missing.ts b/packages/taler-util/src/compat.missing.ts
@@ -0,0 +1,57 @@
+/*
+ This file is part of GNU Taler
+ (C) 2026 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Fallback for the "#compat-impl" / "./compat" conditions on runtimes that are
+ * neither node nor qtart. Every entry point throws, so an unsupported host is
+ * reported where it is used rather than failing to resolve at import time.
+ */
+
+function notImplemented(name: string): never {
+ throw Error(`${name} is not implemented on this platform`);
+}
+
+export function processExit(status: number): never {
+ return notImplemented("processExit");
+}
+
+export function processArgv(): string[] {
+ return notImplemented("processArgv");
+}
+
+export function readlinePrompt(prompt: string): Promise<string> {
+ return notImplemented("readlinePrompt");
+}
+
+export function pathBasename(p: string): string {
+ return notImplemented("pathBasename");
+}
+
+export function pathHomedir(): string {
+ return notImplemented("pathHomedir");
+}
+
+export function setUnhandledRejectionHandler(h: (e: any) => void): void {
+ return notImplemented("setUnhandledRejectionHandler");
+}
+
+export function getenv(name: string): string | undefined {
+ return notImplemented("getenv");
+}
+
+export function readFile(fileName: string): string {
+ return notImplemented("readFile");
+}
diff --git a/packages/taler-util/src/helpers.test.d.ts b/packages/taler-util/src/helpers.test.d.ts
@@ -1 +0,0 @@
-export {};
diff --git a/packages/taler-util/src/qtart.missing.ts b/packages/taler-util/src/qtart.missing.ts
@@ -0,0 +1,35 @@
+/*
+ This file is part of GNU Taler
+ (C) 2026 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Fallback for the "./qtart" condition outside qtart. The real module imports
+ * the QuickJS built-in "os" and "std" modules, which cannot resolve elsewhere,
+ * so this stub stands in and throws on first use.
+ */
+
+import type { QjsOsLib, QjsStdLib } from "./qtart.js";
+
+function unavailable(name: string): never {
+ throw Error(`the qtart ${name} library is only available under qtart`);
+}
+
+export const qjsOs: QjsOsLib = new Proxy({} as QjsOsLib, {
+ get: () => unavailable("os"),
+});
+
+export const qjsStd: QjsStdLib = new Proxy({} as QjsStdLib, {
+ get: () => unavailable("std"),
+});