Skip to content
Merged
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
17 changes: 14 additions & 3 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,24 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- if:
${{ steps.release.outputs['packages/edge-functions--release_created'] || github.event_name ==
${{ steps.release.outputs['packages/edge-functions/prod--release_created'] || github.event_name ==
'workflow_dispatch' }}
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
npm publish packages/edge-functions/ --provenance --access=public || true
npm publish packages/edge-functions/prod/ --provenance --access=public || true
else
npm publish packages/edge-functions/ --provenance --access=public
npm publish packages/edge-functions/prod/ --provenance --access=public
fi
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- if:
${{ steps.release.outputs['packages/edge-functions/dev--release_created'] || github.event_name ==
'workflow_dispatch' }}
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
npm publish packages/edge-functions/dev/ --provenance --access=public || true
else
npm publish packages/edge-functions/dev/ --provenance --access=public
fi
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"packages/cache": "3.3.0",
"packages/dev": "4.6.2",
"packages/dev-utils": "4.3.0",
"packages/edge-functions": "2.19.0",
"packages/edge-functions/dev": "0.0.0",
"packages/edge-functions/prod": "2.19.0",
"packages/functions/prod": "5.0.0",
"packages/functions/dev": "1.0.0",
"packages/headers": "2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default tseslint.config(

// TODO: Move this to `edge-functions` package.
{
ignores: ['packages/**/deno', 'packages/edge-functions/bootstrap-bundle.mjs'],
ignores: ['packages/**/deno', 'packages/edge-functions/dev/bootstrap-bundle.mjs'],
},

// JavaScript-specific rules
Expand Down
19 changes: 2 additions & 17 deletions eslint_temporary_suppressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,32 +336,17 @@ export default [
},
},
{
files: ['packages/edge-functions/dev/node/main.test.ts'],
files: ['packages/edge-functions/dev/src/node/main.test.ts'],
rules: {
'@typescript-eslint/require-await': 'off',
},
},
{
files: ['packages/edge-functions/dev/node/main.ts'],
files: ['packages/edge-functions/dev/src/node/main.ts'],
rules: {
'@typescript-eslint/no-unnecessary-condition': 'off',
},
},
{
files: ['packages/edge-functions/src/version.test.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
},
},
{
files: ['packages/edge-functions/src/version.ts'],
rules: {
'@typescript-eslint/restrict-template-expressions': 'off',
},
},
{
files: ['packages/functions/dev/src/events.ts'],
rules: {
Expand Down
47 changes: 44 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"packages/runtime-utils",
"packages/blobs",
"packages/cache",
"packages/edge-functions",
"packages/edge-functions/prod",
"packages/edge-functions/dev",
"packages/functions/prod",
"packages/functions/dev",
"packages/headers",
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@netlify/blobs": "10.1.0",
"@netlify/config": "^23.2.0",
"@netlify/dev-utils": "4.3.0",
"@netlify/edge-functions": "2.19.0",
"@netlify/edge-functions-dev": "0.0.0",
"@netlify/functions-dev": "1.0.0",
"@netlify/headers": "2.1.0",
"@netlify/images": "1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type Logger,
HTTPServer,
} from '@netlify/dev-utils'
import { EdgeFunctionsHandler } from '@netlify/edge-functions/dev'
import { EdgeFunctionsHandler } from '@netlify/edge-functions-dev'
import { FunctionsHandler } from '@netlify/functions-dev'
import { HeadersHandler, type HeadersCollector } from '@netlify/headers'
import { ImageHandler } from '@netlify/images'
Expand Down
5 changes: 2 additions & 3 deletions packages/edge-functions/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist
dist-dev
dev/deno/bootstrap.mjs
dist/
dev/src/deno/bootstrap.mjs
50 changes: 50 additions & 0 deletions packages/edge-functions/dev/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@netlify/edge-functions-dev",
"version": "0.0.0",
"description": "Local emulation for Netlify Edge Functions",
"type": "module",
"engines": {
"node": ">=20.6.1"
},
"main": "./dist/node/main.js",
"exports": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loving these esm-only packages 😈

".": {
"types": "./dist/node/main.d.ts",
"default": "./dist/node/main.js"
}
},
"types": "./dist/node/main.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsup-node",
"prepack": "npm run build",
"test": "vitest run",
"test:dev": "vitest",
"dev": "tsup-node --watch"
},
"keywords": [
"netlify",
"edge functions"
],
"license": "MIT",
"repository": "netlify/primitives",
"bugs": {
"url": "https://github.com/netlify/primitives/issues"
},
"author": "Netlify Inc.",
"dependencies": {
"@netlify/dev-utils": "4.3.0",
"@netlify/edge-bundler": "^14.5.2",
"@netlify/edge-functions": "2.19.0",
"@netlify/edge-functions-bootstrap": "2.16.0",
"@netlify/runtime-utils": "2.2.0",
"get-port": "^7.1.0"
},
"devDependencies": {
"execa": "^8.0.1",
"tsup": "^8.0.0",
"vitest": "^3.0.0"
}
}
18 changes: 18 additions & 0 deletions packages/edge-functions/dev/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "esnext",
"rootDir": "./",
"outDir": "./dist",
"allowJs": true,
"declaration": true,
"esModuleInterop": true,
"sourceMap": false,
"removeComments": false,
"strict": true,
"moduleResolution": "node",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
}
49 changes: 49 additions & 0 deletions packages/edge-functions/dev/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { argv } from 'node:process'

