File tree Expand file tree Collapse file tree 5 files changed +49
-1
lines changed Expand file tree Collapse file tree 5 files changed +49
-1
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
74
74
75
75
#### Next.js
76
76
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 ` :
78
78
79
79
``` diff
80
80
module.exports = {
@@ -86,6 +86,26 @@ module.exports = {
86
86
}
87
87
```
88
88
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
+ module.exports = {
99
+ + experimental: {
100
+ + turbo: {
101
+ + resolveAlias: {
102
+ + canvas: './empty-module.ts',
103
+ + },
104
+ + },
105
+ + },
106
+ };
107
+ ```
108
+
89
109
### Configure PDF.js worker
90
110
91
111
For React-PDF to work, PDF.js worker needs to be provided. You have several options.
Original file line number Diff line number Diff line change
1
+ export { } ;
Original file line number Diff line number Diff line change 1
1
/** @type {import('next').NextConfig } */
2
2
const 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
+ } ,
3
16
webpack : ( config ) => {
4
17
/**
5
18
* 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 1
1
/** @type {import('next').NextConfig } */
2
2
const 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
+ } ,
3
16
webpack : ( config ) => {
4
17
/**
5
18
* Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
You can’t perform that action at this time.
0 commit comments