Skip to content

--replace_strings does not understand goog.module names #2756

@domnit

Description

@domnit

Given this code:

// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions