crelte 0.5.6 → 0.5.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,MAAM,EAMN,MAAM,MAAM,CAAC;AAwId,MAAM,MAAM,aAAa,GAAG;IAC3B,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAyK3D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,MAAM,EAMN,MAAM,MAAM,CAAC;AA8Id,MAAM,MAAM,aAAa,GAAG;IAC3B,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAyK3D"}
@@ -22,16 +22,21 @@ function usedSsrComponents(code, id, options, svelte5) {
22
22
  const file = relative('.', id);
23
23
  let idx;
24
24
  if (svelte5) {
25
- // this will not catch all cases, but it should be enough
26
- // since almost all components will have props
27
- const initFnSign = '($$renderer, $$props) {';
28
- idx = code.indexOf(initFnSign);
25
+ const defFnSign = 'export default function ';
26
+ idx = code.indexOf(defFnSign);
29
27
  if (idx < 0)
30
28
  return;
31
- const renderCompSign = '$$renderer.component(($$renderer) => {';
32
- idx = code.indexOf(renderCompSign, idx);
33
- if (idx < 0)
29
+ const withPropsIdx = code.indexOf('($$renderer, $$props) {', idx);
30
+ const noPropsIdx = code.indexOf('($$renderer) {', idx);
31
+ idx = withPropsIdx >= 0 ? withPropsIdx : noPropsIdx;
32
+ if (idx < 0) {
33
+ console.error('could not find svelte5 init', id);
34
34
  return;
35
+ }
36
+ const renderCompSign = '$$renderer.component(($$renderer) => {';
37
+ const renderCompIdx = code.indexOf(renderCompSign, idx);
38
+ if (renderCompIdx >= 0)
39
+ idx = renderCompIdx;
35
40
  // Find the end of the line where the pattern was found
36
41
  idx = code.indexOf('\n', idx);
37
42
  if (idx < 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crelte",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "author": "Crelte <support@crelte.com>",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/vite/index.ts CHANGED
@@ -48,15 +48,21 @@ function usedSsrComponents(
48
48
 
49
49
  let idx;
50
50
  if (svelte5) {
51
- // this will not catch all cases, but it should be enough
52
- // since almost all components will have props
53
- const initFnSign = '($$renderer, $$props) {';
54
- idx = code.indexOf(initFnSign);
51
+ const defFnSign = 'export default function ';
52
+ idx = code.indexOf(defFnSign);
55
53
  if (idx < 0) return;
56
54
 
55
+ const withPropsIdx = code.indexOf('($$renderer, $$props) {', idx);
56
+ const noPropsIdx = code.indexOf('($$renderer) {', idx);
57
+ idx = withPropsIdx >= 0 ? withPropsIdx : noPropsIdx;
58
+ if (idx < 0) {
59
+ console.error('could not find svelte5 init', id);
60
+ return;
61
+ }
62
+
57
63
  const renderCompSign = '$$renderer.component(($$renderer) => {';
58
- idx = code.indexOf(renderCompSign, idx);
59
- if (idx < 0) return;
64
+ const renderCompIdx = code.indexOf(renderCompSign, idx);
65
+ if (renderCompIdx >= 0) idx = renderCompIdx;
60
66
 
61
67
  // Find the end of the line where the pattern was found
62
68
  idx = code.indexOf('\n', idx);