facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

Remove `process` shim #323

Closed mnpenner closed 3 years ago

mnpenner commented 4 years ago

If you look in https://unpkg.com/prop-types@15.7.2/prop-types.js, there's a shim for the process var:

// shim for using process in browser
var process = module.exports = {};

I'm pretty sure this is causing a conflict with my code. Can you remove the shim or at least change it to check if it's already been set?

ljharb commented 4 years ago

Why would it? That variable is being set inside an IIFE, which shouldn't conflict with anything outside of that bundle. (and for what it's worth, this is just coming from https://unpkg.com/browse/process@0.11.10/browser.js, which is the process shim that almost every bundler uses)

What's the conflict you think it's causing?

ljharb commented 3 years ago

https://blog.sindresorhus.com/webpack-5-headache-b6ac24973bf1 may be relevant.

Node module bundlers that don't automatically bundle node builtins whenever possible are broken; if you use one of these, you'll need to fix your bundler config (in webpack 5, you can use ProvidePlugin to unbreak things, for example).

mnpenner commented 3 years ago

I see now. I thought it was a global because it wasn't indented. I think you're right, this was probably a webpack 5 issue.