@wuchale/svelte 0.16.4 → 0.16.5

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.
@@ -23,6 +23,7 @@ export declare class SvelteTransformer extends Transformer {
23
23
  visitText: (node: AST.Text) => Message[];
24
24
  visitSpreadAttribute: (node: AST.SpreadAttribute) => Message[];
25
25
  visitAttribute: (node: AST.Attribute) => Message[];
26
+ visitConstTag: (node: AST.ConstTag) => Message[];
26
27
  visitSnippetBlock: (node: AST.SnippetBlock) => Message[];
27
28
  visitIfBlock: (node: AST.IfBlock) => Message[];
28
29
  visitEachBlock: (node: AST.EachBlock) => Message[];
@@ -34,7 +34,11 @@ export class SvelteTransformer extends Transformer {
34
34
  }
35
35
  return true;
36
36
  });
37
- if (needsWrapping) {
37
+ if (!needsWrapping) {
38
+ return msgs;
39
+ }
40
+ const isExported = this.moduleExportRanges.some(([start, end]) => node.init.start >= start && node.init.end <= end);
41
+ if (!isExported) {
38
42
  this.mstr.appendLeft(node.init.start, '$derived(');
39
43
  this.mstr.appendRight(node.init.end, ')');
40
44
  }
@@ -46,6 +50,7 @@ export class SvelteTransformer extends Transformer {
46
50
  getRange: node => ({ start: node.start, end: node.end }),
47
51
  isText: node => node.type === 'Text',
48
52
  isComment: node => node.type === 'Comment',
53
+ leaveInPlace: node => node.type === 'ConstTag',
49
54
  isExpression: node => node.type === 'ExpressionTag',
50
55
  getTextContent: (node) => node.data,
51
56
  getCommentData: (node) => node.data,
@@ -166,6 +171,10 @@ export class SvelteTransformer extends Transformer {
166
171
  }
167
172
  return [msgInfo];
168
173
  };
174
+ visitConstTag = (node) => {
175
+ // @ts-expect-error
176
+ return this.visitVariableDeclaration(node.declaration);
177
+ };
169
178
  visitSnippetBlock = (node) => {
170
179
  // use module runtime var because the snippet may be exported from the module
171
180
  const prevRtVar = this.currentRtVar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/svelte",
3
- "version": "0.16.4",
3
+ "version": "0.16.5",
4
4
  "description": "Protobuf-like i18n from plain code: Svelte adapter",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -52,7 +52,7 @@
52
52
  "license": "MIT",
53
53
  "dependencies": {
54
54
  "svelte": "^5.37.0",
55
- "wuchale": "^0.17.1"
55
+ "wuchale": "^0.17.4"
56
56
  },
57
57
  "devDependencies": {
58
58
  "acorn": "^8.15.0",