Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: typecheck Deno files #2485

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/deno-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,17 @@ jobs:
uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: Vendor Deno Dependencies
uses: actions/github-script@v7
with:
script: |
const { vendorDeno } = await import('${{ github.workspace }}/tools/build.js')

await vendorDeno('edge-runtime')
await vendorDeno('tools/deno')
- name: Typecheck
run: npm run typecheck:deno
- name: Lint
run: npm run lint:deno
- name: Test
run: deno test -A edge-runtime/
run: npm run test:deno
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
- name: Lint
# github adds inline annotation for compact or stylish format
# which is different than our default for local usage
run: npm run lint -- --format=compact
run: npm run lint:node -- --format=compact
- name: Types
run: npm run typecheck
run: npm run typecheck:node
# we still want to check types if lint fails just to know everything
# and not peel errors to uncover new ones of different type
if: always()
10 changes: 0 additions & 10 deletions deno.json

This file was deleted.

29 changes: 29 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"exclude": [
"edge-runtime/vendor/",
"edge-runtime/shim/"
],
"lint": {
"include": [
"tools/deno/",
"edge-runtime/"
],
"exclude": [
// TODO(serhalp) Remove this exclusion and fix the lint errors here.
"edge-runtime/lib"
]
},
"test": {
"include": [
"tools/deno/",
"edge-runtime/"
]
},
"tasks": {
// TODO(serhalp) Add `edge-runtime/**/*.ts` and add a vendoring step in CI.
"typecheck": "deno check tools/deno/**/*.ts"
},
"imports": {
"@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts"
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"pretest:integration": "npm run build && node tests/prepare.mjs",
"build": "node ./tools/build.js",
"build:watch": "node ./tools/build.js --watch",
"lint": "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
"lint:node": "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
"lint:deno": "deno lint",
"lint": "npm run lint:node && npm run lint:deno",
"format:fix": "prettier --write .",
"format:check": "prettier --check .",
"test": "vitest",
Expand All @@ -30,7 +32,10 @@
"test:ci:unit-and-integration": "vitest run --reporter=default --retry=3 --project=unit --project=integration",
"test:ci:smoke": "vitest run --reporter=default --retry=3 --project=smoke",
"test:ci:e2e": "playwright test",
"typecheck": "tsc --noEmit"
"test:deno": "deno test -A",
"typecheck:node": "tsc --noEmit",
"typecheck:deno": "deno task typecheck",
"typecheck": "npm run typecheck:node && npm run typecheck:deno"
},
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion tests/test-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
{
"file": "test/e2e/app-dir/app-static/app-static.test.ts",
"reason": "Uses CLI output",
"tests": ["app-dir static/dynamic handling should warn for too many cache tags"]
"tests": [
"app-dir static/dynamic handling should warn for too many cache tags"
]
},
{
"file": "test/e2e/app-dir/parallel-routes-and-interception/parallel-routes-and-interception.test.ts",
Expand Down
8 changes: 4 additions & 4 deletions tools/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ async function bundle(entryPoints, format, watch) {
})
}

async function vendorDeno() {
const vendorSource = resolve('edge-runtime/vendor.ts')
const vendorDest = resolve('edge-runtime/vendor')
export async function vendorDeno(dir) {
const vendorSource = resolve(join(dir, 'vendor.ts'))
const vendorDest = resolve(join(dir, 'vendor'))

try {
await execaCommand('deno --version')
Expand All @@ -100,7 +100,7 @@ const args = new Set(process.argv.slice(2))
const watch = args.has('--watch') || args.has('-w')

await Promise.all([
vendorDeno(),
vendorDeno('edge-runtime'),
bundle(entryPointsESM, 'esm', watch),
...entryPointsCJS.map((entry) => bundle([entry], 'cjs', watch)),
cp('src/build/templates', join(OUT_DIR, 'build/templates'), { recursive: true, force: true }),
Expand Down
Loading