google / google/closure-compiler
--replace_strings does not understand goog.module names
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Given this code:
```javascript
// err.js
goog.module('example.Err');
class Err extends Error {}
exports = Err;
// thrower.js
goog.module('example.thrower');
const Err = goog.require('example.Err');
function throwErr() {
throw new Err('please replace me');
}
```
String replacement does not occur when compiling with `--replace_strings='example.Err(?)'`.
It does occur when compiling with `--replace_strings='Err(?)'`.
Just using the short name is not a great solution, since short names can conflict, and module names can be shortened differently, across different modules in the compilation unit.
The same issue exists with `goog.scope`, but then at least you can simply avoid scoping the error type. With `goog.module`, the namespace must be removed, so there is no way to specify that a string replacement should be applied to a certain error type.
Contributor guide
Assessment
This issue has not been assessed yet.