Skip to content

Commit 5773910

Browse files
claude: Align engine template with build-ts-extension system
Remove vendored quarto-types approach and restructure engine template to match the build-ts-extension specification. Changes: - Remove backward compatibility quarto-types copy from prepare-dist.ts - Remove vendoring logic from artifacts/extension.ts - Move TypeScript source from _extensions/ to src/ in engine template - Update _extension.yml to reference .js output instead of .ts - Update imports to use @quarto/types via import map - Add build instructions to README - Fix deno.json to include "deno.ns" in lib array (both default and --init-config) Engine extensions now follow the spec: - Source in src/ - Build to _extensions/<name>/<name>.js using build-ts-extension - Reference types via import map (no vendored copies) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f91e87c commit 5773910

File tree

7 files changed

+32
-41
lines changed

7 files changed

+32
-41
lines changed

package/src/common/prepare-dist.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,6 @@ export async function prepareDist(
168168
);
169169
}
170170

171-
// Copy quarto-types for engine extension template (backward compatibility)
172-
info("Copying quarto-types.d.ts for engine extension template");
173-
copySync(
174-
join(config.directoryInfo.root, "packages/quarto-types/dist/index.d.ts"),
175-
join(config.directoryInfo.pkgWorking.share, "quarto-types.d.ts"),
176-
{ overwrite: true },
177-
);
178-
179171
// Copy quarto-types to extension-build directory
180172
// Note: deno.json and import-map.json are copied by supportingFiles() and
181173
// import-map.json is then updated by updateImportMap() for distribution

src/command/create/artifacts/extension.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -256,34 +256,6 @@ async function createExtension(
256256
quiet,
257257
);
258258

259-
// For engine extensions, copy the current quarto-types
260-
const createType = typeFromTemplate(createDirective.template);
261-
if (createType === "engine") {
262-
// Try to find types in the distribution (production)
263-
let typesSource = resourcePath("quarto-types.d.ts");
264-
265-
if (!existsSync(typesSource)) {
266-
// Development build - get from source tree
267-
const quartoRoot = Deno.env.get("QUARTO_ROOT");
268-
if (!quartoRoot) {
269-
throw new Error(
270-
"Cannot find quarto-types.d.ts. QUARTO_ROOT environment variable not set.",
271-
);
272-
}
273-
typesSource = join(quartoRoot, "packages/quarto-types/dist/index.d.ts");
274-
}
275-
276-
const typesTarget = join(
277-
target,
278-
"_extensions",
279-
createDirective.name,
280-
"types",
281-
"quarto-types.d.ts",
282-
);
283-
ensureDirSync(dirname(typesTarget));
284-
copySync(typesSource, typesTarget);
285-
}
286-
287259
return filesCreated[0];
288260
}
289261

src/command/dev-call/build-ts-extension/cmd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ async function initializeConfig(): Promise<void> {
281281
const config = {
282282
compilerOptions: {
283283
strict: true,
284-
lib: ["DOM", "ES2021"],
284+
lib: ["deno.ns", "DOM", "ES2021"],
285285
},
286286
importMap: importMapPath,
287287
};

src/resources/create/extensions/engine/README.ejs.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@ quarto add <github-organization>/<%= filesafename %>
1313
This will install the extension under the `_extensions` subdirectory.
1414
If you're using version control, you will want to check in this directory.
1515

16+
## Developing
17+
18+
This extension is written in TypeScript. The source code is in the `src/` directory.
19+
20+
### Building
21+
22+
To build the extension, you need to set up the build configuration and then run the build command:
23+
24+
```bash
25+
# Build the TypeScript source to JavaScript
26+
quarto dev-call build-ts-extension
27+
```
28+
29+
This will:
30+
31+
- Type-check your TypeScript code against Quarto's API types
32+
- Bundle the extension into `_extensions/<%= filesafename %>/<%= filesafename %>.js`
33+
34+
The built JavaScript file should be committed to version control along with the source.
35+
36+
Optionally, you can create a deno.json to further customize the build:
37+
38+
```bash
39+
# First time setup - creates deno.json with import map configuration
40+
quarto dev-call build-ts-extension --init-config
41+
```
42+
1643
## Using
1744

1845
_TODO_: Describe how to use your extension.

src/resources/create/extensions/engine/_extensions/qstart-filesafename-qend/_extension.ejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ version: <%= version %>
44
quarto-required: ">=<%= quartoversion %>"
55
contributes:
66
engines:
7-
- path: <%= filesafename %>.ts
7+
- path: <%= filesafename %>.js

src/resources/create/extensions/engine/_extensions/qstart-filesafename-qend/qstart-filesafename-qend.ejs.ts renamed to src/resources/create/extensions/engine/src/qstart-filesafename-qend.ejs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* It demonstrates the basic structure of an execution engine.
88
*/
99

10-
// Type imports from bundled quarto-types
10+
// Type imports from Quarto via import map
1111
import type {
1212
DependenciesOptions,
1313
EngineProjectContext,
@@ -19,7 +19,7 @@ import type {
1919
MappedString,
2020
PostProcessOptions,
2121
QuartoAPI,
22-
} from "./types/quarto-types.d.ts";
22+
} from "@quarto/types";
2323

2424
// Module-level quarto API reference
2525
let quarto: QuartoAPI;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"lib": ["DOM", "ES2021"]
4+
"lib": ["deno.ns", "DOM", "ES2021"]
55
},
66
"importMap": "./import-map.json"
77
}

0 commit comments

Comments
 (0)