-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] ReferenceError: process is not defined #836
Comments
@matandro Thanks for the report. I suspect that your bundling environment is only configured to handle diff --git a/packages/grid/_modules_/grid/constants/envConstants.ts b/packages/grid/_modules_/grid/constants/envConstants.ts
index b15fb77..165492d 100644
--- a/packages/grid/_modules_/grid/constants/envConstants.ts
+++ b/packages/grid/_modules_/grid/constants/envConstants.ts
@@ -18,15 +18,16 @@ import { localStorageAvailable } from '../utils/utils';
// Developers (users) are discouraged to enable the experimental feature by setting the EXPERIMENTAL_ENABLED env.
// Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
-let experimentalEnabled;
+let experimentalEnabled = false;
if (
+ typeof process !== 'undefined' &&
process.env.EXPERIMENTAL_ENABLED !== undefined &&
localStorageAvailable() &&
window.localStorage.getItem('EXPERIMENTAL_ENABLED')
) {
experimentalEnabled = window.localStorage.getItem('EXPERIMENTAL_ENABLED') === 'true';
-} else {
+} else if (typeof process !== 'undefined') {
experimentalEnabled = process.env.EXPERIMENTAL_ENABLED === 'true';
} |
I will try to implement a small test case. For now I was reading about this issue (seems to be common).
const webpack = require('webpack');
module.export = {
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
// ... rest of the module
} See more at https://webpack.js.org/migrate/5/ |
@matandro Awesome great, it seems to confirm that the proposed diff would cover your problem. |
I have this issue too. I'm using Even when I define Looking at my build output I see the following two references (the only references in the whole project!) to
I'm assuming this is because the
The bundler you are using to produce Hence, users' bundlers replace This doesn't seem to happen with I don't think @oliviertassinari's suggested diff will fix the issue because the After doing so much research into this issue, I agree with @matandro it would probably be better to do away with this flag in general, and hide experimental features behind another version tag instead. That way, developers who want experimental features can get them simply by checking out a different branch or version, and you can avoid issues related to bundlers' syntax transform rules entirely. Or if you can figure out a way to rewrite Either way, this bug makes the library completely unusable for me since I don't have a readily-available Provider plugin for esbuild to polyfill @oliviertassinari Bless the work you did, this library is still pretty great. |
@leontastic Thanks for looking into it. Under https://unpkg.com/@material-ui/data-grid@4.0.0-alpha.19/dist/index-esm.js I see: let ta;
ta = void 0 !== process.env.EXPERIMENTAL_ENABLED && Wt() &&
window.localStorage.getItem("EXPERIMENTAL_ENABLED")
? "true" === window.localStorage.getItem("EXPERIMENTAL_ENABLED")
: "true" === process.env.EXPERIMENTAL_ENABLED; I'm pretty sure that the proposed fix would work. However, we could try it out with a pull request, and test it instantly with codesandbox-ci before merging. Do you want to give it a try? :) |
I've tried every workaround I've found--using ProvidePlugin and other ways to make
This also does not seem to be true for me. I've tried every Alpha version down to 9 and they still error out. Is there a reason we're going against Webpacks own advice not to use
|
@oliviertassinari I put your diff into a PR so you can try: #1027
A full-text search of the entire project reveals that this flag is not even being used! Personally I would remove this flag. If that's not an option, I would set it to a string so that the bundler doesn't split up the |
Alternative PR removing this file (should cause 0 difference since the flag isn't being used anyway): #1028 Consider merging this PR in and re-adding an experimental flag when you actually introduce experimental features to hide. This way you can test both the experimental feature and the correctness of this flag end-to-end instead of needing to reason with the code. |
@oliviertassinari I tested both PRs from codesandbox and they both work – No more I don't know if the actual flag will work though because Which PR you merge is up to you! Thanks for your hard work. |
@leontastic perfect 👌 |
I could not reproduce the error with codesandbox even with the same package version. The same code runs smooth on alpha.8. I am not sure what is the exact version where it breaks.
Code is built using webpack with babel.
I receive an
index-esm.js?:formatted:2044 Uncaught ReferenceError: process is not defined Error
that is targeted tonode_modules/@material-ui/x-grid/dist/index-esm.js
. The error line is:`Relevant packges list:
EDIT:
I checked each version and the error pops up in alpha 11 (up to alpha 10 I don't see the error)
The text was updated successfully, but these errors were encountered: