Skip to content

Commit 089cfa2

Browse files
authored
docs(api): improve require docs (#6235)
- describe critical dependency warning
1 parent 3e4dcec commit 089cfa2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/content/api/module-methods.mdx

+12
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,15 @@ __webpack_modules__[require.resolveWeak(`./page/${page}`)];
433433
```
434434

435435
T> `require.resolveWeak` is the foundation of _universal rendering_ (SSR + Code Splitting), as used in packages such as [react-universal-component](https://github.com/faceyspacey/react-universal-component). It allows code to render synchronously on both the server and initial page-loads on the client. It requires that chunks are manually served or somehow available. It's able to require modules without indicating they should be bundled into a chunk. It's used in conjunction with `import()` which takes over when user navigation triggers additional imports.
436+
437+
### warning
438+
439+
If the module source contains a require that cannot be statically analyzed, critical dependencies warning is emitted.
440+
441+
Example code:
442+
443+
```javascript
444+
someFn(require);
445+
require.bind(null);
446+
require(variable);
447+
```

0 commit comments

Comments
 (0)