Skip to content

Commit

Permalink
feat(dev-server): remove plugins (#152)
Browse files Browse the repository at this point in the history
* feat(dev-server): remove plugins

* add changeset
  • Loading branch information
yusukebe authored Jul 6, 2024
1 parent a0c6343 commit 1782639
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 240 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-coats-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/vite-dev-server': minor
---

feat: remove plugins
14 changes: 3 additions & 11 deletions packages/dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
"types": "./dist/adapter/cloudflare.d.ts",
"require": "./dist/adapter/cloudflare.cjs",
"import": "./dist/adapter/cloudflare.js"
},
"./cloudflare-pages": {
"types": "./dist/cloudflare-pages/index.d.ts",
"require": "./dist/cloudflare-pages/index.cjs",
"import": "./dist/cloudflare-pages/index.js"
}
},
"typesVersions": {
Expand All @@ -47,9 +42,6 @@
],
"cloudflare": [
"./dist/adapter/cloudflare.d.ts"
],
"cloudflare-pages": [
"./dist/cloudflare-pages/index.d.ts"
]
}
},
Expand Down Expand Up @@ -83,8 +75,8 @@
"node": ">=18.14.1"
},
"dependencies": {
"@hono/node-server": "^1.11.0",
"miniflare": "^3.20231218.2",
"@hono/node-server": "^1.12.0",
"miniflare": "^3.20240701.0",
"minimatch": "^9.0.3"
}
}
}
1 change: 0 additions & 1 deletion packages/dev-server/src/adapter/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { WebSocketPair } from 'miniflare'
import { getPlatformProxy } from 'wrangler'
import type { Adapter, Env } from '../types.js'

// We detect if the environment is `workerd` by checking if the WebSocketPair is available.
Object.assign(globalThis, { WebSocketPair })

type CloudflareAdapterOptions = {
Expand Down
27 changes: 0 additions & 27 deletions packages/dev-server/src/cloudflare-pages/cloudflare-pages.test.ts

This file was deleted.

71 changes: 0 additions & 71 deletions packages/dev-server/src/cloudflare-pages/cloudflare-pages.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/dev-server/src/cloudflare-pages/index.ts

This file was deleted.

19 changes: 2 additions & 17 deletions packages/dev-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import type http from 'http'
import { getRequestListener } from '@hono/node-server'
import { minimatch } from 'minimatch'
import type { Plugin as VitePlugin, ViteDevServer, Connect } from 'vite'
import { createViteRuntime } from 'vite'
import type { ViteRuntime } from 'vite/runtime'
import type { getEnv as cloudflarePagesGetEnv } from './cloudflare-pages/index.js'
import type { Env, Fetch, EnvFunc, Plugin, Adapter } from './types.js'
import type { Env, Fetch, EnvFunc, Adapter } from './types.js'

export type DevServerOptions = {
entry?: string
Expand All @@ -14,11 +11,6 @@ export type DevServerOptions = {
exclude?: (string | RegExp)[]
ignoreWatching?: (string | RegExp)[]
env?: Env | EnvFunc
/**
* @deprecated
* The `plugins` option is deprecated. Use the `adapter` instead of it.
*/
plugins?: Plugin[]
/**
* This can be used to inject environment variables into the worker from your wrangler.toml for example,
* by making use of the helper function `getPlatformProxy` from `wrangler`.
Expand Down Expand Up @@ -48,15 +40,9 @@ export type DevServerOptions = {
*
*/
adapter?: Adapter | Promise<Adapter> | (() => Adapter | Promise<Adapter>)
/**
* @deprecated
* The `cf` option is maintained for backward compatibility, but it will be obsolete in the future.
* Instead, use the `env` option.
*/
cf?: Parameters<typeof cloudflarePagesGetEnv>[0]
}

export const defaultOptions: Required<Omit<DevServerOptions, 'env' | 'cf' | 'adapter'>> = {
export const defaultOptions: Required<Omit<DevServerOptions, 'env' | 'adapter'>> = {
entry: './src/index.ts',
export: 'default',
injectClientScript: true,
Expand All @@ -71,7 +57,6 @@ export const defaultOptions: Required<Omit<DevServerOptions, 'env' | 'cf' | 'ada
/^\/node_modules\/.*/,
],
ignoreWatching: [/\.wrangler/, /\.mf/],
plugins: [],
}

export function devServer(options?: DevServerOptions): VitePlugin {
Expand Down
5 changes: 0 additions & 5 deletions packages/dev-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ export type Fetch = (
executionContext: ExecutionContext
) => Promise<Response>

export interface Plugin {
env?: Env | EnvFunc
onServerClose?: () => void | Promise<void>
}

export interface Adapter {
/**
* Environment variables to be injected into the worker
Expand Down
Loading

0 comments on commit 1782639

Please sign in to comment.