@canonical/summon-component 0.31.0 → 0.33.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.
@@ -21,20 +21,34 @@ import { fileURLToPath } from "node:url";
21
21
  import { template } from "@canonical/summon-core";
22
22
  import { debug, info, mkdir, sequence_, when } from "@canonical/task";
23
23
  import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, } from "../shared/index.js";
24
- import loadTemplate from "../shared/loadTemplate.js";
24
+ import { loadTemplateSync } from "../shared/loadTemplate.js";
25
25
  // =============================================================================
26
- // Template Paths & Content (loaded eagerly via top-level await)
26
+ // Template Paths & Content (loaded LAZILY on first generate())
27
27
  // =============================================================================
28
28
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
29
29
  const templatesDir = path.join(__dirname, "..", "templates");
30
- const litTemplates = {
31
- component: await loadTemplate(path.join(templatesDir, "lit", "component.ts.ejs")),
32
- index: await loadTemplate(path.join(templatesDir, "lit", "index.ts.ejs")),
33
- types: await loadTemplate(path.join(templatesDir, "lit", "types.ts.ejs")),
34
- tests: await loadTemplate(path.join(templatesDir, "lit", "tests.ts.ejs")),
35
- stories: await loadTemplate(path.join(templatesDir, "lit", "stories.ts.ejs")),
36
- styles: await loadTemplate(path.join(templatesDir, "lit", "styles.css.ejs")),
37
- };
30
+ /** Read every Lit template from disk (or the embedded manifest). */
31
+ function loadLitTemplates() {
32
+ return {
33
+ component: loadTemplateSync(path.join(templatesDir, "lit", "component.ts.ejs")),
34
+ index: loadTemplateSync(path.join(templatesDir, "lit", "index.ts.ejs")),
35
+ types: loadTemplateSync(path.join(templatesDir, "lit", "types.ts.ejs")),
36
+ tests: loadTemplateSync(path.join(templatesDir, "lit", "tests.ts.ejs")),
37
+ stories: loadTemplateSync(path.join(templatesDir, "lit", "stories.ts.ejs")),
38
+ styles: loadTemplateSync(path.join(templatesDir, "lit", "styles.css.ejs")),
39
+ };
40
+ }
41
+ /**
42
+ * Memoized template bundle. Loaded on the FIRST `generate()` call, never at
43
+ * module-eval — so importing this generator never reads a template, and a READ
44
+ * command (which never calls `generate()`) never touches the `.ejs` a compiled
45
+ * binary lacks. See the react generator for the full rationale.
46
+ */
47
+ let litTemplatesCache;
48
+ function litTemplates() {
49
+ litTemplatesCache ??= loadLitTemplates();
50
+ return litTemplatesCache;
51
+ }
38
52
  // =============================================================================
39
53
  // Custom Prompts (without SSR tests)
40
54
  // =============================================================================
