Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jayphelps/gatsby-dev-ssr-issue
https://github.com/jayphelps/gatsby-dev-ssr-issue
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jayphelps/gatsby-dev-ssr-issue
- Owner: jayphelps
- Created: 2021-03-01T17:09:04.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-01T17:39:53.000Z (almost 4 years ago)
- Last Synced: 2024-10-19T17:58:33.116Z (3 months ago)
- Language: JavaScript
- Size: 353 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Reproducing in Gatsby app
```shell
npm install
npm run develop
```To reproduce the issue, edit this [src/pages/index.js](src/pages/index.js) component, then do a full page refresh.
## Source code for @jayphelps/fake-package
```js
if (globalThis.fakePackageHasBeenImported) {
throw new Error(
'globalThis.fakePackageHasBeenImported has already been set to true, meaning this module has been duplicated and evaluated more than once within the same JS isolate.',
);
}globalThis.fakePackageHasBeenImported = true;
```## Comparison of Next.js behavior
```shell
cd nextjs-app
npm install
npm run dev
```Because it's helpful to see what others in the community have already done about this problem, I've included a Next.js app that does the same thing, but where the problem does not happen because it only evaluates node_modules once; it does not duplicate them.
Note, however, the problem does happen if your own Next.js app's code has global state, like it does in Gatsby too. That's a much harder problem to solve, and not an issue for me personally right now, just mentioning for clarity.