-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Respect
pure_funcs
for tagged tpls (#8280)
**Related issue:** - Closes #8275.
- Loading branch information
Showing
5 changed files
with
115 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"target": "es2022", | ||
"loose": false, | ||
"minify": { | ||
"compress": { | ||
"pure_funcs": [ | ||
"pure_html" | ||
] | ||
}, | ||
"mangle": false | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"isModule": 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 @@ | ||
/*#__PURE__*/ | ||
function pure_html(strings, ...values) { | ||
return { strings, values }; | ||
} | ||
|
||
// ✅ This is tree-shaken from the minified output. | ||
const a = `<span>aaaa</span>`; | ||
|
||
// ❌ This is not tree-shaken from the minified output, | ||
// despite the "html" function being declare using | ||
// `jsc.minify.compress.pure_funcs` configuration. | ||
const b = pure_html`<span>bbbb</span>`; | ||
|
||
// ✅ This is not tree-shaken from the minified output. | ||
export const c = pure_html`<span>cccc</span>`; |
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,6 @@ | ||
export const c = (function(strings, ...values) { | ||
return { | ||
strings, | ||
values | ||
}; | ||
})`<span>cccc</span>`; |
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