-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swc_ecma_minifier support charset option #9515
Comments
This could be expected with default target Es5. swc/crates/swc_ecma_codegen/src/tests.rs Line 635 in 62ed065
|
The expected behavior should be to display the characters directly instead of Unicode encoding, because in some engines, multi-byte encoding cannot be handled and only characters can be used. And the strange thing is that only some characters seem to be converted to unicode codes. These three are characters from the same font.
|
utf8 seems to take up less file size than unicode const fs = require('fs')
// const a = "🌏"; // 🌏 or
const a = ""; // 🌏 or
const encoder = new TextEncoder();
function getUnicodeEncoding(char) {
const unicodeArray = [];
for (let i = 0; i < char.length; i++) {
const codePoint = char.charCodeAt(i).toString(16).toUpperCase();
unicodeArray.push(`\\u${codePoint.padStart(4, "0")}`);
}
return unicodeArray.join('');
}
const n = 1024
fs.writeFileSync("./utf8.js", `"${a.repeat(n)}"`)
fs.writeFileSync("./unicode.js", `"${getUnicodeEncoding(a).repeat(n)}"`) Both single-byte and double-byte characters in utf8 encoding take up less space than unicode
|
Describe the feature
For nerd fonts characters, convert them to Unicode by default. It is expected that there will be an option similar to esbuild charset
esbuild
Babel plugin or link to the feature description
No response
Additional context
web-infra-dev/rspack#7734
https://play.swc.rs/?version=1.7.21&code=H4sIAAAAAAAAA0vOzyvOz0nVy8lP11BKVNJRUPq8oXsWiH62tfvF%2BqlKmtYA2egJaCMAAAA%3D&config=H4sIAAAAAAAAA42VzW7bMAyA732KwOcetsOAYg%2FQ1xAUiXKUyaIg0m6Mou8%2B2nHSZKaNXRybH38k%2FuXz5XBozuSa34dPeZWPYitBvX%2BLhMbM9iKSBlxnydVYuHm90TNNKNhEMIu%2BrqRhW1vg2Yp%2BLepNQiS4qS%2ByLuYYxseAnc1tggfJ5A5LggHSs%2FGM%2FgAU45IlyrYD2tIIu7TUOFgG%2BcWiKUV4U6Rkg63x54%2BnDNxzIAoOu1KB6Pkykpq%2Bg8xaIFsrfkyAa%2F8oPyImsHmHGEsmZoYWqubYYUq2EJjBVsXLdFK5C6EWYoI9g7%2BnZ8WzjxwxS8w19WC9cehBQbGC4ziAZiaxxCwTJlDuM2MPx75t5379xxoGm3qpqEIuc0nktIrXE0ZiE%2FqspfAKN3JwhUtyV%2B0TTAXua17bnTHmjZr8b2dLP21Z73d9zEGmj0eFy6hqt8zQTmMSY1AyO2UGKketmhV872DKrNOOs%2BCN9FH0YCAE6RXFNX1EdictKI8FMChA6muD1lVXYO5TuMGngdjB73JL1hts0egsn7Ypjd0R006ADviEfkdBSsG4jatsiUvZ5n32IK0BXlXpaQbrJSADwGjSvPdXvSHjIR5Nm%2FD4vSZuG%2FPl9px35%2Fefwqzz9Rc%2BNnjbpwYAAA%3D%3D
The text was updated successfully, but these errors were encountered: