vike-ripple 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +12 -4
  2. package/src/setup.js +10 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-ripple",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Vike extension for Ripple TS — full parity with vike-react/vike-solid/vike-vue",
5
5
  "type": "module",
6
6
  "types": "./src/types/Config.ts",
@@ -19,12 +19,20 @@
19
19
  "bin": {
20
20
  "vike-ripple": "./src/setup.js"
21
21
  },
22
- "files": ["src"],
23
- "keywords": ["vike", "ripple", "ripplets", "ssr", "vite"],
22
+ "files": [
23
+ "src"
24
+ ],
25
+ "keywords": [
26
+ "vike",
27
+ "ripple",
28
+ "ripplets",
29
+ "ssr",
30
+ "vite"
31
+ ],
24
32
  "license": "MIT",
25
33
  "peerDependencies": {
26
34
  "vike": ">=0.4.259",
27
35
  "@ripple-ts/vite-plugin": ">=0.3.0",
28
36
  "ripple": ">=0.1.0"
29
37
  }
30
- }
38
+ }
package/src/setup.js CHANGED
@@ -1,16 +1,9 @@
1
- #!/usr/bin/env node
2
- /**
3
- * vike-ripple setup — patches Vike and Ripple for .tsrx support.
4
- *
5
- * Run once: npx vike-ripple setup
6
- * Or add to project's package.json: "postinstall": "vike-ripple setup"
7
- */
8
1
  import { createRequire } from 'module'
9
- import { join, dirname } from 'path'
2
+ import { join } from 'path'
10
3
  import { readFileSync, writeFileSync, existsSync } from 'fs'
11
4
  import { fileURLToPath } from 'url'
12
5
 
13
- const __dirname = dirname(fileURLToPath(import.meta.url))
6
+ const __dirname = fileURLToPath(new URL('.', import.meta.url))
14
7
  const projectRoot = process.cwd()
15
8
  let exitCode = 0
16
9
 
@@ -61,7 +54,7 @@ function patchRippleDirect() {
61
54
  log('Patched Ripple plugin for ?direct CSS module loading')
62
55
  }
63
56
 
64
- // ── Patch 3: @apply support (tailwindcss integration) ──────────
57
+ // ── Patch 3: @apply support via @reference (no HMR loops) ─────
65
58
  function patchRippleApply() {
66
59
  const target = resolveRipple('src/index.js')
67
60
  if (!target) return
@@ -75,13 +68,16 @@ function patchRippleApply() {
75
68
  src = src.replace(
76
69
  '// TW_PATCH: prepend tailwindcss so @apply works',
77
70
  '// TW_PATCH_APPLY: bring tailwindcss into scope for @apply',
71
+ )
72
+ "css = '@import \"tailwindcss\";\\n' + css;",
73
+ "css = '@import \"tailwindcss\" layer(reference);\\n' + css;",
78
74
  )
79
75
  writeFileSync(target, src, 'utf-8')
80
- log('Upgraded @apply patch format')
76
+ log('Upgraded @apply patch to @reference (prevents HMR loops)')
81
77
  return
82
78
  }
83
79
 
84
- // Fresh install — original unpatched code
80
+ // Fresh install — prepend @reference comment + tailwind for HMR safety
85
81
  const orig = (
86
82
  '\t\t\t\t\tif (css) {\n' +
87
83
  '\t\t\t\t\t\tconst cssId = createVirtualImportId(filename, root, \'style\');\n' +
@@ -90,7 +86,7 @@ function patchRippleApply() {
90
86
  const patched = (
91
87
  '\t\t\t\t\tif (css) {\n' +
92
88
  '\t\t\t\t\t\t// TW_PATCH_APPLY: bring tailwindcss into scope for @apply\n' +
93
- "\t\t\t\t\t\tcss = '@import \"tailwindcss\";\\n' + css;\n" +
89
+ "\t\t\t\t\t\tcss = '@import \"tailwindcss\" layer(reference);\\n' + css;\n" +
94
90
  '\t\t\t\t\t\tconst cssId = createVirtualImportId(filename, root, \'style\');\n' +
95
91
  '\t\t\t\t\t\tcssCache.set(cssId, css);'
96
92
  )
@@ -98,7 +94,7 @@ function patchRippleApply() {
98
94
  const result = src.replace(orig, patched)
99
95
  if (result === src) { warn('Could not patch Ripple plugin for @apply'); return }
100
96
  writeFileSync(target, result, 'utf-8')
101
- log('Patched Ripple plugin for @apply support in <style> blocks')
97
+ log('Patched Ripple plugin for @apply support in <style> blocks (HMR-safe)')
102
98
  }
103
99
 
104
100
  // ── Resolve helpers ────────────────────────────────────────────