Skip to content

Commit

Permalink
improve require docs
Browse files Browse the repository at this point in the history
- describe critical dependency warning
  • Loading branch information
vankop committed Jun 22, 2022
1 parent 02e4d73 commit 7b815ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/content/api/module-methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,13 @@ __webpack_modules__[require.resolveWeak(`./page/${page}`)];
```

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.

If the module source contains a require that cannot be statically analyzed, critical dependencies warning is emitted.

Example code:

```javascript
someFn(require);
require.bind(null);
require(variable);
```

0 comments on commit 7b815ef

Please sign in to comment.