Commit 04e00a1
claude: Fix bundler async initialization with dynamic imports
Use dynamic imports to break async module initialization chains that caused esbuild bundling errors.
The issue was caused by two module-level import paths into render modules with async initialization:
1. check command → command-utils.ts → notebookContext (render modules)
2. quarto-api.ts → checkRender → render-shared.ts (async init)
When esbuild bundled these, it generated invalid JavaScript with await in non-async functions, causing "Unexpected reserved word" errors.
Solution: Convert static imports to dynamic imports that execute at runtime:
- src/command/command-utils.ts: Move projectContext, notebookContext, and reorderEngines imports into function body
- src/core/quarto-api.ts: Wrap checkRender export in arrow function with dynamic import
This defers module loading until the functions are actually called, avoiding top-level async initialization in the bundle.
Fixes prepare-dist workflow and allows test-bundle CI action to pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 5fbbf59 commit 04e00a1
2 files changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 8 | + | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
| |||
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
| |||
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
365 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
366 | 369 | | |
367 | 370 | | |
368 | 371 | | |
| |||
0 commit comments