@@ -96,49 +110,50 @@ with the custom element tag 'button'.`,
96
110
  const componentDir = answers.componentPath;
97
111
  const parentDir = getParentDir(answers.componentPath);
98
112
  const ctx = createTemplateContext(answers, "lit");
113
+ const t = litTemplates();
99
114
  return sequence_([
100
115
  info(`Generating Lit web component: ${componentName}`),
101
116
  debug("Creating component directory"),
102
117
  mkdir(componentDir),
103
118
  debug("Creating main component file"),
104
119
  template({
105
- source: litTemplates.component.source,
106
- content: litTemplates.component.content,
120
+ source: t.component.source,
121
+ content: t.component.content,
107
122
  dest: path.join(componentDir, `${componentName}.ts`),
108
123
  vars: ctx,
109
124
  }),
110
125
  debug("Creating index barrel file"),
111
126
  template({
112
- source: litTemplates.index.source,
113
- content: litTemplates.index.content,
127
+ source: t.index.source,
128
+ content: t.index.content,
114
129
  dest: path.join(componentDir, "index.ts"),
115
130
  vars: ctx,
116
131
  }),
117
132
  debug("Creating types file"),
118
133
  template({
119
- source: litTemplates.types.source,
120
- content: litTemplates.types.content,
134
+ source: t.types.source,
135
+ content: t.types.content,
121
136
  dest: path.join(componentDir, "types.ts"),
122
137
  vars: ctx,
123
138
  }),
124
139
  debug("Creating test file"),
125
140
  template({
126
- source: litTemplates.tests.source,
127
- content: litTemplates.tests.content,
141
+ source: t.tests.source,
142
+ content: t.tests.content,
128
143
  dest: path.join(componentDir, `${componentName}.tests.ts`),
129
144
  vars: ctx,
130
145
  }),
131
146
  when(answers.withStories, debug("Creating stories file")),
132
147
  when(answers.withStories, template({
133
- source: litTemplates.stories.source,
134
- content: litTemplates.stories.content,
148
+ source: t.stories.source,
149
+ content: t.stories.content,
135
150
  dest: path.join(componentDir, `${componentName}.stories.ts`),
136
151
  vars: ctx,
137
152
  })),
138
153
  when(answers.withStyles, debug("Creating styles file")),
139
154
  when(answers.withStyles, template({
140
- source: litTemplates.styles.source,
141
- content: litTemplates.styles.content,
155
+ source: t.styles.source,
156
+ content: t.styles.content,
142
157
  dest: path.join(componentDir, "styles.css"),
143
158
  vars: ctx,
144
159
  })),
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAGrD,gFAAgF;AAChF,gEAAgE;AAChE,gFAAgF;AAEhF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE7D,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,MAAM,YAAY,CAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,kBAAkB,CAAC,CACnD;IACD,KAAK,EAAE,MAAM,YAAY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Y,EAAE,GAAG,aAAa,WAAW,CAAC;gBAC1D,IAAI,EAAE,GAAG;aACV,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACzD,IAAI,CACF,OAAO,CAAC,WAAW,EACnB,QAAQ,CAAC;gBACP,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM;gBACxB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO;gBAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,aAAa,aAAa,CAAC;gBAC5D,IAAI,EAAE,GAAG;aACV,CAAC,CACH;YAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;YACvD,IAAI,CACF,OAAO,CAAC,UAAU,EAClB,QAAQ,CAAC;gBACP,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM;gBACvB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;gBAC3C,IAAI,EAAE,GAAG;aACV,CAAC,CACH;YAED,KAAK,CAAC,sCAAsC,CAAC;YAC7C,yBAAyB,CAAC,SAAS,EAAE,aAAa,CAAC;YAEnD,IAAI,CAAC,WAAW,aAAa,iBAAiB,YAAY,EAAE,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;CACiD,CAAC;AAErD,eAAe,SAAS,CAAC"}
@@ -17,21 +17,36 @@ import { fileURLToPath } from "node:url";
17
17
  import { template } from "@canonical/summon-core";
18
18
  import { debug, info, mkdir, sequence_, when } from "@canonical/task";
19
19
  import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, sharedPrompts, } from "../shared/index.js";
20
- import loadTemplate from "../shared/loadTemplate.js";
20
+ import { loadTemplateSync } from "../shared/loadTemplate.js";
21
21
  // =============================================================================
22
- // Template Paths & Content (loaded eagerly via top-level await)
22
+ // Template Paths & Content (loaded LAZILY on first generate())
23
23
  // =============================================================================
24
24
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
25
25
  const templatesDir = path.join(__dirname, "..", "templates");
26
- const reactTemplates = {
27
- component: await loadTemplate(path.join(templatesDir, "react", "component.tsx.ejs")),
28
- types: await loadTemplate(path.join(templatesDir, "react", "types.ts.ejs")),
29
- index: await loadTemplate(path.join(templatesDir, "react", "index.ts.ejs")),
30
- test: await loadTemplate(path.join(templatesDir, "react", "test.tsx.ejs")),
31
- ssrTest: await loadTemplate(path.join(templatesDir, "react", "ssr.test.tsx.ejs")),
32
- stories: await loadTemplate(path.join(templatesDir, "react", "stories.tsx.ejs")),
33
- styles: await loadTemplate(path.join(templatesDir, "shared", "styles.css.ejs")),
34
- };
26
+ /** Read every React template from disk (or the embedded manifest). */
27
+ function loadReactTemplates() {
28
+ return {
29
+ component: loadTemplateSync(path.join(templatesDir, "react", "component.tsx.ejs")),
30
+ types: loadTemplateSync(path.join(templatesDir, "react", "types.ts.ejs")),
31
+ index: loadTemplateSync(path.join(templatesDir, "react", "index.ts.ejs")),
32
+ test: loadTemplateSync(path.join(templatesDir, "react", "test.tsx.ejs")),
33
+ ssrTest: loadTemplateSync(path.join(templatesDir, "react", "ssr.test.tsx.ejs")),
34
+ stories: loadTemplateSync(path.join(templatesDir, "react", "stories.tsx.ejs")),
35
+ styles: loadTemplateSync(path.join(templatesDir, "shared", "styles.css.ejs")),
36
+ };
37
+ }
38
+ /**
39
+ * Memoized template bundle. Loaded on the FIRST `generate()` call, never at
40
+ * module-eval — so importing this generator (which the CLI does behind a lazy
41
+ * boundary, and which a compiled-binary READ may still eval) never reads a
42
+ * template. A READ never calls `generate()`, so it never touches the disk/`.ejs`
43
+ * that a standalone binary lacks — closing the bun-code-splitting-fragility hole.
44
+ */
45
+ let reactTemplatesCache;
46
+ function reactTemplates() {
47
+ reactTemplatesCache ??= loadReactTemplates();
48
+ return reactTemplatesCache;
49
+ }
35
50
  // =============================================================================
36
51
  // Generator Definition
37
52
  // =============================================================================
@@ -66,56 +81,57 @@ For example, 'src/components/Button' creates a 'Button' component.`,
66
81
  const componentDir = answers.componentPath;
