Skip to content

build: migrate bundle pipeline to tsdown #305

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
941 changes: 552 additions & 389 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/blobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"server.d.ts"
],
"scripts": {
"build": "tsup-node",
"dev": "tsup-node --watch",
"build": "tsdown",
"dev": "tsdown --watch",
"prepack": "npm run build",
"test": "run-s build test:ci",
"test:dev": "run-s build test:dev:*",
Expand All @@ -72,7 +72,7 @@
"npm-run-all2": "^8.0.4",
"semver": "^7.5.3",
"tmp-promise": "^3.0.3",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

export default defineConfig([
{
clean: true,
entry: ['src/server.ts', 'src/main.ts'],
tsconfig: 'tsconfig.json',
bundle: true,
format: ['cjs', 'esm'],
dts: true,
outDir: './dist',
watch: argv.includes('--watch'),
},
])
6 changes: 3 additions & 3 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"dist/**/*"
],
"scripts": {
"build": "tsup-node",
"dev": "tsup-node --watch",
"build": "tsdown",
"dev": "tsdown --watch",
"prepack": "npm run build",
"test": "run-s build test:ci",
"test:dev": "run-s build test:dev:*",
Expand All @@ -71,7 +71,7 @@
"@netlify/dev-utils": "3.2.1",
"@netlify/types": "2.0.2",
"npm-run-all2": "^7.0.2",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/bootstrap/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Operation, RequestContextFactory } from './environment.ts'
export { Operation, type RequestContextFactory } from './environment.ts'
export { NetlifyCache } from './cache.ts'
export { NetlifyCacheStorage } from './cachestorage.ts'
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

export default defineConfig([
{
clean: true,
format: ['cjs', 'esm'],
entry: ['src/bootstrap/main.ts', 'src/main.ts'],
tsconfig: 'tsconfig.json',
splitting: false,
bundle: true,
dts: true,
outDir: './dist',
watch: argv.includes('--watch'),
},
])
6 changes: 3 additions & 3 deletions packages/dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"dist/**/*"
],
"scripts": {
"build": "tsup-node",
"build": "tsdown",
"prepack": "npm run build",
"test": "vitest run",
"test:dev": "vitest",
"test:ci": "npm run build && vitest run",
"dev": "tsup-node --watch",
"dev": "tsdown --watch",
"publint": "npx -y publint --strict"
},
"keywords": [],
Expand All @@ -48,7 +48,7 @@
"@types/write-file-atomic": "^4.0.3",
"execa": "^8.0.1",
"tmp-promise": "^3.0.3",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/dev-utils/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export { getAPIToken } from './lib/api-token.js'
export { shouldBase64Encode } from './lib/base64.js'
export { renderFunctionErrorPage } from './lib/errors.js'
export { DevEvent, DevEventHandler } from './lib/event.js'
export { type DevEvent, type DevEventHandler } from './lib/event.js'
export { type Geolocation, mockLocation } from './lib/geo-location.js'
export { ensureNetlifyIgnore } from './lib/gitignore.js'
export { headers, toMultiValueHeaders } from './lib/headers.js'
export * as globalConfig from './lib/global-config.js'
export { Handler } from './lib/handler.js'
export { type Handler } from './lib/handler.js'
export { LocalState } from './lib/local-state.js'
export { type Logger, netlifyCommand, netlifyCyan, netlifyBanner } from './lib/logger.js'
export { memoize, MemoizeCache } from './lib/memoize.js'
export { killProcess, type ProcessRef } from './lib/process.js'
export { memoize, type MemoizeCache } from './lib/memoize.js'
export { HTTPServer } from './server/http_server.js'
export { watchDebounced } from './lib/watch-debounced.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

