denoland / deno_emit

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
https://jsr.io/@deno/emit
MIT License
223 stars 23 forks source link

Unable to output during bundling: load_transformed failed: failed to analyze module: failed to resolve node:fs #186

Open jkilzi opened 4 months ago

jkilzi commented 4 months ago

Hi, it seems like deno_emit fails to handle node:* specifiers. Here is a repro:

// main.ts
import * as fs from 'node:fs';

fs.writeFileSync('message.txt', 'Hello world!');
// _bundler.ts
import { bundle } from 'jsr:@deno/emit';

const [mod] = Deno.args;
const { code } = await bundle(mod);
const bytes = new TextEncoder().encode(code);
const location = import.meta.resolve(mod).replace(/\.ts$/, '.js');
Deno.writeFileSync(location, bytes);

Execute it with: deno run -A _bundler.ts main.ts