Hey there! I'm currently working on rendering a PDF using the react-pdf library in my next app, but I've run into a problem:
SyntaxError: The named export 'PDFDataRangeTransport' cannot be found in the module 'pdfjs-dist'. This module is a CommonJS one, which may not fully support all exports as named exports. CommonJS modules can be imported using the default export like so:
import pkg from 'pdfjs-dist';
const { PDFDataRangeTransport } = pkg;
I have updated the next.config.js to include the following changes:
webpack(config, options) {
config.module.rules.push({
test: /\.node/,
use: 'raw-loader',
},
{
test: /\.mp3$/,
use: {
loader: 'file-loader',
},
});
return config;
},
However, while paging, an issue arises. Strangely, if I exclude the Document component and let the page render first before adding back the Document component, everything renders correctly.