3

Could you please help me with replacing deprecetad deno bundle command?

I wanted to change it for esbuild, but running a command:

./node_modules/.bin/esbuild --bundle lib/commands/abc/main.ts --outfile=mod.abc.ts

give me an error:

[ERROR] Top-level await is currently not supported with the "iife" output format

I have tried also with --format=cjs and --format=esm option, but the output still is different than deno bundle output. eg. there are not imports included.

How should I use it?

Or maybe can you help me with other option? The goal is to quickly remove deno bundle without main code modification.

Kim Yu
  • 205
  • 2
  • 9

2 Answers2

1

The esbuild CLI interface does not support bundling of Deno TypeScript module code (at least when using remote imports — e.g. https://deno.land/...).

The JavaScript API for esbuild can handle those imports by using a plugin that's maintained by one of the Deno core team members: https://github.com/lucacasonato/esbuild_deno_loader

The readme for the plugin explains its usage, and the JavaScript API for esbuild is extensively documented as well: https://esbuild.github.io/

jsejcksn
  • 27,667
  • 4
  • 38
  • 62
1

There are three recommended replacements for deno bundle in in the current Deno version v1.32.3:

Warning "deno bundle" is deprecated and will be removed in the future.
Use alternative bundlers like "deno_emit", "esbuild" or "rollup" instead.

See:

If esbuild doesn't work then you may check the other ones. Also, esbuild has a project deno-esbuild that might be relevant:

Rollup has some instructions abut Deno usage:

deno_emit is the most Deno-centric from those three - it has similar functionality as the removed Deno.emit() but as a user loadable module, to avoid including its code in the main Deno binary. In principle it should be the most similar to the deno bundle but I'm not sure how stable it is already.

rsp
  • 107,747
  • 29
  • 201
  • 177