ampproject / ampproject/rollup-plugin-closure-compiler

Allow named imports with names `Storage`, `Plugin` and more.

Open
#92 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
293
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Closure throws an error if it sees a class named `Storage` or `Plugin`.

e.g.: https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Aclass%2520Plugin%257B%257D

This might be fine as one can argue that it is a reserved word. But if these classes are a part of my imports and not global definitions, it should be a clear indication that we can safely mangle this.

## What's the issue?

Closure throws error.

## How do we reproduce the issue?
file-A:
```
export class Plugin {
}
```

file-B:
```
import {Plugin} from './file-A`
const p = new Plugin();
```

Run ☝️ this, with rollup-plugin-closure-compiler.

Contributor guide

Open the contributing guide

Research direction

Start with the file-A and file-B reproduction and run it through rollup-plugin-closure-compiler. Trace how imported names such as Plugin and Storage are handled during compilation, then verify that the reproduction completes without the reported error while preserving the import behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rollup, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.