Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need tree-shaking import for the enableStaticRendering() function #4520

Open
heath-freenome opened this issue Feb 11, 2025 · 0 comments
Open
Labels

Comments

@heath-freenome
Copy link

I am using NextJS and am calling the enableStaticRendering() function on the server. I currently have to import the function as follows:

import { enableStaticRendering } from 'mobx-react';

Due to the way NextJS deals with imports while building their production mode, I am getting the following warnings:

./node_modules/scheduler/cjs/scheduler.production.min.js
A Node.js API is used (setImmediate at line: 11) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/scheduler/cjs/scheduler.production.min.js
./node_modules/scheduler/index.js
./node_modules/react-dom/cjs/react-dom.production.min.js
./node_modules/react-dom/index.js
./node_modules/mobx-react-lite/es/utils/reactBatchedUpdates.js
./node_modules/mobx-react-lite/es/index.js
./node_modules/mobx-react/dist/mobxreact.esm.js
./node_modules/@freenome/nextjs/esm/containers/ClientPageContainer/index.js
./node_modules/@freenome/nextjs/esm/index.js

./node_modules/scheduler/cjs/scheduler.production.min.js
A Node.js API is used (setImmediate at line: 11) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/scheduler/cjs/scheduler.production.min.js
./node_modules/scheduler/index.js
./node_modules/react-dom/cjs/react-dom.production.min.js
./node_modules/react-dom/index.js
./node_modules/mobx-react-lite/es/utils/reactBatchedUpdates.js
./node_modules/mobx-react-lite/es/index.js
./node_modules/mobx-react/dist/mobxreact.esm.js
./node_modules/@freenome/nextjs/esm/containers/ClientPageContainer/index.js
./node_modules/@freenome/nextjs/esm/index.js

Actual outcome:

When I do try to import directly from the source file to avoid the error like in this screenshot, I get typescript issues:

Image

How to reproduce the issue:

I'm imagining, since there are so few static rendering functions in mobx-react-lite that if one were to update the package.json to add the exports section to provide a named export for the static rendering functions in then I could do what I needed. I am fairly confident that this change can be easily done in a backwards-compatible manner meaning that I could also import enableStaticRendering from the mob-react-lite as before.

Given that, I really can't provide an easily reproducible case for you unless you want me to link an entire nextjs application that is importing and using this function.

Versions
"mobx": "6.13.6",
"mobx-react": "9.2.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant