Skip to content

Commit 50bb3d1

Browse files
committed
Improve and logs
1 parent 6a9e85e commit 50bb3d1

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

packages/bundle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"scripts": {
4848
"build": "npm run build:tsdown",
49-
"build:tsdown": "tsdown --config ./tsdown.config.ts",
49+
"build:tsdown": "RUST_BACKTRACE=1 NODE_OPTIONS=--max-old-space-size=8192 tsdown --config ./tsdown.config.ts",
5050
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
5151
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
5252
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",

packages/unplugin-lightningcss/src/core/transform.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,23 @@ export async function transformCssModule(
4242
const compiledId = actualId
4343
.replaceAll('\\', '/')
4444
.replace(/\.module\.css$/, '.module_built.css')
45+
46+
const classes = Object.fromEntries(
47+
Object.entries(res.exports ?? {}).map(([key, value]) => [key, value.name]),
48+
)
49+
let exports = `const classes = ${JSON.stringify(classes)}\nexport default classes\n`
50+
const i = 0
51+
for (const key of Object.keys(classes)) {
52+
const sanitizedKey = `_${key.replaceAll(/\W/g, '_')}${i}`
53+
exports +=
54+
`\nconst ${sanitizedKey} = classes[${JSON.stringify(key)}]\n` +
55+
`export { ${sanitizedKey} as ${JSON.stringify(key)} }\n`
56+
}
57+
4558
return {
4659
code: res.code.toString(),
4760
map: 'map' in res ? res.map?.toString() : undefined,
4861
id: compiledId,
49-
exports: res.exports
50-
? `export default ${JSON.stringify(res.exports)}`
51-
: '',
62+
exports,
5263
}
5364
}

0 commit comments

Comments
 (0)