Commit 049a690
authored
Backport: Fix
> [!NOTE]
> This is a backport of #73732 for Next.js 14.
When using dependencies in Middleware that make use of dynamic code
evaluation, Next.js emits a build error because this is not supported in
the Edge runtime.
In rare cases, when the code can not be reached at runtime and can't be
removed by tree-shaking, users might opt in to using the
`unstable_allowDynamic` config.
When combined with pnpm, the provided glob patterns as documented at
https://nextjs.org/docs/messages/edge-dynamic-code-evaluation#possible-ways-to-fix-it
did not match correctly because of pnpm's use of the `.pnpm` directory.
To fix the pattern matching, we need to provide the `dot` option to
[picomatch](https://github.com/micromatch/picomatch), which enables
dotfile matching.
_Side note: Ideally we would detect dynamic code evaluation after tree
shaking, to reduce the number of cases where users need to revert to
using `unstable_allowDynamic`._
fixes #51401unstable_allowDynamic when used with pnpm (#73765)1 parent 663fa9c commit 049a690
File tree
8 files changed
+55
-24
lines changed- docs/02-app/02-api-reference
- errors
- packages/next/src/build
- analysis
- webpack/plugins
- test/integration/edge-runtime-configurable-guards
- node_modules
- .pnpm/test/node_modules/lib
- test
8 files changed
+55
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| |||
Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 40 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
77 | | - | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| |||
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | | - | |
| 171 | + | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
172 | | - | |
| 178 | + | |
173 | 179 | | |
174 | 180 | | |
175 | 181 | | |
| |||
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
181 | 190 | | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
186 | 195 | | |
187 | 196 | | |
188 | | - | |
| 197 | + | |
189 | 198 | | |
190 | 199 | | |
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
196 | | - | |
| 205 | + | |
197 | 206 | | |
198 | 207 | | |
199 | 208 | | |
| |||
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
205 | 217 | | |
206 | | - | |
| 218 | + | |
207 | 219 | | |
208 | | - | |
209 | | - | |
| 220 | + | |
210 | 221 | | |
211 | 222 | | |
212 | 223 | | |
| 224 | + | |
213 | 225 | | |
| 226 | + | |
214 | 227 | | |
215 | 228 | | |
216 | 229 | | |
| |||
260 | 273 | | |
261 | 274 | | |
262 | 275 | | |
263 | | - | |
| 276 | + | |
264 | 277 | | |
265 | 278 | | |
266 | 279 | | |
267 | 280 | | |
268 | 281 | | |
269 | 282 | | |
270 | | - | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
| |||
285 | 298 | | |
286 | 299 | | |
287 | 300 | | |
288 | | - | |
| 301 | + | |
289 | 302 | | |
290 | 303 | | |
291 | 304 | | |
292 | 305 | | |
293 | 306 | | |
294 | 307 | | |
295 | | - | |
| 308 | + | |
296 | 309 | | |
297 | 310 | | |
298 | 311 | | |
| |||
340 | 353 | | |
341 | 354 | | |
342 | 355 | | |
343 | | - | |
| 356 | + | |
344 | 357 | | |
345 | 358 | | |
346 | 359 | | |
| |||
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
359 | 375 | | |
360 | 376 | | |
361 | 377 | | |
362 | 378 | | |
363 | 379 | | |
364 | 380 | | |
365 | 381 | | |
366 | | - | |
| 382 | + | |
367 | 383 | | |
368 | 384 | | |
369 | 385 | | |
| |||
378 | 394 | | |
379 | 395 | | |
380 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
381 | 400 | | |
382 | | - | |
| 401 | + | |
383 | 402 | | |
384 | | - | |
385 | | - | |
| 403 | + | |
386 | 404 | | |
387 | 405 | | |
388 | 406 | | |
| 407 | + | |
389 | 408 | | |
| 409 | + | |
390 | 410 | | |
391 | 411 | | |
392 | 412 | | |
393 | 413 | | |
394 | | - | |
| 414 | + | |
395 | 415 | | |
396 | 416 | | |
397 | 417 | | |
| |||
429 | 449 | | |
430 | 450 | | |
431 | 451 | | |
432 | | - | |
| 452 | + | |
433 | 453 | | |
434 | 454 | | |
435 | 455 | | |
| |||
0 commit comments