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-denoManual
Refer to deno manual installation
Refer to just packages installation
Note: Windows users, please use git-bash to interact with just
.vscodeVSCode configurationsextensions.jsonVSCode extensionssettings.jsonVSCode settings
bin/deno compileoutputbuild_npm_package.tstransforming fornpmwithdntdeno.jsonusingdeno.jsonconfig fileimport_map.jsonusingimport_map.jsonlock.jsonlockfilevendorVendored dependencies
hello_bench.tsdeno benchexamplehello_test.tsdeno testexamplejustfileJustfile for running tasksLICENCEdefault MIT licencemain.tscompilation entry-pointmain.tsmod.tslibrary entry pointmod.ts
Tasks can be considered the equivalent of
npmscripts. Deno counterpart exposesdeno taskcommand, and it's not ideal to write your tasks indeno.jsonconfig. 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.jsonDefault 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.jsonProduction 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.jsonDependency 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.tsAlias 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,libandnpmpackage.just: chores && build
Modules are typically registered in the import-map.
update:
$(udd) main.ts $(dep_flags) --test="make test"
make depsLook over import_map and dependency tree stemming from
main.tsentry-point and update them to latest versions.
deps: lock reload vendor cacheReload 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.tsCompile into a single executable.
build-npm:
deno run -A ./build_npm_package.ts $$VERSIONBuild a package to be published on npm.
clean:
rm -rf bin npmClean previously built artifacts.
publish: deno build-npm
cd npm && npm publishRelease to NPM.
debug:
deno run --v8-flags=--prof --inspect-brk $(run_flags) bench/run_suite.tsDebug
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.tsRun tests.