gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: fix new node version


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix new node version
Date: Tue, 16 Jan 2024 19:44:07 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 54d5cb458 fix new node version
54d5cb458 is described below

commit 54d5cb4584e8c0378fe09ee4c9b8e7760ff293af
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Tue Jan 16 15:44:00 2024 -0300

    fix new node version
---
 packages/web-util/build.mjs | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/packages/web-util/build.mjs b/packages/web-util/build.mjs
index c15a2715b..6320b4937 100755
--- a/packages/web-util/build.mjs
+++ b/packages/web-util/build.mjs
@@ -50,6 +50,49 @@ function git_hash() {
   }
 }
 
+/**
+ * Problem: 
+ *   No loader is configured for ".node" files: 
../../node_modules/.pnpm/fsevents@2.3.3/node_modules/fsevents/fsevents.node
+ * 
+ * Reference:
+ *   https://github.com/evanw/esbuild/issues/1051#issuecomment-806325487
+ */
+const nativeNodeModulesPlugin = {
+  name: 'native-node-modules',
+  setup(build) {
+    // If a ".node" file is imported within a module in the "file" namespace, 
resolve 
+    // it to an absolute path and put it into the "node-file" virtual 
namespace.
+    build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => ({
+      path: require.resolve(args.path, { paths: [args.resolveDir] }),
+      namespace: 'node-file',
+    }))
+
+    // Files in the "node-file" virtual namespace call "require()" on the
+    // path from esbuild of the ".node" file in the output directory.
+    build.onLoad({ filter: /.*/, namespace: 'node-file' }, args => ({
+      contents: `
+        import path from ${JSON.stringify(args.path)}
+        try { module.exports = require(path) }
+        catch {}
+      `,
+    }))
+
+    // If a ".node" file is imported within a module in the "node-file" 
namespace, put
+    // it in the "file" namespace where esbuild's default loading behavior 
will handle
+    // it. It is already an absolute path since we resolved it to one above.
+    build.onResolve({ filter: /\.node$/, namespace: 'node-file' }, args => ({
+      path: args.path,
+      namespace: 'file',
+    }))
+
+    // Tell esbuild's default loading behavior to use the "file" loader for
+    // these ".node" files.
+    let opts = build.initialOptions
+    opts.loader = opts.loader || {}
+    opts.loader['.node'] = 'file'
+  },
+}
+
 const buildConfigBase = {
   outdir: "lib",
   bundle: true,
@@ -66,6 +109,7 @@ const buildConfigBase = {
     __VERSION__: `"${_package.version}"`,
     __GIT_HASH__: `"${GIT_HASH}"`,
   },
+  plugins: [nativeNodeModulesPlugin],
 };
 
 /**
@@ -122,6 +166,7 @@ const buildConfigNode = {
   format: "cjs",
   platform: "node",
   external: ["preact"],
+
 };
 
 /**

-- 
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]