zaydek / retro-legacy

[WIP] Your friendly neighborhood React static-site generator
MIT License
2 stars 0 forks source link

[Todo] What about __BROWSER__ and __NODE__ env variables? #38

Closed zaydek closed 3 years ago

zaydek commented 3 years ago

See https://github.com/rtsao/create-universal-package.

process.title; // fails `cup/no-undef`
window.location; // fails `cup/no-undef`

// passes lint
if (__BROWSER__) {
  document.body.appendChild(document.createTextNode('hello world'));
}

// passes lint
if (__NODE__) {
  process.stdout.write('hello world');
}

// passes lint
const topLevel = __BROWSER__ ? window : global;

Not sure this actually makes sense.

zaydek commented 3 years ago

So technically we don’t actually run app code on the server; we only bundle it on the sever which can emit static warnings and errors but not runtime errors. This means this code is probably only useful for loaders, but even that is designed to be strictly sever-only, so I don’t think this API makes a lot of sense. Closing for now.