An opinionated deno project starter template.
This template provides examples and a batteries included experience for starting a new project in Deno land.
$ just all
- Sane VSCode defaults for deno
- Benchmarking example
- Compiled executable example
- Testing example
- Vendoring capabilities
- NPM Compatibility
- Deno confiugration
- Import Map usage example
- Standard MIT Licence
- Executable entry point (main.ts)
- Library entry points (mod.ts)
code --install-extension denoland.vscode-deno
Manual
Refer to deno manual installation
Refer to just packages installation
Note: Windows users, please use git-bash
to interact with just
.vscode
VSCode configurationsextensions.json
VSCode extensionssettings.json
VSCode settings
bin/
deno compile
outputbuild_npm_package.ts
transforming fornpm
withdnt
deno.json
usingdeno.json
config fileimport_map.json
usingimport_map.json
lock.json
lockfilevendor
Vendored dependencies
hello_bench.ts
deno bench
examplehello_test.ts
deno test
examplejustfile
Justfile for running tasksLICENCE
default MIT licencemain.ts
compilation entry-pointmain.ts
mod.ts
library entry pointmod.ts
Tasks can be considered the equivalent of
npm
scripts. Deno counterpart exposesdeno task
command, and it's not ideal to write your tasks indeno.json
config. Therefore the author's best current advice is just using amakefile
. The sections are organized into Chores and Tasks.
dev_flags = --unstable -A -c ./deno.json
Default run flags:
- Enabling Deno Unstable APIs
- allowing All Permissions.
- Setting Deno Conifg path
prod_flags = --check --cached-only --no-remote --import-map=vendor/import_map.json --lock ./lock.json
Production flags:
- always type-check (tsc)
- use only cached deps
- no remote dependencies allowed
- point to vendored import-map always
- validate dependencies against lock file
Locking settings, defining the lock file.
dep_flags = --import-map ./import_map.json --lock ./lock.json
Dependency flags:
- use import map to resolve dependencies
- use/write lock file to
./lock.json
Path to test files (e.g.
./*_test.ts
)
Path to source files, default is any file in the root, (e.g.
./*.ts
)
all_files = "./*.ts ./node/*.ts"
Source + Test files.
udd = deno run -A https://deno.land/x/udd@0.7.3/main.ts
Alias for UDD library. Used for automatically updating dependencies.
just chores
: Update dependencies, write lock file, reload cache, vendor dependencies and load them into cache.just build
: Buildbin
,lib
andnpm
package.just
: chores && build
Modules are typically registered in the import-map.
update:
$(udd) main.ts $(dep_flags) --test="make test"
make deps
Look over import_map and dependency tree stemming from
main.ts
entry-point and update them to latest versions.
deps: lock reload vendor cache
Reload dependency tree without updating it.
lock:
deno cache $(dep_flags) --lock-write $(source_files)
Produce a lock file of the dependency tree.
reload:
deno cache -r $(dep_flags) $(source_files)
Reload local cache.
Import map overridden as config sets the vendored import-map. Obviously the vendoring can't depend on the import map it outputs.
vendor:
deno vendor $(dep_flags) --force $(source_files)
Vendor dependencies for production builds.
cache:
deno cache $(lock_flags) $(source_files)
Populate local cache from vendored dependencies for all source files.
bench: clean
deno bench $(run_flags)
Run benchmarks.
build-bin: cache
deno compile -o bin/hello_deno --import-map vendor/import_map.json $(run_flags) ./main.ts
Compile into a single executable.
build-npm:
deno run -A ./build_npm_package.ts $$VERSION
Build a package to be published on npm.
clean:
rm -rf bin npm
Clean previously built artifacts.
publish: deno build-npm
cd npm && npm publish
Release to NPM.
debug:
deno run --v8-flags=--prof --inspect-brk $(run_flags) bench/run_suite.ts
Debug
lint:
deno lint $(all_files)
Run linter.
format:
deno fmt $(all_files) $(docs)
Run formatting.
test: clean
deno test $(run_flags) --coverage=cov_profile $(test_files)
deno test $(run_flags) --doc mod.ts
Run tests.