Skip to content

Commit c80d77d

Browse files
feat: add support for edge functions (#233)
* feat: add support for edge functions * chore: update lock file * chore: remove unused types * chore: remove unused file * feat: more things * chore: remove `.only` * refactor: rename prop * refactor: handle merge * fix: use `serverAddress` prop * chore: update Deno version in CI * fix: add dep * refactor: update bootstrap URL * feat: add dynamic bootstrap URL * refactor: fix lint issues * feat: add quiet flag * chore: update Node version * chore: fix packages * feat: use workers * fix: add missing site metadata * chore: fix test * Apply suggestions from code review Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com> * chore: fix formatting * fix: fix tests * chore: remove unused file * chore: add comment * refactor: conditionally start HTTP server * refactor: rename variables * Update packages/edge-functions/dev/node/main.test.ts Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com> * fix(deps): update lockfile * build: improve eslint config - move non-temporary config out of `eslint_temporary_suppressions` - configure `node-builtins` rule properly * refactor: fix lint errors * build: add new suppressions The new eslint setup was merged after most of the work on this PR was done. * chore(deps): bump @netlify/types in packages/edge-functions * ci: add missing build step to lint job * chore: update lockfile --------- Co-authored-by: Philippe Serhal <philippe.serhal@netlify.com>
1 parent efc7c35 commit c80d77d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2379
-232
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ jobs:
2525
- name: Install dependencies
2626
run: npm ci --no-audit
2727

28+
- name: Build
29+
run: npm run build --workspaces=true
30+
2831
- name: Lint
2932
run: npm run lint

.github/workflows/release-please.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ jobs:
5858
if: ${{ steps.release.outputs['packages/cache--release_created'] }}
5959
env:
6060
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
61+
- run: npm publish packages/edge-functions/ --provenance --access=public
62+
if: ${{ steps.release.outputs['packages/edge-functions--release_created'] }}
63+
env:
64+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
6165
- run: npm publish packages/functions/ --provenance --access=public
6266
if: ${{ steps.release.outputs['packages/functions--release_created'] }}
6367
env:

.github/workflows/test.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest, macOS-latest, windows-latest]
1919
node-version: ['*']
20-
deno-version: ['v1.37.0', 'v1.44.4']
2120
include:
2221
- os: ubuntu-latest
2322
node-version: '18.14.0'
24-
deno-version: 'v1.44.4'
2523
fail-fast: false
2624
steps:
2725
# Increasing the maximum number of open files. See:
@@ -41,7 +39,7 @@ jobs:
4139
- name: Setup Deno
4240
uses: denoland/setup-deno@v1
4341
with:
44-
deno-version: ${{ matrix.deno-version }}
42+
deno-version: 2.2.4
4543
- name: Setup Deno dependencies
4644
run: deno cache https://deno.land/x/eszip@v0.55.2/eszip.ts
4745
- name: Install dependencies

eslint.config.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @ts-check
2+
import { promises as fs } from 'node:fs'
23
import * as path from 'node:path'
34
import { fileURLToPath } from 'node:url'
45
import { includeIgnoreFile } from '@eslint/compat'
@@ -13,15 +14,25 @@ import temporarySuppressions from './eslint_temporary_suppressions.js'
1314
const __filename = fileURLToPath(import.meta.url)
1415
const __dirname = path.dirname(__filename)
1516

17+
const packagesPath = path.join(__dirname, 'packages')
18+
const packages = await fs.readdir(packagesPath)
19+
const packageIgnores = packages.map((name) => includeIgnoreFile(path.resolve(packagesPath, name, '.gitignore')))
20+
1621
export default tseslint.config(
1722
// Global rules and configuration
1823
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
24+
...packageIgnores,
1925
{
2026
linterOptions: {
2127
reportUnusedDisableDirectives: true,
2228
},
2329
},
2430

31+
// TODO: Move this to `edge-functions` package.
32+
{
33+
ignores: ['packages/**/deno'],
34+
},
35+
2536
// JavaScript-specific rules
2637
eslint.configs.recommended,
2738

@@ -73,12 +84,18 @@ export default tseslint.config(
7384
varsIgnorePattern: '^_',
7485
},
7586
],
87+
88+
// Empty functions and blocks are useful (e.g `noop() {}`, `catch {}`) but can mask unintentionally omitted
89+
// implementation. We should add explanatory comments like `// intentionally empty` and `// ignore error` in these
90+
// scenarios to communicate intent.
91+
'no-empty': 'off',
92+
'@typescript-eslint/no-empty-function': 'off',
7693
},
7794
},
7895

7996
// Tests
8097
{
81-
files: ['**/*.test.?(c|m)[jt]s?(x)'],
98+
files: ['**/*.test.?(c|m)[jt]s?(x)', '**/test/*'],
8299
plugins: { vitest },
83100
rules: {
84101
...vitest.configs.recommended.rules,
@@ -101,6 +118,15 @@ export default tseslint.config(
101118
],
102119
},
103120
],
121+
'n/no-unsupported-features/node-builtins': 'off',
122+
},
123+
},
124+
125+
// Config files
126+
{
127+
files: ['**/tsup.config.ts'],
128+
rules: {
129+
'n/no-unsupported-features/node-builtins': 'off',
104130
},
105131
},
106132

0 commit comments

Comments
 (0)