Skip to content

feat: transformCss no longer inits lightningcss#25

Open
jptaranto wants to merge 1 commit intobalintbrews:mainfrom
jptaranto:lightningcss-init-split
Open

feat: transformCss no longer inits lightningcss#25
jptaranto wants to merge 1 commit intobalintbrews:mainfrom
jptaranto:lightningcss-init-split

Conversation

@jptaranto
Copy link
Copy Markdown

BREAKING CHANGE: lightningcss must be loaded manually if you are not using buildCss.

BREAKING CHANGE: lightningcss must be loaded manually if you are not using buildCss.
Comment thread tsup.config.ts
// Get the version of the `lightningcss-wasm` package. It will be added to the
// bundled WASM file's filename in the `tsup` config below (`esbuildOptions` →
// `assetNames`).
const lightningCssWasmVersion = await (async (): Promise<string> => {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to get the import working when the wasm file had a version number in it, so I removed it.

Comment thread tsup.config.ts
// CAVEAT: The `banner` option can add an arbitrary to string to all
// generated JS and CSS files, but there is no way to limit it to only the
// `index.js` file. What's lucky is that it's the only generated JS file.
js: `import './lightningcss_node-${lightningCssWasmVersion}.wasm?url';`,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this isn't necessary anymore but I might be wrong. The buildCss function thats output in dist/index.js correctly references the output dist/lightningcss_node.wasm file.

Comment thread src/transform-css.ts
css: string,
{ minify = true }: TransformCssOptions = {},
): Promise<string> {
await lightningCssInit(new URL(lightningCssWasm, import.meta.url).href);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moved into buildCss - so hopefully the API is unaffected, but we can manually init ourselves now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant