Skip to content

Instantly share code, notes, and snippets.

@fusionstrings
Created December 9, 2024 20:53
Show Gist options
  • Save fusionstrings/2ee2ced7d1eb8a028823e4ed272bd0ed to your computer and use it in GitHub Desktop.
Save fusionstrings/2ee2ced7d1eb8a028823e4ed272bd0ed to your computer and use it in GitHub Desktop.
ESZIP
import { build, LoadResponse, Parser } from 'npm:@deno/eszip';
const moduleURL =
'https://raw.githubusercontent.com/fusionstrings/fusionstrings/refs/heads/creation/package/src/dom/home.ts';
const importmapURL =
'https://raw.githubusercontent.com/fusionstrings/fusionstrings/refs/heads/creation/deno.json';
const path = new URL('./home.ts', import.meta.url).href;
console.log(path);
async function main() {
const eszip = await build([path], undefined, importmapURL);
const parser = await Parser.createInstance();
const specifiers = await parser.parseBytes(eszip);
console.log('specifier', specifiers);
console.log(typeof specifiers)
await parser.load();
for await (const specifier of specifiers) {
console.log('s', specifier);
const code = await parser.getModuleSource(specifier);
console.log('code');
console.log(code);
}
await Deno.writeFile('path.eszip2', eszip);
return eszip;
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment