gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/05: separate node entry points


From: gnunet
Subject: [taler-wallet-core] 02/05: separate node entry points
Date: Fri, 20 Aug 2021 13:34:10 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit a3687d84ba011639f6bd1b25ea8ea906fcc5b1f3
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Aug 20 13:01:35 2021 +0200

    separate node entry points
    
    Signed-off-by: Florian Dold <florian@dold.me>
---
 packages/taler-util/package.json                   |  7 +++--
 packages/taler-util/src/globbing/minimatch.ts      | 18 +------------
 packages/taler-util/src/index.node.ts              |  2 ++
 packages/taler-util/src/index.ts                   |  4 +--
 packages/taler-wallet-core/src/headless/helpers.ts | 30 +++++-----------------
 5 files changed, 15 insertions(+), 46 deletions(-)

diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json
index 730e99e8..b4bc3221 100644
--- a/packages/taler-util/package.json
+++ b/packages/taler-util/package.json
@@ -5,8 +5,11 @@
   "exports": {
     ".": "./lib/index.js"
   },
-  "module": "./lib/index.js",
-  "main": "./lib/index.js",
+  "module": "./lib/index.node.js",
+  "main": "./lib/index.node.js",
+  "browser": {
+    "./lib/index.node.js": "./lib/index.js"
+  },
   "type": "module",
   "types": "./lib/index.d.ts",
   "typesVersions": {
diff --git a/packages/taler-util/src/globbing/minimatch.ts 
b/packages/taler-util/src/globbing/minimatch.ts
index 54779623..b23de4e9 100644
--- a/packages/taler-util/src/globbing/minimatch.ts
+++ b/packages/taler-util/src/globbing/minimatch.ts
@@ -7,27 +7,11 @@ purpose with or without fee is hereby granted, provided that 
the above
 copyright notice and this permission notice appear in all copies.
 */
 
-
 import { expand } from "./brace-expansion.js";
 
-const nodejs_path = (function () {
-  let path: typeof import("path");
-  return function () {
-    if (!path) {
-      /**
-       * need to use an expression when doing a require if we want
-       * webpack not to find out about the requirement
-       */
-      const _r = "require";
-      path = module[_r]("path");
-    }
-    return path;
-  };
-})();
-
 let path = { sep: "/" };
 try {
-  path.sep = nodejs_path().sep;
+  path.sep = require("path").sep;
 } catch (er) {}
 
 const GLOBSTAR = {};
diff --git a/packages/taler-util/src/index.node.ts 
b/packages/taler-util/src/index.node.ts
new file mode 100644
index 00000000..f0c80598
--- /dev/null
+++ b/packages/taler-util/src/index.node.ts
@@ -0,0 +1,2 @@
+export * from "./index.js";
+export * from "./talerconfig.js";
diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts
index e45e5dc0..a4b5cc8d 100644
--- a/packages/taler-util/src/index.ts
+++ b/packages/taler-util/src/index.ts
@@ -11,7 +11,6 @@ export * from "./notifications.js";
 export * from "./payto.js";
 export * from "./ReserveStatus.js";
 export * from "./ReserveTransaction.js";
-export * from "./talerconfig.js";
 export * from "./talerTypes.js";
 export * from "./taleruri.js";
 export * from "./time.js";
@@ -19,5 +18,4 @@ export * from "./transactionsTypes.js";
 export * from "./walletTypes.js";
 export * from "./i18n.js";
 export * from "./logging.js";
-export * from "./url.js";
-export * from "./globbing/minimatch.js";
\ No newline at end of file
+export * from "./url.js";
\ No newline at end of file
diff --git a/packages/taler-wallet-core/src/headless/helpers.ts 
b/packages/taler-wallet-core/src/headless/helpers.ts
index a862dab4..1867fab6 100644
--- a/packages/taler-wallet-core/src/headless/helpers.ts
+++ b/packages/taler-wallet-core/src/headless/helpers.ts
@@ -36,24 +36,10 @@ import { SynchronousCryptoWorkerFactory } from 
"../crypto/workers/synchronousWor
 import type { IDBFactory } from "@gnu-taler/idb-bridge";
 import { WalletNotification } from "@gnu-taler/taler-util";
 import { Wallet } from "../wallet.js";
+import * as fs from "fs";
 
 const logger = new Logger("headless/helpers.ts");
 
-const nodejs_fs = (function () {
-  let fs: typeof import("fs");
-  return function () {
-    if (!fs) {
-      /**
-       * need to use an expression when doing a require if we want
-       * webpack not to find out about the requirement
-       */
-      const _r = "require";
-      fs = module[_r]("fs");
-    }
-    return fs;
-  };
-})();
-
 export interface DefaultNodeWalletArgs {
   /**
    * Location of the wallet database.
@@ -101,7 +87,7 @@ export async function getDefaultNodeWallet(
   const storagePath = args.persistentStoragePath;
   if (storagePath) {
     try {
-      const dbContentStr: string = nodejs_fs().readFileSync(storagePath, {
+      const dbContentStr: string = fs.readFileSync(storagePath, {
         encoding: "utf-8",
       });
       const dbContent = JSON.parse(dbContentStr);
@@ -124,15 +110,11 @@ export async function getDefaultNodeWallet(
       }
       const tmpPath = `${args.persistentStoragePath}-${makeId(5)}.tmp`;
       const dbContent = myBackend.exportDump();
-      nodejs_fs().writeFileSync(
-        tmpPath,
-        JSON.stringify(dbContent, undefined, 2),
-        {
-          encoding: "utf-8",
-        },
-      );
+      fs.writeFileSync(tmpPath, JSON.stringify(dbContent, undefined, 2), {
+        encoding: "utf-8",
+      });
       // Atomically move the temporary file onto the DB path.
-      nodejs_fs().renameSync(tmpPath, args.persistentStoragePath);
+      fs.renameSync(tmpPath, args.persistentStoragePath);
     };
   }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]