Merged
Merged
Conversation
| } | ||
| const { tsImport, register } = await import("tsx/esm/api") | ||
| unregister = register({ onImport }) | ||
| const module = await tsImport(modulePath, { |
| ```js title="summarize.genai.mjs" | ||
| const { summarize } = await import("./summarizer.mjs") | ||
| summarize(env.generator, env.files) | ||
| ``` |
| ```js title="summarize.genai.mts" | ||
| const { summarize } = await import("./summarizer.mts") | ||
| summarize(env.generator, env.files) | ||
| ``` |
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
| ## Module Imports | ||
|
|
||
| You can import module installed in your project. | ||
| You can import node packages installed in your project. |
| ## Script files | ||
|
|
||
| - GenAIScript will detect any file matching `*.genai.mjs` in your workspace. | ||
| - GenAIScript will detect any file matching `*.genai.mjs`, `*.genai.js`, `*.genai.mts` in your workspace. |
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
| ## Module Imports | ||
|
|
||
| You can import module installed in your project. | ||
| You can import node packages installed in your project. |
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
| import.meta.url ?? | ||
| new URL(__filename ?? host.projectFolder(), "file://").href | ||
|
|
||
| trace?.itemValue(`import`, `${modulePath}, parent: ${parentURL}`) |
| } | ||
|
|
||
| const current = await tryReadText(host.path.join(folder, defName)) | ||
| if (defName === "tsconfig.json" && !ts) continue |
Labels
None yet