diff --git a/README.md b/README.md index 838d929..47bfc0a 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,24 @@ [![Deploy to Fastly](https://deploy.edgecompute.app/button)](https://deploy.edgecompute.app/deploy) -Get to know the Fastly Compute environment with a basic starter that demonstrates routing, simple synthetic responses and code comments that cover common patterns. +Get to know the Fastly Compute environment with a basic starter in TypeScript that demonstrates routing, simple synthetic responses and code comments that cover common patterns. **For more details about other starter kits for Compute, see the [Fastly Documentation Hub](https://www.fastly.com/documentation/solutions/starters)** ## Features +* TypeScript source files +* `tsconfig.json` file to use as a starting point * Allow only requests with particular HTTP methods * Match request URL path and methods for routing * Build synthetic responses at the edge ## Understanding the code -This starter is intentionally lightweight, and requires no dependencies aside from the [`@fastly/js-compute`](https://www.npmjs.com/package/@fastly/js-compute) npm package. It will help you understand the basics of processing requests at the edge using Fastly. This starter includes implementations of common patterns explained in our [using Compute](https://www.fastly.com/documentation/guides/compute/javascript/) and [VCL migration](https://www.fastly.com/documentation/guides/compute/migrate/) guides. +This starter kit is written in TypeScript and illustrates the same features as the [Compute JavaScript default starter kit](https://github.com/fastly/compute-starter-kit-typescript-default). It is intentionally lightweight, and requires no dependencies aside from the [`@fastly/js-compute`](https://www.npmjs.com/package/@fastly/js-compute) npm package. It will help you understand the basics of processing requests at the edge using Fastly. This starter includes implementations of common patterns explained in our [using Compute](https://www.fastly.com/documentation/guides/compute/javascript/) and [VCL migration](https://www.fastly.com/documentation/guides/compute/migrate/) guides. The starter doesn't require the use of any backends. Once deployed, you will have a Fastly service running on Compute that can generate synthetic responses at the edge. -The starter doesn't require the use of any backends. Once deployed, you will have a Fastly service running on Compute that can generate synthetic responses at the edge. +The Compute JavaScript SDK [has built-in support](https://www.fastly.com/documentation/guides/compute/developer-guides/javascript/#built-in-typescript) for executing TypeScript source files that contain only erasable TypeScript syntax. In this mode, type checking is not performed. -The template uses TypeScript to compile source files in `./src` into JS files in `./build`, which are then wrapped into `./bin/index.wasm` using the `js-compute-runtime` CLI tool bundled with the `@fastly/js-compute` npm package, and bundled into a `.tar.gz` file ready for deployment to Compute. +The SDK does not directly refer to the `tsconfig.json` file, but one is included to aid your IDE in coding support as well as to illustrate the recommended practice of running `tsc --noEmit` in a `prebuild` script to check for TypeScript errors, since the SDK does not perform type checking. ## Running the application diff --git a/fastly.toml b/fastly.toml index 53c3797..2317338 100644 --- a/fastly.toml +++ b/fastly.toml @@ -2,7 +2,7 @@ # https://developer.fastly.com/reference/fastly-toml/ authors = [""] -description = "A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules." +description = "A basic TypeScript starter kit that demonstrates routing, simple synthetic responses and overriding caching rules." language = "javascript" manifest_version = 3 name = "Default starter for TypeScript" diff --git a/package.json b/package.json index f72b68a..01b2266 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "@fastly/js-compute": "^3.33.2" }, "devDependencies": { - "@fastly/cli": "^11.0.0", + "@fastly/cli": "^12.0.0", "typescript": "^5.2.2" }, "scripts": { - "prebuild": "tsc", - "build": "js-compute-runtime build/index.js bin/main.wasm", + "prebuild": "tsc --noEmit", + "build": "js-compute-runtime src/index.ts bin/main.wasm", "start": "fastly compute serve", "deploy": "fastly compute publish" } diff --git a/tsconfig.json b/tsconfig.json index 20b433b..277d971 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,17 @@ { "compilerOptions": { "strict": true, - "module": "ES2022", + "erasableSyntaxOnly": true, + "skipLibCheck": true, "target": "ES2022", + "lib": [ "ES2022" ], + "module": "ESNext", "moduleResolution": "bundler", "customConditions": [ "fastly" ], + "types": [ "@fastly/js-compute" ], "esModuleInterop": true, - "lib": [ "ES2022" ], - "rootDir": "src", - "outDir": "build" - }, - "include": [ - "./src/**/*.js", - "./src/**/*.ts", - ], - "exclude": [ - "node_modules" - ] + "isolatedModules": true, + "verbatimModuleSyntax": true, + "allowImportingTsExtensions": true + } }