Skip to content
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 "ReferenceError: self is not defined" (#4593) #9243

Closed
wants to merge 1 commit into from

Conversation

NameFILIP
Copy link

@NameFILIP NameFILIP commented Jan 29, 2020

Fixes #4593

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/studio and/or @mapbox/map-design-team if this PR includes style spec or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

@kkaefer
Copy link
Contributor

kkaefer commented Jan 29, 2020

The file src/util/browser/window.js is specifically intended for being used in a browser. There's a non-browser version in src/util/window.js, which is used by default. Instead of altering the browser-only version, modify your setup to avoid directly including the browser-specific version. Some bundlers read the browsers key in our package.json which specifies browser-specific file replacements. If you're building a bundle for use in Node.js, you should ignore these files.

@kkaefer kkaefer closed this Jan 29, 2020
@NameFILIP
Copy link
Author

In my case, I'm building a bundle to be used on the frontend, but the build process is happening in Node.

@kkaefer what is the downside of writing resilient code like this? It'll still work in the browser and in addition, will not crash the node environment (while being imported, not used). Look how many people are complaining about it: #4593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReferenceError: self is not defined
2 participants