anchor.diff:          name = element.name.slowToString().replaceAll('+', '_');
         }
       } else if (element.isLibrary()) {
  -      name = LIBRARY_PREFIX;
  +      LibraryElement library = element;
  +      name = library.getLibraryOrScriptName();
  +      if (name.contains('.')) {
  +        // For libraries that have a library tag, we use the last part
  +        // of the fully qualified name as their base name. For all other
  +        // libraries, we use the first part of their filename.
  +        name = library.hasLibraryName()
  +            ? name.substring(name.lastIndexOf('.') + 1)
  +            : name.substring(0, name.indexOf('.'));
  +      }
       } else {
         name = element.name.slowToString();
       }
  
positive.code:         ? library
          : shortPrivateNameOwners.putIfAbsent(nameString, () => library);
  
      // If a private name could clash with a mangled private name we don't
      // use the short name. For example a private name "_lib3_foo" would
      // clash with "_foo" from "lib3".
      if (owner == library &&
          !nameString.startsWith('_$LIBRARY_PREFIX') &&
          !shouldMinify) {
        return nameString;
      }
  
      // If a library name does not start with the [LIBRARY_PREFIX] then our
      // assumptions about clashing with mangled private members do not hold.
      String libraryName = getNameOfLibrary(library);
      assert(shouldMinify || libraryName.startsWith(LIBRARY_PREFIX));
      // TODO(erikcorry): Fix this with other manglings to avoid clashes.
      return '_lib$libraryName\$$nameString';
    }
  
    String instanceMethodName(FunctionElement element) {
  
negative.code:   SourceString getClosureVariableName(SourceString name, int id) {
      return new SourceString("${name.slowToString()}_$id");
    }
  
    /**
     * Returns a preferred JS-id for the given top-level or static element.
  