Peli de Halleux (pelikhan) · GitHub

Merged

Merged

Conversation

github-actions[bot]

github-actions[bot]

github-actions[bot]

github-actions[bot]

github-actions[bot]

github-actions[bot]

}
const { tsImport, register } = await import("tsx/esm/api")
unregister = register({ onImport })
const module = await tsImport(modulePath, {

github-actions[bot]

```js title="summarize.genai.mjs"
const { summarize } = await import("./summarizer.mjs")
summarize(env.generator, env.files)
```

github-actions[bot]

```js title="summarize.genai.mts"
const { summarize } = await import("./summarizer.mts")
summarize(env.generator, env.files)
```

github-actions[bot]

- `.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.

github-actions[bot]

## Module Imports

You can import module installed in your project.
You can import node packages installed in your project.

github-actions[bot]

```

## File imports
## JavaScript imports

github-actions[bot]


## TypeScript imports

TypeScript (`.mts`) files can be imported using **dynamic** import only.

github-actions[bot]

## 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.

github-actions[bot]

- `.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.

github-actions[bot]

## Module Imports

You can import module installed in your project.
You can import node packages installed in your project.

github-actions[bot]

- `.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.

github-actions[bot]

import.meta.url ??
new URL(__filename ?? host.projectFolder(), "file://").href

trace?.itemValue(`import`, `${modulePath}, parent: ${parentURL}`)

github-actions[bot]

}

const current = await tryReadText(host.path.join(folder, defName))
if (defName === "tsconfig.json" && !ts) continue

github-actions[bot]

@@ -111,7 +111,7 @@ async function callExpander(
}

try {

@pelikhan

@pelikhan

Labels

None yet

Read the original on github.com ↗