I am working on a project with Next.js and need to utilize openjphjs for decoding HTJ2K pixel data.
In order to incorporate openjphjs, I have included both openjphjs.js and openjphjs.wasm in a specific folder within the project structure.
To address an error that arose, I made the following adjustments to the next.config.js file:
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
These modifications were aimed at resolving the issue highlighted by the error message:
Module not found: Can't resolve 'fs'
Following guidance from the example provided, I attempted the following implementation:
import openjphjs from './openjphjs/openjphjs.js';
const decode = () => {
const decoder = new openjphjs.HTJ2KDecoder();
}
Unfortunately, this approach resulted in multiple errors being thrown:
GET http://localhost:3000/_next/static/chunks/openjphjs.wasm 404 (Not Found)
Uncaught (in promise) RuntimeError: Aborted(RuntimeError: Aborted(both async and sync fetching of the wasm failed).
Uncaught TypeError: _openjphjs_openjphjs_js__WEBPACK_IMPORTED_MODULE_8___default(...).HTJ2KDecoder is not a constructor
Experimentally, I also tried relocating openjphjs.wasm to the indicated path, as well as placing the files in the /public directory, but the issues persisted.