I am receiving the following error in Webpack v5 after migrating from v4. I am able to compile my build properly, but performance issue occurs.
Uncaught ReferenceError: process is not defined
Upon checking the documentation it is advised that:
- webpack 5 does no longer include a polyfill for this Node.js variable. Avoid using it in the frontend code.
- Want to support frontend and browser usage? Use the exports or imports package.json field to use different code depending on the environment.
- Also use the browser field to support older bundlers,.
- Alternative: Wrap code blocks with the typeof process checks. Note that this will have a negative impact on the bundle size.
I wish to support frontend and browser usage. What does "use the exports or imports package.json field to use different code depending on the environment" mean?