(
root: string,
path: string,
{resolveImport = getModuleResolver(root, path), ...options}: RenderModuleOptions = {}
)
| 290 | export type RenderModuleOptions = Omit<TranspileModuleOptions, "root" | "path" | "servePath" | "params">; |
| 291 | |
| 292 | export async function renderModule( |
| 293 | root: string, |
| 294 | path: string, |
| 295 | {resolveImport = getModuleResolver(root, path), ...options}: RenderModuleOptions = {} |
| 296 | ): Promise<string> { |
| 297 | const module = findModule(root, path); |
| 298 | if (!module) throw enoent(path); |
| 299 | const imports = new Set<string>(); |
| 300 | const resolutions = new Set<string>(); |
| 301 | for (const i of await getModuleStaticImports(root, path)) { |
| 302 | const r = await resolveImport(i); |
| 303 | if (!resolutions.has(r)) { |
| 304 | resolutions.add(r); |
| 305 | imports.add(i); |
| 306 | } |
| 307 | } |
| 308 | const input = Array.from(imports, (i) => `import ${JSON.stringify(i)};\n`) |
| 309 | .concat(`export * from ${JSON.stringify(path)};\n`) |
| 310 | .join(""); |
| 311 | return await transpileModule(input, {root, path, servePath: path, params: module.params, resolveImport, ...options}); |
| 312 | } |
no test coverage detected