question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docs: Add guidance for usage with Deno bundler

See original GitHub issue

With 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:closed
  • Created 2 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
Return180bpmcommented, Oct 30, 2021

@kamranayub, @eonarheim: This was my first PR. Thank You for all your help!

1reaction
kamranayubcommented, Oct 30, 2021

Thanks, those will be fixed in an upcoming PR I am working on that will upgrade our dependencies

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found