-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix(table-core): Avoid process not defined in environments not setting a process variable #5373
base: main
Are you sure you want to change the base?
Conversation
What environments do that? |
I have a situation where we are bundling Tanstack into a library component, then distributing the component as a standalone package that can be loaded directly in an html page. In this scenario, there is no process variable defined and the tanstack library fails. |
Are you sure that you're not accidentally importing from Also, maybe try importing from the |
I'm importing the Tanstack library into my project's component like this:
There wouldn't be a way to just import the pieces I need using the umd, would there? I'm also curious what the harm would be in detecting the process variable in the library before calling it? |
I have just never seen any other NPM library ever have to do this, so I think there should be a better way. |
I hit this trying to use tanstack table in Greenwood |
Hey, stumbled across this with @lschierer and did a little digging and have some observations to share if it helps 👋
browser / client environments, no bundle development workflows, etc.
Tools following NodeJS exports spec looking for ESM files would look to the In package.json both the
(Curious, is there any reason
It's worth noting that the reason most NPM libraries don't guard against this is because most people "erase" it away through their build tools. For instance, you can see that happening in this project in its examples and own build step
An alternative to guarding would be that for client side / browser / UI libraries don't include any non web standard (e.g. NodeJS APIs) Not the biggest deal, but hopefully it's helpful information either way. 👍 |
When running the library in an environment that is not setting the process variable, the library throws a not defined error and breaks the render. This change checks to see if the variable exists before attempting to read it to avoid this.