forked from rollup/rollup
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tree-shakes side effect free string methods on template literals (rol…
- Loading branch information
1 parent
1722594
commit 7b4c552
Showing
6 changed files
with
64 additions
and
6 deletions.
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
3 changes: 3 additions & 0 deletions
3
test/form/samples/builtin-prototypes/template-literal/_config.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,3 @@ | ||
module.exports = { | ||
description: 'Tree-shake known string template literal prototype functions' | ||
}; |
8 changes: 8 additions & 0 deletions
8
test/form/samples/builtin-prototypes/template-literal/_expected.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,8 @@ | ||
// deep property access is forbidden | ||
`ab`.x.y; | ||
|
||
// due to strict mode, extension is forbidden | ||
`ab`.x = 1; | ||
|
||
// throws when called | ||
`ab`(); |
15 changes: 15 additions & 0 deletions
15
test/form/samples/builtin-prototypes/template-literal/main.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,15 @@ | ||
`ab`.trim(); | ||
`ab`.trim().trim(); | ||
`ab`.toString().trim(); | ||
|
||
// property access is allowed | ||
const accessString = `ab`.x; | ||
|
||
// deep property access is forbidden | ||
const deepString = `ab`.x.y; | ||
|
||
// due to strict mode, extension is forbidden | ||
`ab`.x = 1; | ||
|
||
// throws when called | ||
`ab`(); |