File tree Expand file tree Collapse file tree 5 files changed +51
-2
lines changed Expand file tree Collapse file tree 5 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ Add React-PDF to your project by executing `npm install react-pdf` or `yarn add
7474
7575#### Next.js
7676
77- If you use Next.js, you may need to add the following to your ` next.config.js ` :
77+ If you use Next.js without Turbopack enabled, add the following to your ` next.config.js ` :
7878
7979``` diff
8080module.exports = {
@@ -86,6 +86,27 @@ module.exports = {
8686}
8787```
8888
89+ If you use Next.js with Turbopack enabled, add ` empty-module.ts ` file:
90+
91+ ``` ts
92+ export default {};
93+ ```
94+
95+ and add the following to your ` next.config.js ` :
96+
97+ ```` diff
98+
99+ module.exports = {
100+ + experimental: {
101+ + turbo: {
102+ + resolveAlias: {
103+ + canvas: './empty-module.ts',
104+ + },
105+ + },
106+ + },
107+ };
108+ ```
109+
89110# ## Configure PDF.js worker
90111
91112For React-PDF to work, PDF.js worker needs to be provided. You have several options.
@@ -101,7 +122,7 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
101122 'pdfjs-dist/build/pdf.worker.min.js',
102123 import.meta.url,
103124).toString();
104- ```
125+ ````
105126
106127> ** Note**
107128> In Next.js:
Original file line number Diff line number Diff line change 1+ export { } ;
Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
3+ experimental : {
4+ turbo : {
5+ resolveAlias : {
6+ // Turbopack does not support standard ESM import paths yet
7+ './Sample.js' : './app/Sample.tsx' ,
8+ /**
9+ * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
10+ * Module parse failed: Unexpected character '�' (1:0)" error
11+ */
12+ canvas : './empty-module.ts' ,
13+ } ,
14+ } ,
15+ } ,
316 webpack : ( config ) => {
417 /**
518 * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
Original file line number Diff line number Diff line change 1+ export { } ;
Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
3+ experimental : {
4+ turbo : {
5+ resolveAlias : {
6+ // Turbopack does not support standard ESM import paths yet
7+ './Sample.js' : './pages/Sample.tsx' ,
8+ /**
9+ * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
10+ * Module parse failed: Unexpected character '�' (1:0)" error
11+ */
12+ canvas : './empty-module.ts' ,
13+ } ,
14+ } ,
15+ } ,
316 webpack : ( config ) => {
417 /**
518 * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
You can’t perform that action at this time.
0 commit comments