-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
I'm submitting a bug report
Webpack version:
2.1.0-beta.21
Please tell us about your environment:
Linux
Current behavior:
I have a class named Car in the file car.ts and two other classes for the engines in another file engine.ts.
car.ts
import { V8Engine, Engine } from './engine';
class SportsCar {
constructor(private engine: Engine) {}
toString() {
return this.engine.toString() + ' Sports Car';
}
}
engine.ts
export interface Engine {
toString(): string;
}
export class V6Engine implements Engine {
toString() {
return 'V6';
}
}
export class V8Engine implements Engine {
toString() {
return 'V8';
}
}
export function getVersion() {
return '1.0';
}
console.log(new SportsCar(new V8Engine()).toString());
The car.ts file only imports the V8Engine class, but the V6Engine class also appears even in the minified file. The unused function i export from engine.ts is stripped.
When running Webpack without UglifyJS plugin, the V6Engine class is marked with /* unused harmony export V6Engine */ as expected.
But after adding the plugin i get this warning message from UglifyJS:
WARNING in car.prod.bundle.js from UglifyJs
Dropping unused function getVersion [car.prod.bundle.js:89,9]
Side effects in initialization of unused variable V6Engine [car.prod.bundle.js:73,132]
I have created a repository where the problem can be reproduced.
Cloning, installing and running npm run webpack and npm run webpack-prod reproduces the issue.
Don't know if this is a bug with the Typescript transpilation, UglifyJS or the orchestration of these tools.
I'm using Typescript with es2015 modules and Webpack 2.
Expected/desired behavior:
The unused class should be removed in the minified file.
- What is the motivation / use case for changing the behavior?
- Browser: all
- Language: TypeScript 2.0-dev