[Experiment] Build the JS API with Deno instead of Rollup #1556
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⚠ This is an experiment, so this is not (yet?) ought to be merged.
As you can see, to build with deno, a very few amount of changes are necessary in order to make it work:
.ts
suffix to TS importsnode_modules
to import thegenerator-runtime
lib, use the one from Unpkg which is already bundledtsconfig.json
to use the Deno lib and specify the usage of the DOM library (since it's mostly dedicated to browsers)deno bundle src/bundle.ts --config=./tsconfig.json dist/bundle.js
, and the code is bundled.Of course, it must be checked by Tauri experts to be sure it contains everything one needs to use the API!
⬇ Click here to see the contents of the generated `bundle.js` file
Why?
import_map.json
in order to determine where the dependencies come from. It's similar to apackage.json
, but manually maintained. The latter is used in this PR.Cons
import_map.json
for each tool that has to be bundled.deno bundle
command doesn't allow multiple targets. For this, we need to create a specific script that makes use of the internal compiler API. It's not that much of a disadvantage per se, and it is only a problem if Tauri must publish more than one JS file for each tool. Note: today Tauri exports a CJS fileindex.js
and an ESM one.mjs
for each tool.Pros
esbuild
can still be used to minify the final package, it has to be scripted in the building process. After all,esbuild
is a Go package, and it has a Deno implementation: https://deno.land/x/[email protected]