import { getURL } from '@netlify/edge-functions-bootstrap/version'
import { execa } from 'execa'
import { defineConfig } from 'tsup'

const __filename = fileURLToPath(import.meta.url)

const BOOTSTRAP_FILENAME = 'bootstrap.mjs'

export default defineConfig({
clean: true,
outDir: 'dist/node',
entry: ['src/node/main.ts'],
format: ['esm'],
dts: true,
splitting: false,
watch: argv.includes('--watch'),
platform: 'node',
bundle: true,

// Using a custom function to copy the contents of the `deno` directory and
// preserve the original structure, so that the relative path to the worker
// files is consistent.
onSuccess: async () => {
const bootstrapURL = await getURL()
const denoPath = path.resolve(path.dirname(__filename), 'src', 'deno')
const distPath = path.resolve(path.dirname(__filename), 'dist')

await fs.cp(denoPath, path.resolve(distPath, 'deno'), { recursive: true })

// We need to bundle the bootstrap layer with the package because Deno
// does not support HTTP imports when inside a `node_modules` directory.
const distBootstrapPath = path.resolve(distPath, 'deno', BOOTSTRAP_FILENAME)
await execa('deno', ['run', '--allow-all', '--no-lock', 'bootstrap-bundle.mjs', bootstrapURL, distBootstrapPath], {
stdio: 'inherit',
})

// In addition to putting the bootstrap file in `dist`, we must also
// put it in the source directory so that the reference to the bootstrap
// file still works in tests and local development. This is not great. At
// least we're gitignoring the file so that it doesn't end up in version
// control.
await fs.cp(distBootstrapPath, path.resolve(denoPath, BOOTSTRAP_FILENAME))
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@
".": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"./dev": {
"types": "./dist-dev/node/main.d.ts",
"default": "./dist-dev/node/main.js"
},
"./version": {
"types": "./dist/version.d.ts",
"default": "./dist/version.js"
}
},
"types": "./dist/main.d.ts",
"files": [
"dist/**/*",
"dist-dev/**/*",
"deno/**/*"
],
"scripts": {
Expand All @@ -50,16 +41,10 @@
"test": "test"
},
"devDependencies": {
"execa": "^8.0.1",
"tsup": "^8.0.0",
"vitest": "^3.0.0"
},
"dependencies": {
"@netlify/dev-utils": "4.3.0",
"@netlify/edge-bundler": "^14.5.2",
"@netlify/edge-functions-bootstrap": "2.16.0",
"@netlify/runtime-utils": "2.2.0",
"@netlify/types": "2.1.0",
"get-port": "^7.1.0"
"@netlify/types": "2.1.0"
}
}
7 changes: 7 additions & 0 deletions packages/edge-functions/prod/src/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from 'vitest'

import * as main from './main.js'

test('Main file does not export anything', () => {
expect(Object.keys(main)).toStrictEqual([])
})
17 changes: 17 additions & 0 deletions packages/edge-functions/prod/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'

export default defineConfig([
{
clean: true,
format: ['esm'],
entry: ['src/main.ts'],
tsconfig: 'tsconfig.json',
splitting: false,
bundle: true,
dts: true,
outDir: './dist',
watch: argv.includes('--watch'),
},
])
10 changes: 0 additions & 10 deletions packages/edge-functions/src/version.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/edge-functions/src/version.ts

This file was deleted.

Loading