@canonical/summon-component 0.27.0 → 0.28.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.28.0](https://github.com/canonical/pragma/compare/v0.27.1-experimental.0...v0.28.0) (2026-06-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **summon-component:** Fix Svelte component output failing type-checking ([#642](https://github.com/canonical/pragma/issues/642)) ([1331c96](https://github.com/canonical/pragma/commit/1331c963a5691f20b826bbb8b081ab283bde8584))
12
+
13
+
14
+ ### Features
15
+
16
+ * **pragma:** trace, MCP resources, summon template loading, framework config ([#645](https://github.com/canonical/pragma/issues/645)) ([4f0a341](https://github.com/canonical/pragma/commit/4f0a341a050facbf3a87419ed7a9b3c29c0a9ade)), closes [#1](https://github.com/canonical/pragma/issues/1) [#551](https://github.com/canonical/pragma/issues/551) [#569](https://github.com/canonical/pragma/issues/569) [#641](https://github.com/canonical/pragma/issues/641) [#641](https://github.com/canonical/pragma/issues/641)
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.27.1-experimental.0](https://github.com/canonical/pragma/compare/v0.28.0-experimental.0...v0.27.1-experimental.0) (2026-05-21)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **release:** unblock lerna 9 publish (access via publishConfig) ([#637](https://github.com/canonical/pragma/issues/637)) ([acc1185](https://github.com/canonical/pragma/commit/acc1185b43290c1edd88da25c000f7d9494caee6))
28
+
29
+
30
+
31
+
32
+
6
33
  # [0.27.0](https://github.com/canonical/pragma/compare/v0.26.0...v0.27.0) (2026-04-29)
7
34
 
8
35
  **Note:** Version bump only for package @canonical/summon-component
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/summon-component",
3
3
  "description": "Component generators for Summon - React, Svelte and Lit component scaffolding",
4
- "version": "0.27.0",
4
+ "version": "0.28.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "author": {
@@ -17,6 +17,9 @@
17
17
  "url": "https://github.com/canonical/pragma/issues"
18
18
  },
19
19
  "homepage": "https://github.com/canonical/pragma#readme",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
20
23
  "scripts": {
21
24
  "build": "echo 'No build needed - runs directly from TypeScript'",
22
25
  "build:all": "bun run build",
@@ -32,20 +35,20 @@
32
35
  },
33
36
  "devDependencies": {
34
37
  "@biomejs/biome": "2.4.9",
35
- "@canonical/biome-config": "^0.27.0",
36
- "@canonical/typescript-config": "^0.27.0",
37
- "@canonical/webarchitect": "^0.27.0",
38
+ "@canonical/biome-config": "^0.28.0",
39
+ "@canonical/typescript-config": "^0.28.0",
40
+ "@canonical/webarchitect": "^0.28.0",
38
41
  "@types/bun": "^1.3.10",
39
42
  "@types/node": "^24.12.0",
40
43
  "typescript": "^5.9.3",
41
44
  "vitest": "^4.0.18"
42
45
  },
43
46
  "dependencies": {
44
- "@canonical/utils": "^0.27.0"
47
+ "@canonical/utils": "^0.28.0"
45
48
  },
46
49
  "peerDependencies": {
47
50
  "@canonical/summon-core": "^0.18.0 || ^0.20.0",
48
51
  "@canonical/task": "^0.18.0 || ^0.20.0"
49
52
  },
50
- "gitHead": "5df5709bf7cb6f2016be2f6eba8391637e2e2a0c"
53
+ "gitHead": "8297d72122bcba903f7e8833cb23ccbaa164ed56"
51
54
  }
@@ -30,22 +30,25 @@ import {
30
30
  getComponentName,
31
31
  getParentDir,
32
32
  } from "../shared/index.js";
33
+ import loadTemplate from "../shared/loadTemplate.js";
33
34
  import type { LitAnswers } from "./types.js";
34
35
 
35
36
  // =============================================================================
36
- // Template Paths
37
+ // Template Paths & Content (loaded eagerly via top-level await)
37
38
  // =============================================================================
38
39
 
39
40
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
40
41
  const templatesDir = path.join(__dirname, "..", "templates");
41
42
 
42
43
  const litTemplates = {
43
- component: path.join(templatesDir, "lit", "component.ts.ejs"),
44
- index: path.join(templatesDir, "lit", "index.ts.ejs"),
45
- types: path.join(templatesDir, "lit", "types.ts.ejs"),
46
- tests: path.join(templatesDir, "lit", "tests.ts.ejs"),
47
- stories: path.join(templatesDir, "lit", "stories.ts.ejs"),
48
- styles: path.join(templatesDir, "lit", "styles.css.ejs"),
44
+ component: await loadTemplate(
45
+ path.join(templatesDir, "lit", "component.ts.ejs"),
46
+ ),
47
+ index: await loadTemplate(path.join(templatesDir, "lit", "index.ts.ejs")),
48
+ types: await loadTemplate(path.join(templatesDir, "lit", "types.ts.ejs")),
49
+ tests: await loadTemplate(path.join(templatesDir, "lit", "tests.ts.ejs")),
50
+ stories: await loadTemplate(path.join(templatesDir, "lit", "stories.ts.ejs")),
51
+ styles: await loadTemplate(path.join(templatesDir, "lit", "styles.css.ejs")),
49
52
  };
50
53
 
51
54
  // =============================================================================
@@ -124,28 +127,32 @@ with the custom element tag 'button'.`,
124
127
 
125
128
  debug("Creating main component file"),
126
129
  template({
127
- source: litTemplates.component,
130
+ source: litTemplates.component.source,
131
+ content: litTemplates.component.content,
128
132
  dest: path.join(componentDir, `${componentName}.ts`),
129
133
  vars: ctx,
130
134
  }),
131
135
 
132
136
  debug("Creating index barrel file"),
133
137
  template({
134
- source: litTemplates.index,
138
+ source: litTemplates.index.source,
139
+ content: litTemplates.index.content,
135
140
  dest: path.join(componentDir, "index.ts"),
136
141
  vars: ctx,
137
142
  }),
138
143
 
139
144
  debug("Creating types file"),
140
145
  template({
141
- source: litTemplates.types,
146
+ source: litTemplates.types.source,
147
+ content: litTemplates.types.content,
142
148
  dest: path.join(componentDir, "types.ts"),
143
149
  vars: ctx,
144
150
  }),
145
151
 
146
152
  debug("Creating test file"),
147
153
  template({
148
- source: litTemplates.tests,
154
+ source: litTemplates.tests.source,
155
+ content: litTemplates.tests.content,
149
156
  dest: path.join(componentDir, `${componentName}.tests.ts`),
150
157
  vars: ctx,
151
158
  }),
@@ -154,7 +161,8 @@ with the custom element tag 'button'.`,
154
161
  when(
155
162
  answers.withStories,
156
163
  template({
157
- source: litTemplates.stories,
164
+ source: litTemplates.stories.source,
165
+ content: litTemplates.stories.content,
158
166
  dest: path.join(componentDir, `${componentName}.stories.ts`),
159
167
  vars: ctx,
160
168
  }),
@@ -164,7 +172,8 @@ with the custom element tag 'button'.`,
164
172
  when(
165
173
  answers.withStyles,
166
174
  template({
167
- source: litTemplates.styles,
175
+ source: litTemplates.styles.source,
176
+ content: litTemplates.styles.content,
168
177
  dest: path.join(componentDir, "styles.css"),
169
178
  vars: ctx,
170
179
  }),
@@ -10,12 +10,6 @@
10
10
  * - `ComponentName.stories.tsx` - Storybook stories (optional)
11
11
  * - `styles.css` - CSS styles (optional)
12
12
  *
13
- * @example
14
- * ```bash
15
- * summon component react --component-path=src/components/Button
16
- * summon component react --component-path=src/components/Card --with-styles --with-stories
17
- * ```
18
- *
19
13
  * @module
20
14
  */
21
15
 
@@ -33,37 +27,38 @@ import {
33
27
  getParentDir,
34
28
  sharedPrompts,
35
29
  } from "../shared/index.js";
30
+ import loadTemplate from "../shared/loadTemplate.js";
36
31
  import type { ReactComponentAnswers } from "./types.js";
37
32
 
38
33
  // =============================================================================
39
- // Template Paths
34
+ // Template Paths & Content (loaded eagerly via top-level await)
40
35
  // =============================================================================
41
36
 
42
37
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
43
38
  const templatesDir = path.join(__dirname, "..", "templates");
44
39
 
45
40
  const reactTemplates = {
46
- component: path.join(templatesDir, "react", "component.tsx.ejs"),
47
- types: path.join(templatesDir, "react", "types.ts.ejs"),
48
- index: path.join(templatesDir, "react", "index.ts.ejs"),
49
- test: path.join(templatesDir, "react", "test.tsx.ejs"),
50
- ssrTest: path.join(templatesDir, "react", "ssr.test.tsx.ejs"),
51
- stories: path.join(templatesDir, "react", "stories.tsx.ejs"),
52
- styles: path.join(templatesDir, "shared", "styles.css.ejs"),
41
+ component: await loadTemplate(
42
+ path.join(templatesDir, "react", "component.tsx.ejs"),
43
+ ),
44
+ types: await loadTemplate(path.join(templatesDir, "react", "types.ts.ejs")),
45
+ index: await loadTemplate(path.join(templatesDir, "react", "index.ts.ejs")),
46
+ test: await loadTemplate(path.join(templatesDir, "react", "test.tsx.ejs")),
47
+ ssrTest: await loadTemplate(
48
+ path.join(templatesDir, "react", "ssr.test.tsx.ejs"),
49
+ ),
50
+ stories: await loadTemplate(
51
+ path.join(templatesDir, "react", "stories.tsx.ejs"),
52
+ ),
53
+ styles: await loadTemplate(
54
+ path.join(templatesDir, "shared", "styles.css.ejs"),
55
+ ),
53
56
  };
54
57
 
55
58
  // =============================================================================
56
59
  // Generator Definition
57
60
  // =============================================================================
58
61
 
59
- /**
60
- * React component generator definition.
61
- *
62
- * This generator creates a complete React component with TypeScript support,
63
- * testing infrastructure, and optional Storybook stories and CSS styles.
64
- *
65
- * @see {@link https://summon.dev/generators/component/react} for documentation
66
- */
67
62
  const generator = {
68
63
  meta: {
69
64
  name: "component/react",
@@ -107,28 +102,32 @@ For example, 'src/components/Button' creates a 'Button' component.`,
107
102
 
108
103
  debug("Creating main component file"),
109
104
  template({
110
- source: reactTemplates.component,
105
+ source: reactTemplates.component.source,
106
+ content: reactTemplates.component.content,
111
107
  dest: path.join(componentDir, `${componentName}.tsx`),
112
108
  vars: ctx,
113
109
  }),
114
110
 
115
111
  debug("Creating types file"),
116
112
  template({
117
- source: reactTemplates.types,
113
+ source: reactTemplates.types.source,
114
+ content: reactTemplates.types.content,
118
115
  dest: path.join(componentDir, "types.ts"),
119
116
  vars: ctx,
120
117
  }),
121
118
 
122
119
  debug("Creating index barrel file"),
123
120
  template({
124
- source: reactTemplates.index,
121
+ source: reactTemplates.index.source,
122
+ content: reactTemplates.index.content,
125
123
  dest: path.join(componentDir, "index.ts"),
126
124
  vars: ctx,
127
125
  }),
128
126
 
129
127
  debug("Creating test file"),
130
128
  template({
131
- source: reactTemplates.test,
129
+ source: reactTemplates.test.source,
130
+ content: reactTemplates.test.content,
132
131
  dest: path.join(componentDir, `${componentName}.tests.tsx`),
133
132
  vars: ctx,
134
133
  }),
@@ -137,7 +136,8 @@ For example, 'src/components/Button' creates a 'Button' component.`,
137
136
  when(
138
137
  answers.withSsrTests,
139
138
  template({
140
- source: reactTemplates.ssrTest,
139
+ source: reactTemplates.ssrTest.source,
140
+ content: reactTemplates.ssrTest.content,
141
141
  dest: path.join(componentDir, `${componentName}.ssr.tests.tsx`),
142
142
  vars: ctx,
143
143
  }),
@@ -147,7 +147,8 @@ For example, 'src/components/Button' creates a 'Button' component.`,
147
147
  when(
148
148
  answers.withStories,
149
149
  template({
150
- source: reactTemplates.stories,
150
+ source: reactTemplates.stories.source,
151
+ content: reactTemplates.stories.content,
151
152
  dest: path.join(componentDir, `${componentName}.stories.tsx`),
152
153
  vars: ctx,
153
154
  }),
@@ -157,7 +158,8 @@ For example, 'src/components/Button' creates a 'Button' component.`,
157
158
  when(
158
159
  answers.withStyles,
159
160
  template({
160
- source: reactTemplates.styles,
161
+ source: reactTemplates.styles.source,
162
+ content: reactTemplates.styles.content,
161
163
  dest: path.join(componentDir, "styles.css"),
162
164
  vars: ctx,
163
165
  }),
@@ -0,0 +1,100 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
5
+ import loadTemplate from "./loadTemplate.js";
6
+
7
+ describe("loadTemplate", () => {
8
+ let dir: string;
9
+
10
+ beforeEach(() => {
11
+ dir = mkdtempSync(join(tmpdir(), "pragma-load-template-"));
12
+ });
13
+
14
+ afterEach(() => {
15
+ rmSync(dir, { recursive: true, force: true });
16
+ // Ensure no embedded-files stub leaks between tests.
17
+ delete (globalThis as { Bun?: unknown }).Bun;
18
+ });
19
+
20
+ it("reads template content from the filesystem", async () => {
21
+ const path = join(dir, "component.tsx.ejs");
22
+ writeFileSync(path, "export const <%= name %> = () => null;");
23
+
24
+ const result = await loadTemplate(path);
25
+
26
+ expect(result.source).toBe(path);
27
+ expect(result.content).toBe("export const <%= name %> = () => null;");
28
+ });
29
+
30
+ it("falls back to Bun.embeddedFiles when the file is not on disk", async () => {
31
+ // No file written to disk → fs read fails → embedded lookup runs.
32
+ // Blob names are content-hashed (e.g. "component-a1b2c3.tsx.ejs"); the
33
+ // loader dehashes by stripping the "-<hash>." segment.
34
+ const missingPath = join(dir, "component.tsx.ejs");
35
+ (globalThis as { Bun?: unknown }).Bun = {
36
+ embeddedFiles: [
37
+ Object.assign(new Blob(["EMBEDDED CONTENT"]), {
38
+ name: "component-a1b2c3d4.tsx.ejs",
39
+ }),
40
+ ],
41
+ };
42
+
43
+ const result = await loadTemplate(missingPath);
44
+
45
+ expect(result.content).toBe("EMBEDDED CONTENT");
46
+ expect(result.source).toBe(missingPath);
47
+ });
48
+
49
+ it("returns the disk content even when an embedded blob also exists", async () => {
50
+ const path = join(dir, "types.ts.ejs");
51
+ writeFileSync(path, "DISK WINS");
52
+ (globalThis as { Bun?: unknown }).Bun = {
53
+ embeddedFiles: [
54
+ Object.assign(new Blob(["EMBEDDED"]), {
55
+ name: "types-deadbeef.ts.ejs",
56
+ }),
57
+ ],
58
+ };
59
+
60
+ const result = await loadTemplate(path);
61
+
62
+ expect(result.content).toBe("DISK WINS");
63
+ });
64
+
65
+ // A total miss (no disk file, no matching embedded blob) must fail loud:
66
+ // callers await this for required templates and do not guard against empty
67
+ // content, so a silent "" would generate blank files (notably in a compiled
68
+ // binary, where the disk read always fails).
69
+ it("throws on a total miss (no disk, no embedded match)", async () => {
70
+ const missingPath = join(dir, "nonexistent.ejs");
71
+
72
+ await expect(loadTemplate(missingPath)).rejects.toThrow(
73
+ /Template not found/,
74
+ );
75
+ });
76
+
77
+ it("throws when an embedded blob exists but none matches the basename", async () => {
78
+ const missingPath = join(dir, "wanted.ejs");
79
+ (globalThis as { Bun?: unknown }).Bun = {
80
+ embeddedFiles: [
81
+ Object.assign(new Blob(["x"]), { name: "other-cafef00d.ejs" }),
82
+ ],
83
+ };
84
+
85
+ await expect(loadTemplate(missingPath)).rejects.toThrow(
86
+ /Template not found/,
87
+ );
88
+ });
89
+
90
+ it("throws when Bun is present but exposes no embeddedFiles", async () => {
91
+ // Running under the Bun runtime (not a compiled binary): `Bun` exists but
92
+ // `embeddedFiles` is undefined, so the embedded lookup is skipped.
93
+ const missingPath = join(dir, "wanted.ejs");
94
+ (globalThis as { Bun?: unknown }).Bun = {};
95
+
96
+ await expect(loadTemplate(missingPath)).rejects.toThrow(
97
+ /Template not found/,
98
+ );
99
+ });
100
+ });
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Load a template file eagerly, with compiled binary support.
3
+ *
4
+ * In interpreted mode, reads from the filesystem. In a compiled binary,
5
+ * falls back to `Bun.embeddedFiles` blobs (async, requires top-level await).
6
+ */
7
+
8
+ import { readFileSync } from "node:fs";
9
+
10
+ export interface LoadedTemplate {
11
+ /** Original source path (for diagnostics and dry-run display). */
12
+ readonly source: string;
13
+ /** Template content string. */
14
+ readonly content: string;
15
+ }
16
+
17
+ /**
18
+ * Load a template from disk or embedded files.
19
+ *
20
+ * @param source - Absolute path to the template file.
21
+ * @returns Loaded template with path and content.
22
+ */
23
+ export default async function loadTemplate(
24
+ source: string,
25
+ ): Promise<LoadedTemplate> {
26
+ // Try filesystem first (works in interpreted mode)
27
+ try {
28
+ return { source, content: readFileSync(source, "utf-8") };
29
+ } catch {
30
+ // Fall through to embedded lookup
31
+ }
32
+
33
+ // Try Bun.embeddedFiles (works in compiled binary)
34
+ if (typeof globalThis.Bun !== "undefined") {
35
+ const blobs = (globalThis.Bun as { embeddedFiles?: readonly Blob[] })
36
+ .embeddedFiles as ReadonlyArray<Blob & { name: string }> | undefined;
37
+
38
+ if (blobs) {
39
+ // KNOWN LIMITATION (basename collision): we match embedded blobs by
40
+ // basename only, because Bun flattens embedded-asset names to the
41
+ // filename (the source directory is not preserved). Several templates
42
+ // share a basename across frameworks — types.ts.ejs, index.ts.ejs,
43
+ // styles.css.ejs and stories.ts.ejs each exist in lit/, react/ and/or
44
+ // svelte/. In a compiled binary this can resolve to the WRONG
45
+ // framework's template (whichever blob is encountered first), producing
46
+ // a silently incorrect generated file. The proper fix is build-side:
47
+ // embed templates under directory-qualified unique names and match on
48
+ // those. Deferred — needs verification against a real compiled binary
49
+ // (see pragma-adrs/session/J.CLI_MCP_FINISH.md). Interpreted mode (the
50
+ // common path) reads from disk above and is unaffected.
51
+ const basename = source.slice(source.lastIndexOf("/") + 1);
52
+ for (const blob of blobs) {
53
+ const dehashed = blob.name.replace(/-[a-z0-9]+\./, ".");
54
+ if (dehashed === basename) {
55
+ const content = await blob.text();
56
+ return { source, content };
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ // Neither the filesystem nor embedded files yielded the template. Fail loud
63
+ // rather than returning empty content: callers await this for required
64
+ // templates and do not guard against blanks, so a silent "" would generate
65
+ // empty files (notably in a compiled binary, where the disk read always
66
+ // fails and a missing embed is the only failure mode).
67
+ throw new Error(
68
+ `Template not found: ${source} (not on disk, and no matching embedded file).`,
69
+ );
70
+ }
@@ -35,24 +35,35 @@ import {
35
35
  getParentDir,
36
36
  sharedPrompts,
37
37
  } from "../shared/index.js";
38
+ import loadTemplate from "../shared/loadTemplate.js";
38
39
  import type { SvelteComponentAnswers } from "./types.js";
39
40
 
40
41
  // =============================================================================
41
- // Template Paths
42
+ // Template Paths & Content (loaded eagerly via top-level await)
42
43
  // =============================================================================
43
44
 
44
45
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
45
46
  const templatesDir = path.join(__dirname, "..", "templates");
46
47
 
47
48
  const svelteTemplates = {
48
- component: path.join(templatesDir, "svelte", "component.svelte.ejs"),
49
- types: path.join(templatesDir, "svelte", "types.ts.ejs"),
50
- index: path.join(templatesDir, "svelte", "index.ts.ejs"),
51
- test: path.join(templatesDir, "svelte", "test.ts.ejs"),
52
- ssrTest: path.join(templatesDir, "svelte", "ssr.test.ts.ejs"),
53
- storiesSvelte: path.join(templatesDir, "svelte", "stories.svelte.ejs"),
54
- storiesTs: path.join(templatesDir, "svelte", "stories.ts.ejs"),
55
- styles: path.join(templatesDir, "shared", "styles.css.ejs"),
49
+ component: await loadTemplate(
50
+ path.join(templatesDir, "svelte", "component.svelte.ejs"),
51
+ ),
52
+ types: await loadTemplate(path.join(templatesDir, "svelte", "types.ts.ejs")),
53
+ index: await loadTemplate(path.join(templatesDir, "svelte", "index.ts.ejs")),
54
+ test: await loadTemplate(path.join(templatesDir, "svelte", "test.ts.ejs")),
55
+ ssrTest: await loadTemplate(
56
+ path.join(templatesDir, "svelte", "ssr.test.ts.ejs"),
57
+ ),
58
+ storiesSvelte: await loadTemplate(
59
+ path.join(templatesDir, "svelte", "stories.svelte.ejs"),
60
+ ),
61
+ storiesTs: await loadTemplate(
62
+ path.join(templatesDir, "svelte", "stories.ts.ejs"),
63
+ ),
64
+ styles: await loadTemplate(
65
+ path.join(templatesDir, "shared", "styles.css.ejs"),
66
+ ),
56
67
  };
57
68
 
58
69
  // =============================================================================
@@ -122,28 +133,32 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
122
133
 
123
134
  debug("Creating main component file"),
124
135
  template({
125
- source: svelteTemplates.component,
136
+ source: svelteTemplates.component.source,
137
+ content: svelteTemplates.component.content,
126
138
  dest: path.join(componentDir, `${componentName}.svelte`),
127
139
  vars: ctx,
128
140
  }),
129
141
 
130
142
  debug("Creating types file"),
131
143
  template({
132
- source: svelteTemplates.types,
144
+ source: svelteTemplates.types.source,
145
+ content: svelteTemplates.types.content,
133
146
  dest: path.join(componentDir, "types.ts"),
134
147
  vars: ctx,
135
148
  }),
136
149
 
137
150
  debug("Creating index barrel file"),
138
151
  template({
139
- source: svelteTemplates.index,
152
+ source: svelteTemplates.index.source,
153
+ content: svelteTemplates.index.content,
140
154
  dest: path.join(componentDir, "index.ts"),
141
155
  vars: ctx,
142
156
  }),
143
157
 
144
158
  debug("Creating test file"),
145
159
  template({
146
- source: svelteTemplates.test,
160
+ source: svelteTemplates.test.source,
161
+ content: svelteTemplates.test.content,
147
162
  dest: path.join(componentDir, `${componentName}.svelte.test.ts`),
148
163
  vars: ctx,
149
164
  }),
@@ -152,7 +167,8 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
152
167
  when(
153
168
  answers.withSsrTests,
154
169
  template({
155
- source: svelteTemplates.ssrTest,
170
+ source: svelteTemplates.ssrTest.source,
171
+ content: svelteTemplates.ssrTest.content,
156
172
  dest: path.join(componentDir, `${componentName}.ssr.test.ts`),
157
173
  vars: ctx,
158
174
  }),
@@ -165,7 +181,8 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
165
181
  when(
166
182
  answers.withStories && !answers.useTsStories,
167
183
  template({
168
- source: svelteTemplates.storiesSvelte,
184
+ source: svelteTemplates.storiesSvelte.source,
185
+ content: svelteTemplates.storiesSvelte.content,
169
186
  dest: path.join(componentDir, `${componentName}.stories.svelte`),
170
187
  vars: ctx,
171
188
  }),
@@ -178,7 +195,8 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
178
195
  when(
179
196
  answers.withStories && answers.useTsStories,
180
197
  template({
181
- source: svelteTemplates.storiesTs,
198
+ source: svelteTemplates.storiesTs.source,
199
+ content: svelteTemplates.storiesTs.content,
182
200
  dest: path.join(componentDir, `${componentName}.stories.ts`),
183
201
  vars: ctx,
184
202
  }),
@@ -188,7 +206,8 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
188
206
  when(
189
207
  answers.withStyles,
190
208
  template({
191
- source: svelteTemplates.styles,
209
+ source: svelteTemplates.styles.source,
210
+ content: svelteTemplates.styles.content,
192
211
  dest: path.join(componentDir, "styles.css"),
193
212
  vars: ctx,
194
213
  }),
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { <%= name %>Props } from "./types";
2
+ import type { <%= name %>Props } from "./types.js";
3
3
  <% if (withStyles) { -%>
4
4
  import "./styles.css";
5
5
  <% } -%>
@@ -1,2 +1,2 @@
1
1
  export { default as <%= name %> } from "./<%= name %>.svelte";
2
- export type { <%= name %>Props } from "./types";
2
+ export type { <%= name %>Props } from "./types.js";
@@ -1,3 +1,4 @@
1
+ import type { Snippet } from "svelte";
1
2
  import type { SvelteHTMLElements } from "svelte/elements";
2
3
 
3
4
  /*