docs: Add guidance for usage with Deno bundler
See original GitHub issueWith Deno there are a couple extra steps to consume Excalibur to bundle a game for the browser.
esm.sh should generate a bundle that works, tested locally.
deno info https://esm.sh/excalibur
type: JavaScript
dependencies: 180 unique (total 816KB)
https://esm.sh/excalibur (192B)
├── https://cdn.esm.sh/v54/excalibur@0.25.0/deno/excalibur.js (355.24KB)
Outputs a bundle:
deno bundle https://esm.sh/excalibur excalibur.bundle.js
Using native in browser
Using as a native module works in Chrome without any extras:
<script type="module">
import ex from "./excalibur.bundle.js";
const game = new ex.Engine();
game.start();
</script>
Using with bundler
More likely users will be writing a game and will be importing Excalibur. Deno uses URLs so we’ll want to showcase pinning.
A custom tsconfig.json
has to be used with strict
turned off and there are a few DOM libs to add:
tsconfig.json
{
"compilerOptions": {
"strict": false,
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"]
}
}
Then Excalibur can be imported from esh.sh:
index.ts
import { Engine } from "https://esm.sh/excalibur";
const game = new ex.Engine();
game.start();
And Deno will successfully bundle:
deno bundle index.ts game.bundle.js --config tsconfig.json
Check file:///E:/Development/Junk/deno-excalibur/index.ts
Bundle file:///E:/Development/Junk/deno-excalibur/index.ts
Emit "game.bundle.js" (678.91KB)
Thanks to @tarsupin for bringing this up.
_Originally posted by @kamranayub in https://github.com/excaliburjs/Excalibur/discussions/2060#discussioncomment-1480720_
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (13 by maintainers)
Top Results From Across the Web
deno bundle | Manual
Bundling. deno bundle [URL] will output a single JavaScript file for consumption in Deno, which includes all dependencies of the specified input.
Read more >Introduction | Manual - Deno
Can bundle scripts into a single JavaScript file or executable. Supports the use of existing npm modules. Philosophy. Deno aims to be a...
Read more >Style Guide | Manual - Deno
Use the term "module" instead of "library" or "package". ... For clarity and consistency, avoid the terms "library" and "package". Instead use "module"...
Read more >deno compile | Manual
Use deno compile --help to list the full values for each compilation target. Unavailable in executables. Workers; Dynamic Imports; Web Storage API ·...
Read more >Command Line Interface | Manual - Deno
To see subcommand-specific help, for example for bundle , you can similarly ... Detailed guides for each subcommand can be found here. ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kamranayub, @eonarheim: This was my first PR. Thank You for all your help!
Thanks, those will be fixed in an upcoming PR I am working on that will upgrade our dependencies