aboutsummaryrefslogtreecommitdiff
path: root/packages/web-util/src/index.build.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-01-17 10:22:49 -0300
committerSebastian <sebasjm@gmail.com>2024-01-17 10:22:49 -0300
commitf5a54633dca3599dab82730fd7d550c0289f170f (patch)
tree5c4d2b25973b891e0b19cb8401d24354a1227105 /packages/web-util/src/index.build.ts
parent87765a4023e33d9502cf55ad2592dabf262ddc69 (diff)
downloadwallet-core-f5a54633dca3599dab82730fd7d550c0289f170f.tar.xz
add translation completeness from pogen to the UI
Diffstat (limited to 'packages/web-util/src/index.build.ts')
-rw-r--r--packages/web-util/src/index.build.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/packages/web-util/src/index.build.ts b/packages/web-util/src/index.build.ts
index e2851dc3a..4a52d1177 100644
--- a/packages/web-util/src/index.build.ts
+++ b/packages/web-util/src/index.build.ts
@@ -121,6 +121,51 @@ const sassPlugin: esbuild.Plugin = {
},
};
+
+/**
+ * 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: esbuild.Plugin = {
+ 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 postCssPlugin: esbuild.Plugin = {
name: "custom-build-postcss",
setup(build) {