@lls/vitescripts 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lls/vitescripts",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "lls vite plugins",
5
5
  "main": "src/index.mjs",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "dependencies": {
13
- "vite-plugin-require-transform": "1.0.9"
13
+ "lightningcss": "1.21.5"
14
14
  },
15
15
  "type": "module",
16
16
  "author": "",
@@ -4,6 +4,7 @@
4
4
  * resolveId() method that filters files to be added to css set
5
5
  * flushStyles() method that generates and return <style> tag with refreshed style
6
6
  */
7
+ import { transform } from 'lightningcss'
7
8
  const llsLinariaSsrCollectPlugin = () => {
8
9
  const cssIds = new Set()
9
10
  let linariaPlugin
@@ -18,12 +19,12 @@ const llsLinariaSsrCollectPlugin = () => {
18
19
  if (id.includes('@linaria-cache')) { cssIds.add(id) }
19
20
  },
20
21
  flushStyles() {
21
- const back = `<style id="linaria-ssr-collect-plugin">${[...cssIds].map(linariaPlugin.load).join('\n')}</style>`
22
- // linaria plugin keeps cache. But we dont want to keep ids which have changed (updating a css component)
23
- // css is removed from client anyway but still be accurate
24
- cssIds.clear()
22
+ const css = [...cssIds].map(linariaPlugin.load).join('\n')
25
23
 
26
- return back
24
+ // when hmr, id changes but not css-selector so we get two rules with the same css-selector
25
+ // we dedupe the rules so old rule is now stripped.
26
+ const { code } = transform({ code: Buffer.from(css) })
27
+ return `<style id="linaria-ssr-collect-plugin">${code.toString()}</style>`
27
28
  }
28
29
  }
29
30
  }