question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make RescopeGlobalSymbols usable in a node environment

See original GitHub issue

I’m using the RescopeGlobalSymbols compiler pass via the options.setRenamePrefixNamespace compiler option in shadow-cljs. This works great for Browser-targetted builds but node.js targetted builds break since the compiler is rewriting all of the node “specials”.

module.exports -> window.module.exports
require("foo") ->  (0,window.require)("foo")
global -> window.global

This could be fixed by either making SPECIAL_EXTERNS configurable or just including the node-specific globals by default.

https://github.com/google/closure-compiler/blob/4c97e69df965da4179b639ea3ee2020c98cc3621/src/com/google/javascript/jscomp/RescopeGlobalSymbols.java#L60-L82

Happy to open a PR for this just wanted to check in first about the preferred way.

The added externs would be global, process, require, module, exports, __filename, __dirname.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
brad4dcommented, Nov 19, 2018

@thheller I think your suggestion is a reasonable one, but I’m not personally familiar with this pass, so I could be wrong.

We’re unlikely to work directly on this ourselves anytime soon, but if you’re willing to create a PR we can review it and merge it if it seems safe to do so.

0reactions
thhellercommented, Mar 24, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >
Setting up a Node development environment - MDN Web Docs
You now have a Node development environment up and running on your computer that can be used for creating Express web applications.
Read more >
Setting Environment Variables for Node to retrieve
process.env.TEST is now usable in node. Env-files are a good way of keeping api-keys out of your codebase. B) Use Powershell - this...
Read more >
How to (easily) set up Node environment variables in your JS ...
Step 1: .gitignore. We're going to add the variables to a file we make called simply .env , but before we do, let's...
Read more >
How To Create a Node.js Module - DigitalOcean
You will need Node.js and npm installed on your development environment. This tutorial uses version 10.17.0. To install this on macOS or Ubuntu ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found