-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Checks for existence of process before process.env for esm build #2409
Conversation
@lukejacksonn Thanks for extracting this PR 👍 I checked how React handles this problem and they use I'm a bit worried that we inventing new solutions to a known problem so I would prefer to copy solution that other libraries use for supporting |
I am having to roll my own react at the moment (see https://github.com/lukejacksonn/es-react) which used to be created from the umd build which will have had anything to do with I'm not an expert in this kind of thing.. partially why I do bundle-less 😅 I just had a snoop around react/redux/vue for similar issue and found these relatable:
Looking further I found this reduxjs/redux#3143 was merged (confirming my initial suspicion) which hints that we are going to need something like
Is the intention that the |
@lukejacksonn Thanks for the research 👍 But more importantly, it's not a long term solution since this check was added for a reason: we had a lot of issues from devs who were using duplicated instances of Also, we have a bunch of So here is my proposal for long term plan: What do you think? P.S. Just to clarify my motives: I think That said Deno also has the same problem of not having |
Hey Ivan, I have been on vacation the past week. Just catching up on GitHub notifications now..
Yes, I presumed that that might be the blocker here. That considered, your proposal makes sense.. In the meantime (given that all the other esm compatibility issues have been resolved) one could make this work in the browser by creating a global variable
When I get a moment I will give this a go and see what happens! |
@lukejacksonn Thanks for understanding 👍 I maintain a few projects that have frontend code and I constantly struggling with updating Webpack or one of its numerous plugins.
It would be useful for everyone else searching for a temporary solution. |
Thank you @IvanGoncharov for all your hard work.. people like you are truly an inspiration! Very happy to have you on board the cause 🚂 you have been exceptionally responsive here which I am very grateful for. Will keep you posted on the workaround! |
The following workaround works fine on Chrome: <script>
window.process = globalThis.process = {
env: {
NODE_ENV: "development"
}
};
</script> My use-case is a custom GraphiQL fetcher, which works quite nicely with tools like unpkg.com.
|
i think that makes sense @IvanGoncharov ? |
I created #3501 |
Related to #2277 specifically 8e7cc02. The last thing required to make this package run in the browser without bundling.
This change will make
instanceOf
choose production mode if:process
doesn't exist)NODE_ENV === 'production'
I do not know if there is a more webpack specific check required. That is:
instanceOf
but whereNODE_ENV !== 'production'
.