Gathering detailed insights and metrics for wds
Gathering detailed insights and metrics for wds
Gathering detailed insights and metrics for wds
Gathering detailed insights and metrics for wds
Real fast development reloading for server side TypeScript projects.
npm install wds
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
113 Stars
305 Commits
6 Forks
6 Watching
10 Branches
11 Contributors
Updated on 28 Nov 2024
TypeScript (87.49%)
JavaScript (6.97%)
Shell (4.62%)
Nix (0.93%)
Cumulative downloads
Total Downloads
Last day
-81.8%
174
Compared to previous day
Last week
36.3%
7,324
Compared to previous week
Last month
121.8%
15,433
Compared to previous month
Last year
-5.7%
177,879
Compared to previous year
14
A reloading dev server for server side TypeScript projects. Compiles TypeScript real fast, on demand, using ESM loaders and require.extensions
. Similar to and inspired by ts-node-dev
and tsx
.
wds stands for Whirlwind (or web) Development Server.
After installing wds
, you can use it like you might use the node
command line program:
1# run one script with wds compiling TS to JS 2wds some-script.ts 3 4# run one server with wds `watch` mode, re-running the server on any file changes 5wds --watch some-server.ts 6 7# run one script with node command line arguments that you'd normally pass to `node` 8wds --inspect some-test.test.ts
swc
--watch
mode, restarting the process on file changes--commands
mode--inspect
or --prof
ipc
channels between the process starting wds
and the node.js process started by wds
.You deserve to get stuff done. You deserve a fast iteration loop. If you're writing TypeScript for node, you still deserve to have a fast iteration loop, but with big codebases, tsc
can get quite slow. Instead, you can use a fast TS => JS transpiler like swc
to quickly reload your runtime code and get to the point where you know if your code is working as fast as possible. This means a small sacrifice: tsc
no longer typechecks your code as you run it, and so you must supplement with typechecking in your editor or in CI.
This tool prioritizes rebooting a node.js TypeScript project as fast as possible. This means it doesn't typecheck. Type checking gets prohibitively slow at scale, so we recommend using this separate typechecker approach that still gives you valuable feedback out of band. That way, you don't have to wait for it to see if your change actually worked. We usually don't run anything other than VSCode's TypeScript integration locally, and then run a full tsc --noEmit
in CI.
1Options: 2 --help Show help [boolean] 3 --version Show version number [boolean] 4 -c, --commands Trigger commands by watching for them on stdin. Prevents 5 stdin from being forwarded to the process. Only command right 6 now is `rs` to restart the server. [boolean] [default: false] 7 -w, --watch Trigger restarts by watching for changes to required files 8 [boolean] [default: false] 9 -s, --supervise Supervise and restart the process when it exits indefinitely 10 [boolean] [default: false]
Configuration for wds
is done by adding a wds.js
file to your pacakge root, and optionally a .swcrc
file if using swc
as your compiler backend.
An wds.js
file needs to export an object like so:
1module.exports = { 2 // which file extensions to build, defaults to .js, .jsx, .ts, .tsx extensions 3 extensions: [".tsx", ".ts", ".mdx"], 4 5 // file paths to explicitly not transform for speed, defaults to [], plus whatever the compiler backend excludes by default, which is `node_modules` for swc 6 ignore: ["spec/integration/**/node_modules", "spec/**/*.spec.ts", "cypress/", "public/"], 7};
swc
(the default)swc
is the fastest TypeScript compiler we've found and is the default compiler wds
uses. wds
sets up a default swc
config suitable for compiling to JS for running in Node:
1{ 2 "jsc": { 3 "parser": { 4 "syntax": "typescript", 5 "decorators": true, 6 "dynamicImport": true 7 }, 8 "target": "es2020" 9 }, 10 "module": { 11 "type": "commonjs", 12 // turn on lazy imports for maximum reboot performance 13 "lazy": true 14 } 15}
Note: the above config is different than the default swc config. It's been honed to give maximum performance for server start time, but can be adjusted by creating your own .swcrc
file.
Configuring swc
's compiler options with with wds
can be done using the wds.js
file. Create a file named wds.js
in the root of your repository with content like this:
1// wds.js 2module.exports = { 3 swc: { 4 env: { 5 targets: { 6 node: 12, 7 }, 8 }, 9 }, 10};
You can also use swc
's built in configuration mechanism which is an .swcrc
file. Using an .swcrc
file is useful in order to share swc
configuration between wds
and other tools that might use swc
under the hood as well, like @swc/jest
. To stop using wds
's default config and use the config from a .swcrc
file, you must configure wds to do so using wds.js
like so:
1// in wds.js 2module.exports = { 3 swc: ".swcrc", 4};
And then, you can use swc
's standard syntax for the .swcrc
file
1// in .swcrc, these are the defaults wds uses 2{ 3 "jsc": { 4 "parser": { 5 "syntax": "typescript", 6 "decorators": true, 7 "dynamicImport": true 8 }, 9 "target": "es2022" 10 }, 11 "module": { 12 "type": "commonjs", 13 // turn on lazy imports for maximum reboot performance 14 "lazy": true 15 } 16}
Refer to the SWC docs for more info.
ts-node-dev
ts-node-dev
(and ts-node
) accomplish a similar feat but are often 5-10x slower than wds
in big projects. They are loaded with features and will keep up with new TypeScript features much better as they use the mainline TypeScript compiler sources, and we think they make lots of sense! Because they use TypeScript proper for compilation though, even with --transpile-only
, they are destined to be slower than swc
. wds
is for the times where you care a lot more about performance and are ok with the tradeoffs swc
makes, like not supporting const enum
and being a touch behind on supporting new TypeScript releases.
No vulnerabilities found.
No security vulnerabilities found.