Closed 0-don closed 1 month ago
I think the issue comes from using app router
instead of pages router
while calling the api rpc methods
Error: Cannot find module '/home/don/Desktop/xmr-sample-next/.next/dist/src/main/js/common/MoneroWebWorker.js'
Require stack:
- /home/don/Desktop/xmr-sample-next/node_modules/web-worker/cjs/node.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
at Function._load (node:internal/modules/cjs/loader:1051:27)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at require (node:internal/modules/helpers:179:18)
at workerThread (/home/don/Desktop/xmr-sample-next/node_modules/web-worker/cjs/node.js:189:9)
at Object.<anonymous> (/home/don/Desktop/xmr-sample-next/node_modules/web-worker/cjs/node.js:67:56)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Object..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Function._load (node:internal/modules/cjs/loader:1104:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/don/Desktop/xmr-sample-next/node_modules/web-worker/cjs/node.js'
]
}
this error doesn't appear when using pages router
Ok, just confirming it's working for you by default on the main branch?
Are these 2 different issues then, one is about enabling standalone output, and one is about using a different router?
its the same issue and I think I got a fix for it, this way standalone works and app router aswell
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
webpack: (config, { isServer }) => {
config.experiments = { ...config.experiments, topLevelAwait: true };
if (!isServer) {
config.resolve.alias.fs = "memfs";
config.resolve.fallback.child_process = false;
}
config.externals = [
...config.externals,
({ request }, callback) => {
if (/^web-worker$/.test(request)) {
return callback(null, request);
}
callback();
},
];
if (isServer) {
config.externals.push("monero-ts");
}
return config;
},
};
export default nextConfig;
Ok great, a PR is welcome :)
I will test this further and make one if everything looks fine
would be nice to make
output: "standalone"
working to decrease the bundle size in docker images innext.config.mjs