export default defineConfig([
{
Expand All @@ -9,9 +7,6 @@ export default defineConfig([
outDir: 'dist',
format: ['esm'],
dts: true,
splitting: false,
watch: argv.includes('--watch'),
platform: 'node',
bundle: true,
},
])
6 changes: 3 additions & 3 deletions packages/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"dist/**/*"
],
"scripts": {
"build": "tsup-node",
"build": "tsdown",
"prepack": "npm run build",
"test": "vitest run",
"test:dev": "vitest",
"test:ci": "npm run build && vitest run",
"dev": "tsup-node --watch",
"dev": "tsdown --watch",
"publint": "npx -y publint --strict"
},
"keywords": [],
Expand All @@ -48,7 +48,7 @@
"devDependencies": {
"@netlify/api": "^14.0.3",
"@netlify/types": "2.0.2",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

export default defineConfig([
{
Expand All @@ -9,9 +7,6 @@ export default defineConfig([
outDir: 'dist',
format: ['cjs', 'esm'],
dts: true,
splitting: false,
watch: argv.includes('--watch'),
platform: 'node',
bundle: true,
},
])
7 changes: 4 additions & 3 deletions packages/edge-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"deno/**/*"
],
"scripts": {
"build": "tsup-node",
"build": "tsdown",
"prepack": "npm run build",
"test": "vitest run",
"test:dev": "vitest",
"test:ci": "npm run build && vitest run",
"dev": "tsup-node --watch",
"dev": "tsdown --watch",
"publint": "npx -y publint --strict"
},
"keywords": [
Expand All @@ -51,8 +51,9 @@
},
"devDependencies": {
"@netlify/types": "2.0.2",
"esbuild": "^0.25.5",
"execa": "^8.0.1",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
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'
import { defineConfig } from 'tsdown'

const __filename = fileURLToPath(import.meta.url)

Expand All @@ -17,33 +15,24 @@ export default defineConfig([
format: ['esm'],
entry: ['src/main.ts'],
tsconfig: 'tsconfig.json',
splitting: false,
bundle: true,
dts: true,
outDir: './dist',
watch: argv.includes('--watch'),
},
{
clean: true,
format: ['esm'],
entry: ['src/version.ts'],
tsconfig: 'tsconfig.json',
splitting: false,
bundle: true,
dts: true,
outDir: './dist',
watch: argv.includes('--watch'),
},
{
clean: true,
outDir: 'dist-dev/node',
entry: ['dev/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
Expand All @@ -56,7 +45,7 @@ export default defineConfig([
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_modukes` directory.
// does not support HTTP imports when inside a `node_modules` directory.
const distBootstrapPath = path.resolve(distPath, 'deno', BOOTSTRAP_FILENAME)
await execa(
'deno',
Expand Down
6 changes: 3 additions & 3 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"internal.d.ts"
],
"scripts": {
"dev": "tsup-node --watch",
"build": "tsup-node",
"dev": "tsdown --watch",
"build": "tsdown",
"prepack": "npm run build",
"test": "run-s test:ci",
"test:dev": "run-s build test:dev:*",
Expand Down Expand Up @@ -99,7 +99,7 @@
"npm-run-all2": "^5.0.0",
"semver": "^7.6.3",
"tsd": "^0.32.0",
"tsup": "^8.0.2",
"tsdown": "^0.12.7",
"vitest": "^3.0.0"
},
"engines": {
Expand Down
16 changes: 11 additions & 5 deletions packages/functions/src/function/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export { HandlerContext } from './handler_context.js'
export { HandlerEvent } from './handler_event.js'
export { BuilderHandler, Handler, BackgroundHandler, HandlerCallback, StreamingHandler } from './handler.js'
export { BuilderResponse, HandlerResponse, StreamingResponse } from './handler_response.js'
export { Context, Config } from './v2.js'
export { type HandlerContext } from './handler_context.js'
export { type HandlerEvent } from './handler_event.js'
export {
type BuilderHandler,
type Handler,
type BackgroundHandler,
type HandlerCallback,
type StreamingHandler,
} from './handler.js'
export { type BuilderResponse, type HandlerResponse, type StreamingResponse } from './handler_response.js'
export { type Context, type Config } from './v2.js'
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

export default defineConfig([
{
Expand All @@ -9,21 +7,18 @@ export default defineConfig([
outDir: 'dist',
format: ['cjs', 'esm'],
dts: true,
splitting: false,
watch: argv.includes('--watch'),
platform: 'node',
bundle: true,
},
{
clean: true,
outDir: 'dist-dev',
entry: ['dev/main.ts'],
format: ['esm'],
dts: true,
splitting: false,
watch: argv.includes('--watch'),
platform: 'node',
bundle: true,
publicDir: 'dev/runtimes/nodejs',
copy: {
from: 'dev/runtimes/nodejs',
to: 'dist-dev',
},
},
])
6 changes: 3 additions & 3 deletions packages/headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"dist/**/*"
],
"scripts": {
"build": "tsup-node",
"dev": "tsup-node --watch",
"build": "tsdown",
"dev": "tsdown --watch",
"prepack": "npm run build",
"publint": "npx -y publint --strict",
"test": "vitest run",
Expand All @@ -34,7 +34,7 @@
"devDependencies": {
"@netlify/dev-utils": "^3.2.1",
"@types/node": "^20.17.57",
"tsup": "^8.0.0",
"tsdown": "^0.12.7",
"vitest": "^3.1.4"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { argv } from 'node:process'

import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'

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'),
},
])
Loading
Loading