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

refactor(dev-server): use regexp #12

Merged
merged 1 commit into from
Oct 23, 2023
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
2 changes: 1 addition & 1 deletion packages/dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
},
"dependencies": {
"@hono/node-server": "^1.2.0",
"miniflare": "^3.20230904.0"
"miniflare": "^3.20231016.0"
}
}
4 changes: 2 additions & 2 deletions packages/dev-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type DevServerOptions = {
export const defaultOptions: Required<Omit<DevServerOptions, 'cf'>> = {
entry: './src/index.ts',
injectClientScript: true,
exclude: ['.*\\.ts', '.*\\.tsx', '\\/@.+', '\\/node_modules\\/.*'],
exclude: [/.*\.ts$/, /.*\.tsx$/, /^\/@.+$/, /^\/node_modules\/.*/],
}

interface ExecutionContext {
Expand Down Expand Up @@ -61,7 +61,7 @@ export function devServer(options?: DevServerOptions): Plugin {
const exclude = options?.exclude ?? defaultOptions.exclude

for (const pattern of exclude) {
const regExp = new RegExp(`^${pattern}$`)
const regExp = pattern instanceof RegExp ? pattern : new RegExp(`^${pattern}$`)
if (req.url && regExp.test(req.url)) {
return next()
}
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ __metadata:
bumpp: ^9.2.0
glob: ^10.3.4
hono: ^3.5.8
miniflare: ^3.20230904.0
miniflare: ^3.20231016.0
publint: ^0.1.12
rimraf: ^5.0.1
tsup: ^7.2.0
Expand Down Expand Up @@ -2952,7 +2952,7 @@ __metadata:
languageName: node
linkType: hard

"miniflare@npm:^3.20230904.0":
"miniflare@npm:^3.20231016.0":
version: 3.20231016.0
resolution: "miniflare@npm:3.20231016.0"
dependencies:
Expand Down