-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have rollup emit `let $safeClassName = class $originalClassName { ...…
…` instead of `class $safeClassName { ...`, which changes the runtime behavior when MyClass.name is accessed. Added corresponding tests.
- Loading branch information
Showing
13 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class MyClass { | ||
constructor() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
description: 'class name should not be changed, even if symbol is renamed', | ||
options: { output: { name: 'myBundle' } } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define(['exports'], function (exports) { 'use strict'; | ||
|
||
class MyClass { | ||
constructor() { } | ||
} | ||
|
||
let MyClass$1 = class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass$1.name, "MyClass"); // oops | ||
|
||
exports.MyClass = MyClass$1; | ||
exports.MyClass2 = MyClass; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
class MyClass { | ||
constructor() { } | ||
} | ||
|
||
let MyClass$1 = class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass$1.name, "MyClass"); // oops | ||
|
||
exports.MyClass = MyClass$1; | ||
exports.MyClass2 = MyClass; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class MyClass { | ||
constructor() { } | ||
} | ||
|
||
let MyClass$1 = class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass$1.name, "MyClass"); // oops | ||
|
||
export { MyClass$1 as MyClass, MyClass as MyClass2 }; |
18 changes: 18 additions & 0 deletions
18
test/form/samples/class-name-not-changed/_expected/iife.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var myBundle = (function (exports) { | ||
'use strict'; | ||
|
||
class MyClass { | ||
constructor() { } | ||
} | ||
|
||
let MyClass$1 = class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass$1.name, "MyClass"); // oops | ||
|
||
exports.MyClass = MyClass$1; | ||
exports.MyClass2 = MyClass; | ||
|
||
return exports; | ||
|
||
}({})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.myBundle = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
|
||
class MyClass { | ||
constructor() { } | ||
} | ||
|
||
let MyClass$1 = class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass$1.name, "MyClass"); // oops | ||
|
||
exports.MyClass = MyClass$1; | ||
exports.MyClass2 = MyClass; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass.name, "MyClass") // oops | ||
export { MyClass as MyClass2 } from "./MyClass" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class MyClass { | ||
constructor() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'class name should not be changed, even if symbol is renamed' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class MyClass { | ||
constructor() { } | ||
} | ||
assert.equal(MyClass.name, "MyClass") // oops | ||
export { MyClass as MyClass2 } from "./MyClass" |