67
82
  const parentDir = getParentDir(answers.componentPath);
68
83
  const ctx = createTemplateContext(answers, "react");
84
+ const t = reactTemplates();
69
85
  return sequence_([
70
86
  info(`Generating React component: ${componentName}`),
71
87
  debug("Creating component directory"),
72
88
  mkdir(componentDir),
73
89
  debug("Creating main component file"),
74
90
  template({
75
- source: reactTemplates.component.source,
76
- content: reactTemplates.component.content,
91
+ source: t.component.source,
92
+ content: t.component.content,
77
93
  dest: path.join(componentDir, `${componentName}.tsx`),
78
94
  vars: ctx,
79
95
  }),
80
96
  debug("Creating types file"),
81
97
  template({
82
- source: reactTemplates.types.source,
83
- content: reactTemplates.types.content,
98
+ source: t.types.source,
99
+ content: t.types.content,
84
100
  dest: path.join(componentDir, "types.ts"),
85
101
  vars: ctx,
86
102
  }),
87
103
  debug("Creating index barrel file"),
88
104
  template({
89
- source: reactTemplates.index.source,
90
- content: reactTemplates.index.content,
105
+ source: t.index.source,
106
+ content: t.index.content,
91
107
  dest: path.join(componentDir, "index.ts"),
92
108
  vars: ctx,
93
109
  }),
94
110
  debug("Creating test file"),
95
111
  template({
96
- source: reactTemplates.test.source,
97
- content: reactTemplates.test.content,
112
+ source: t.test.source,
113
+ content: t.test.content,
98
114
  dest: path.join(componentDir, `${componentName}.tests.tsx`),
99
115
  vars: ctx,
100
116
  }),
101
117
  when(answers.withSsrTests, debug("Creating SSR test file")),
102
118
  when(answers.withSsrTests, template({
103
- source: reactTemplates.ssrTest.source,
104
- content: reactTemplates.ssrTest.content,
119
+ source: t.ssrTest.source,
120
+ content: t.ssrTest.content,
105
121
  dest: path.join(componentDir, `${componentName}.ssr.tests.tsx`),
106
122
  vars: ctx,
107
123
  })),
108
124
  when(answers.withStories, debug("Creating stories file")),
109
125
  when(answers.withStories, template({
110
- source: reactTemplates.stories.source,
111
- content: reactTemplates.stories.content,
126
+ source: t.stories.source,
127
+ content: t.stories.content,
112
128
  dest: path.join(componentDir, `${componentName}.stories.tsx`),
113
129
  vars: ctx,
114
130
  })),
115
131
  when(answers.withStyles, debug("Creating styles file")),
116
132
  when(answers.withStyles, template({
117
- source: reactTemplates.styles.source,
118
- content: reactTemplates.styles.content,
133
+ source: t.styles.source,
134
+ content: t.styles.content,
119
135
  dest: path.join(componentDir, "styles.css"),
120
136
  vars: ctx,
121
137
  })),
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAGrD,gFAAgF;AAChF,gEAAgE;AAChE,gFAAgF;AAEhF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE7D,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE,MAAM,YAAY,CAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,mBAAmB,CAAC,CACtD;I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agerly, with compiled binary support.
2
+ * Load a template file eagerly, with compiled-binary support.
3
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).
4
+ * In a source run (or tests) the template is read from disk. In the standalone
5
+ * `bun build --compile` binary the `.ejs` files are not on disk, so the loader
6
+ * falls back to an EMBEDDED MANIFEST injected by the host via
7
+ * {@link setEmbeddedTemplates} — a map keyed by DIRECTORY-QUALIFIED path
8
+ * (`component/<framework>/<file>`), compiled into the binary as inline strings.
9
+ *
10
+ * The directory-qualified key is what fixes the historic basename collision:
11
+ * several component templates share a basename across frameworks
12
+ * (`types.ts.ejs`, `index.ts.ejs`, `styles.css.ejs`, `stories.ts.ejs` exist in
13
+ * `react/`, `svelte/` and `lit/`). The previous fallback matched embedded blobs
14
+ * by BARE BASENAME, so a compiled binary could silently emit the WRONG
15
+ * framework's template (whichever blob was encountered first). Matching on the
16
+ * framework-qualified suffix instead guarantees the right framework's file.
6
17
  */
7
18
  import { readFileSync } from "node:fs";
8
19
  /**
9
- * Load a template from disk or embedded files.
20
+ * The injected embedded-template manifest: directory-qualified path
21
+ * (`component/react/types.ts.ejs`) → template content. Empty in a source run
22
+ * (templates load from disk); populated by the compiled-binary host BEFORE the
23
+ * component generators evaluate their top-level `await loadTemplate`.
24
+ */
25
+ let embeddedTemplates = {};
26
+ /**
27
+ * Inject the embedded-template manifest — the compiled-binary fallback. Called
28
+ * once by the host (the `pragma` `create` runtime) before the component
29
+ * generators are imported, so their eager `loadTemplate` calls can resolve from
30
+ * it when the disk read fails. Passing an empty map (the default) restores pure
31
+ * disk loading.
32
+ *
33
+ * @param manifest - Directory-qualified path → template content.
34
+ */
35
+ export function setEmbeddedTemplates(manifest) {
36
+ embeddedTemplates = manifest;
37
+ }
38
+ /**
39
+ * The directory-qualified manifest key for a template source path: the portion
40
+ * after the last `/templates/` segment (e.g. `react/types.ts.ejs`), prefixed
41
+ * with the generator id (`component/`). Returns `undefined` when the path has no
42
+ * `templates/` segment (never expected for a real template).
43
+ *
44
+ * The `component/` prefix is correct because this loader is used ONLY by the
45
+ * component generators; the shared manifest additionally carries `package/…` and
46
+ * `application/…` entries (embedded for a future compiled-binary rollout of
47
+ * those nouns), which this loader never queries.
48
+ */
49
+ function qualifiedKey(source) {
50
+ const marker = "/templates/";
51
+ const at = source.lastIndexOf(marker);
52
+ if (at === -1)
53
+ return undefined;
54
+ return `component/${source.slice(at + marker.length)}`;
55
+ }
56
+ /**
57
+ * Load a template from disk, or — when the disk read fails (a compiled binary) —
58
+ * from the injected embedded manifest. SYNCHRONOUS.
59
+ *
60
+ * Disk is consulted FIRST: a source run reads the real file, and the compiled
61
+ * binary's absolute `/$bunfs/…` source paths never exist on a user's disk, so it
62
+ * always falls through to the manifest. A source run and a compiled run are
63
+ * therefore byte-identical (the manifest is generated from the same files).
64
+ *
65
+ * This is synchronous (both branches — `readFileSync` and the in-memory manifest
66
+ * lookup — are), so a generator can load its templates LAZILY inside its
67
+ * synchronous `generate(answers): Task` call rather than via a module-eval
68
+ * top-level `await`. That is the whole point of the sync form: a READ command
69
+ * (which never calls `generate()`) then never touches a template, regardless of
70
+ * whether bun's `--compile` code-splitting kept the generator module lazy — the
71
+ * exact fragility that crashed `pragma block list` on some bun versions.
10
72
  *
11
73
  * @param source - Absolute path to the template file.
12
74
  * @returns Loaded template with path and content.
75
+ * @throws If the template is neither on disk nor in the embedded manifest — fail
76
+ * loud rather than return `""`, which callers do not guard against and would
77
+ * silently write as empty files (notably in a compiled binary).
13
78
  */
14
- export default async function loadTemplate(source) {
15
- // Try filesystem first (works in interpreted mode)
79
+ export function loadTemplateSync(source) {
80
+ // Filesystem first (source runs / tests).
16
81
  try {
17
82
  return { source, content: readFileSync(source, "utf-8") };
18
83
  }
19
84
  catch {
20
- // Fall through to embedded lookup
85
+ // Not on disk — fall through to the embedded manifest (compiled binary).
21
86
  }
22
- // Try Bun.embeddedFiles (works in compiled binary)
23
- if (typeof globalThis.Bun !== "undefined") {
24
- const blobs = globalThis.Bun
25
- .embeddedFiles;
26
- if (blobs) {
27
- // KNOWN LIMITATION (basename collision): we match embedded blobs by
28
- // basename only, because Bun flattens embedded-asset names to the
29
- // filename (the source directory is not preserved). Several templates
30
- // share a basename across frameworks — types.ts.ejs, index.ts.ejs,
31
- // styles.css.ejs and stories.ts.ejs each exist in lit/, react/ and/or
32
- // svelte/. In a compiled binary this can resolve to the WRONG
33
- // framework's template (whichever blob is encountered first), producing
34
- // a silently incorrect generated file. The proper fix is build-side:
35
- // embed templates under directory-qualified unique names and match on
36
- // those. Deferred — needs verification against a real compiled binary
37
- // (see pragma-adrs/session/J.CLI_MCP_FINISH.md). Interpreted mode (the
38
- // common path) reads from disk above and is unaffected.
39
- const basename = source.slice(source.lastIndexOf("/") + 1);
40
- for (const blob of blobs) {
41
- const dehashed = blob.name.replace(/-[a-z0-9]+\./, ".");
42
- if (dehashed === basename) {
43
- const content = await blob.text();
44
- return { source, content };
45
- }
46
- }
47
- }
87
+ // Directory-qualified embedded lookup: `react/types.ts.ejs` and
88
+ // `svelte/types.ts.ejs` map to distinct keys, so the collision is impossible.
89
+ const key = qualifiedKey(source);
90
+ if (key !== undefined) {
91
+ const content = embeddedTemplates[key];
92
+ if (content !== undefined)
93
+ return { source, content };
48
94
  }
49
- // Neither the filesystem nor embedded files yielded the template. Fail loud
50
- // rather than returning empty content: callers await this for required
51
- // templates and do not guard against blanks, so a silent "" would generate
52
- // empty files (notably in a compiled binary, where the disk read always
53
- // fails and a missing embed is the only failure mode).
54
- throw new Error(`Template not found: ${source} (not on disk, and no matching embedded file).`);
95
+ throw new Error(`Template not found: ${source} (not on disk, and no embedded template for ${key === undefined ? "this path" : `'${key}'`}).`);
96
+ }
97
+ /**
98
+ * Async wrapper over {@link loadTemplateSync}, kept for callers that await a
99
+ * template load. The body is fully synchronous.
100
+ *
101
+ * @param source - Absolute path to the template file.
102
+ * @returns Loaded template with path and content.
103
+ */
104
+ export default async function loadTemplate(source) {
105
+ return loadTemplateSync(source);
55
106
  }
56
107
  //# sourceMappingURL=loadTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadTemplate.js","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,MAAc;IAEd,mDAAmD;IACnD,IAAI,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,kCAAkC;IACpC,CAAC;IAED,mDAAmD;IACnD,IAAI,OAAO,UAAU,CAAC,GAAG,KAAK,WAAW,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAI,UAAU,CAAC,GAA2C;aAClE,aAAmE,CAAC;QAEvE,IAAI,KAAK,EAAE,CAAC;YACV,oEAAoE;YACpE,kEAAkE;YAClE,sEAAsE;YACtE,mEAAmE;YACnE,sEAAsE;YACtE,8DAA8D;YAC9D,wEAAwE;YACxE,qEAAqE;YACrE,sEAAsE;YACtE,sEAAsE;YACtE,uEAAuE;YACvE,wDAAwD;YACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;gBACxD,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;oBAC1B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;oBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;gBAC7B,C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G,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,+CAC3B,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,GAC3C,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,MAAc;IAEd,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
@@ -25,22 +25,36 @@ import { fileURLToPath } from "node:url";
25
25
  import { template } from "@canonical/summon-core";
26
26
  import { debug, info, mkdir, sequence_, when } from "@canonical/task";
27
27
  import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, sharedPrompts, } from "../shared/index.js";
28
- import loadTemplate from "../shared/loadTemplate.js";
28
+ import { loadTemplateSync } from "../shared/loadTemplate.js";
29
29
  // =============================================================================
30
- // Template Paths & Content (loaded eagerly via top-level await)
30
+ // Template Paths & Content (loaded LAZILY on first generate())
31
31
  // =============================================================================
32
32
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
33
33
  const templatesDir = path.join(__dirname, "..", "templates");
34
- const svelteTemplates = {
35
- component: await loadTemplate(path.join(templatesDir, "svelte", "component.svelte.ejs")),
36
- types: await loadTemplate(path.join(templatesDir, "svelte", "types.ts.ejs")),
37
- index: await loadTemplate(path.join(templatesDir, "svelte", "index.ts.ejs")),
38
- test: await loadTemplate(path.join(templatesDir, "svelte", "test.ts.ejs")),
39
- ssrTest: await loadTemplate(path.join(templatesDir, "svelte", "ssr.test.ts.ejs")),
40
- storiesSvelte: await loadTemplate(path.join(templatesDir, "svelte", "stories.svelte.ejs")),
41
- storiesTs: await loadTemplate(path.join(templatesDir, "svelte", "stories.ts.ejs")),
42
- styles: await loadTemplate(path.join(templatesDir, "shared", "styles.css.ejs")),
43
- };
34
+ /** Read every Svelte template from disk (or the embedded manifest). */
35
+ function loadSvelteTemplates() {
36
+ return {
37
+ component: loadTemplateSync(path.join(templatesDir, "svelte", "component.svelte.ejs")),
38
+ types: loadTemplateSync(path.join(templatesDir, "svelte", "types.ts.ejs")),
39
+ index: loadTemplateSync(path.join(templatesDir, "svelte", "index.ts.ejs")),
40
+ test: loadTemplateSync(path.join(templatesDir, "svelte", "test.ts.ejs")),
41
+ ssrTest: loadTemplateSync(path.join(templatesDir, "svelte", "ssr.test.ts.ejs")),
42
+ storiesSvelte: loadTemplateSync(path.join(templatesDir, "svelte", "stories.svelte.ejs")),
43
+ storiesTs: loadTemplateSync(path.join(templatesDir, "svelte", "stories.ts.ejs")),
44
+ styles: loadTemplateSync(path.join(templatesDir, "shared", "styles.css.ejs")),
45
+ };
46
+ }
47
+ /**
48
+ * Memoized template bundle. Loaded on the FIRST `generate()` call, never at
49
+ * module-eval — so importing this generator never reads a template, and a READ
50
+ * command (which never calls `generate()`) never touches the `.ejs` a compiled
51
+ * binary lacks. See the react generator for the full rationale.
52
+ */
53
+ let svelteTemplatesCache;
54
+ function svelteTemplates() {
55
+ svelteTemplatesCache ??= loadSvelteTemplates();
56
+ return svelteTemplatesCache;
57
+ }
44
58
  // =============================================================================
45
59
  // Generator Definition
46
60
  // =============================================================================
@@ -95,63 +109,64 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
95
109
  const componentDir = answers.componentPath;
96
110
  const parentDir = getParentDir(answers.componentPath);
97
111
  const ctx = createTemplateContext(answers, "svelte");
112
+ const t = svelteTemplates();
98
113
  return sequence_([
99
114
  info(`Generating Svelte component: ${componentName}`),
100
115
  debug("Creating component directory"),
101
116
  mkdir(componentDir),
102
117
  debug("Creating main component file"),
103
118
  template({
104
- source: svelteTemplates.component.source,
105
- content: svelteTemplates.component.content,
119
+ source: t.component.source,
120
+ content: t.component.content,
106
121
  dest: path.join(componentDir, `${componentName}.svelte`),
107
122
  vars: ctx,
108
123
  }),
109
124
  debug("Creating types file"),
110
125
  template({
111
- source: svelteTemplates.types.source,
112
- content: svelteTemplates.types.content,
126
+ source: t.types.source,
127
+ content: t.types.content,
113
128
  dest: path.join(componentDir, "types.ts"),
114
129
  vars: ctx,
115
130
  }),
116
131
  debug("Creating index barrel file"),
117
132
  template({
118
- source: svelteTemplates.index.source,
119
- content: svelteTemplates.index.content,
133
+ source: t.index.source,
134
+ content: t.index.content,
120
135
  dest: path.join(componentDir, "index.ts"),
121
136
  vars: ctx,
122
137
  }),
123
138
  debug("Creating test file"),
124
139
  template({
125
- source: svelteTemplates.test.source,
126
- content: svelteTemplates.test.content,
140
+ source: t.test.source,
141
+ content: t.test.content,
127
142
  dest: path.join(componentDir, `${componentName}.svelte.test.ts`),
128
143
  vars: ctx,
129
144
  }),
130
145
  when(answers.withSsrTests, debug("Creating SSR test file")),
131
146
  when(answers.withSsrTests, template({
132
- source: svelteTemplates.ssrTest.source,
133
- content: svelteTemplates.ssrTest.content,
147
+ source: t.ssrTest.source,
148
+ content: t.ssrTest.content,
134
149
  dest: path.join(componentDir, `${componentName}.ssr.test.ts`),
135
150
  vars: ctx,
136
151
  })),
137
152
  when(answers.withStories && !answers.useTsStories, debug("Creating Svelte CSF stories file")),
138
153
  when(answers.withStories && !answers.useTsStories, template({
139
- source: svelteTemplates.storiesSvelte.source,
140
- content: svelteTemplates.storiesSvelte.content,
154
+ source: t.storiesSvelte.source,
155
+ content: t.storiesSvelte.content,
141
156
  dest: path.join(componentDir, `${componentName}.stories.svelte`),
142
157
  vars: ctx,
143
158
  })),
144
159
  when(answers.withStories && answers.useTsStories, debug("Creating TypeScript stories file")),
145
160
  when(answers.withStories && answers.useTsStories, template({
146
- source: svelteTemplates.storiesTs.source,
147
- content: svelteTemplates.storiesTs.content,
161
+ source: t.storiesTs.source,
162
+ content: t.storiesTs.content,
148
163
  dest: path.join(componentDir, `${componentName}.stories.ts`),
149
164
  vars: ctx,
150
165
  })),
151
166
  when(answers.withStyles, debug("Creating styles file")),
152
167
  when(answers.withStyles, template({
153
- source: svelteTemplates.styles.source,
154
- content: svelteTemplates.styles.content,
168
+ source: t.styles.source,
169
+ content: t.styles.content,
155
170
  dest: path.join(componentDir, "styles.css"),
156
171
  vars: ctx,
157
172
  })),
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAGrD,gFAAgF;AAChF,gEAAgE;AAChE,gFAAgF;AAEhF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE7D,MAAM,eAAe,GAAG;IACtB,SAAS,EAAE,MAAM,YAAY,CAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAC1D;IACD,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,C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I,EAAE,GAAG;aACV,CAAC,CACH;YAED,KAAK,CAAC,sCAAsC,CAAC;YAC7C,yBAAyB,CAAC,SAAS,EAAE,aAAa,CAAC;YAEnD,IAAI,CAAC,WAAW,aAAa,iBAAiB,YAAY,EAAE,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;CAC6D,CAAC;AAEjE,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA6DH;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;CAqGqC,CAAC;AAErD,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4EH;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;CAsGqC,CAAC;AAErD,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgDH,QAAA,MAAM,SAAS;;;;;;;;;;;CAgHgD,CAAC;AAEhE,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgEH,QAAA,MAAM,SAAS;;;;;;;;;;;CAiHgD,CAAC;AAEhE,eAAe,SAAS,CAAC"}
@@ -1,8 +1,19 @@
1
1
  /**
2
- * Load a template file eagerly, with compiled binary support.
2
+ * Load a template file eagerly, with compiled-binary support.
3
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).
4
+ * In a source run (or tests) the template is read from disk. In the standalone
5
+ * `bun build --compile` binary the `.ejs` files are not on disk, so the loader
6
+ * falls back to an EMBEDDED MANIFEST injected by the host via
7
+ * {@link setEmbeddedTemplates} — a map keyed by DIRECTORY-QUALIFIED path
8
+ * (`component/<framework>/<file>`), compiled into the binary as inline strings.
9
+ *
10
+ * The directory-qualified key is what fixes the historic basename collision:
11
+ * several component templates share a basename across frameworks
12
+ * (`types.ts.ejs`, `index.ts.ejs`, `styles.css.ejs`, `stories.ts.ejs` exist in
13
+ * `react/`, `svelte/` and `lit/`). The previous fallback matched embedded blobs
14
+ * by BARE BASENAME, so a compiled binary could silently emit the WRONG
15
+ * framework's template (whichever blob was encountered first). Matching on the
16
+ * framework-qualified suffix instead guarantees the right framework's file.
6
17
  */
7
18
  export interface LoadedTemplate {
8
19
  /** Original source path (for diagnostics and dry-run display). */
@@ -11,7 +22,42 @@ export interface LoadedTemplate {
11
22
  readonly content: string;
12
23
  }
13
24
  /**
14
- * Load a template from disk or embedded files.
25
+ * Inject the embedded-template manifest — the compiled-binary fallback. Called
26
+ * once by the host (the `pragma` `create` runtime) before the component
27
+ * generators are imported, so their eager `loadTemplate` calls can resolve from
28
+ * it when the disk read fails. Passing an empty map (the default) restores pure
29
+ * disk loading.
30
+ *
31
+ * @param manifest - Directory-qualified path → template content.
32
+ */
33
+ export declare function setEmbeddedTemplates(manifest: Readonly<Record<string, string>>): void;
34
+ /**
35
+ * Load a template from disk, or — when the disk read fails (a compiled binary) —
36
+ * from the injected embedded manifest. SYNCHRONOUS.
37
+ *
38
+ * Disk is consulted FIRST: a source run reads the real file, and the compiled
39
+ * binary's absolute `/$bunfs/…` source paths never exist on a user's disk, so it
40
+ * always falls through to the manifest. A source run and a compiled run are
41
+ * therefore byte-identical (the manifest is generated from the same files).
42
+ *
43
+ * This is synchronous (both branches — `readFileSync` and the in-memory manifest
44
+ * lookup — are), so a generator can load its templates LAZILY inside its
45
+ * synchronous `generate(answers): Task` call rather than via a module-eval
46
+ * top-level `await`. That is the whole point of the sync form: a READ command
47
+ * (which never calls `generate()`) then never touches a template, regardless of
48
+ * whether bun's `--compile` code-splitting kept the generator module lazy — the
49
+ * exact fragility that crashed `pragma block list` on some bun versions.
50
+ *
51
+ * @param source - Absolute path to the template file.
52
+ * @returns Loaded template with path and content.
53
+ * @throws If the template is neither on disk nor in the embedded manifest — fail
54
+ * loud rather than return `""`, which callers do not guard against and would
55
+ * silently write as empty files (notably in a compiled binary).
56
+ */
57
+ export declare function loadTemplateSync(source: string): LoadedTemplate;
58
+ /**
59
+ * Async wrapper over {@link loadTemplateSync}, kept for callers that await a
60
+ * template load. The body is fully synchronous.
15
61
  *
16
62
  * @param source - Absolute path to the template file.
17
63
  * @returns Loaded template with path and content.
@@ -1 +1 @@
1
- {"version":3,"file":"loadTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAA8B,YAAY,CACxC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CA6CzB"}
1
+ {"version":3,"file":"loadTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAUD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACzC,IAAI,CAEN;AAoBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAqB/D;AAED;;;;;;GAMG;AACH,wBAA8B,YAAY,CACxC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAEzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiBH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAkCzD;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;CA6IiD,CAAC;AAEjE,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiBH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAiDzD;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;CA8IiD,CAAC;AAEjE,eAAe,SAAS,CAAC"}
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.31.0",
4
+ "version": "0.33.0",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
7
7
  "module": "dist/esm/index.js",
@@ -10,6 +10,10 @@
10
10
  ".": {
11
11
  "types": "./dist/types/index.d.ts",
12
12
  "import": "./dist/esm/index.js"
13
+ },
14
+ "./embedded": {
15
+ "types": "./dist/types/shared/loadTemplate.d.ts",
16
+ "import": "./dist/esm/shared/loadTemplate.js"
13
17
  }
14
18
  },
15
19
  "files": [
@@ -46,20 +50,20 @@
46
50
  },
47
51
  "devDependencies": {
48
52
  "@biomejs/biome": "2.4.9",
49
- "@canonical/biome-config": "^0.31.0",
50
- "@canonical/typescript-config": "^0.31.0",
51
- "@canonical/webarchitect": "^0.31.0",
53
+ "@canonical/biome-config": "^0.33.0",
54
+ "@canonical/typescript-config": "^0.33.0",
55
+ "@canonical/webarchitect": "^0.33.0",
52
56
  "@types/bun": "^1.3.10",
53
57
  "@types/node": "^24.12.0",
54
58
  "typescript": "^5.9.3",
55
59
  "vitest": "^4.0.18"
56
60
  },
57
61
  "dependencies": {
58
- "@canonical/utils": "^0.31.0"
62
+ "@canonical/utils": "^0.33.0"
59
63
  },
60
64
  "peerDependencies": {
61
65
  "@canonical/summon-core": "^0.30.0",
62
66
  "@canonical/task": "^0.30.0"
63
67
  },
64
- "gitHead": "d4a67ebe42e62b8cf3de77f42f537309ca88d672"
68
+ "gitHead": "fca2bc4440fff2d511fc8db6686f9b19222fdbc7"
65
69
  }