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

fix(dev-server): add .mf to ignoreWatching #111

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

tseijp
Copy link
Contributor

@tseijp tseijp commented Mar 18, 2024

The change is minimal, adding .mf to ignoreWatching in vite-plugins/packages/dev-server/src/dev-server.ts.

// dev-server.ts
- ignoreWatching: [/\.wrangler/],
+ ignoreWatching: [/\.wrangler/, /\.mf/],

I've been developing with hono-x and cloudflare d1, but frequently encountered vite errors, causing the server to stop many time.

warn - No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
warn - https://tailwindcss.com/docs/content-configuration
/___/node_modules/wrangler/wrangler-dist/cli.js:29573
            throw a;
            ^

Error: The server is being restarted or closed. Request is outdated
    at throwClosedServerError (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:50329:17)
    at transformRequest (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:53416:9)
    at Proxy.warmupRequest (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:64313:19)
    at file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:65812:32
    at async Promise.all (index 0)
    at async TransformContext.transform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:65670:13)
    at async Object.transform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:50838:30)
    at async loadAndTransform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:53611:29)
    at async viteTransformMiddleware (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:63409:32) {
  code: 'ERR_CLOSED_SERVER'
}

Even without file changes, the vite server kept reloading. Adding .mf to server.watch.ignore resolved the errors, suggesting .mf updates caused clashes.

...
  return {
    server: {
      watch: {
        ignored: [/\.wrangler/, /\.mf/],
      },
...

For reference, I'm using the following vite.config.ts. Developing with react and tailwind on hono-x has been very comfortable and enjoyable. Thank you!

import pages from '@hono/vite-cloudflare-pages'
import honox from 'honox/vite'
import { defineConfig } from 'vite'
import { getPlatformProxy } from 'wrangler'

export default defineConfig(async ({ mode }) => {
  if (mode === 'client') {
    return {
      build: {
        rollupOptions: {
          input: ['./app/client.ts', './app/style.css'],
          output: {
            entryFileNames: 'static/client.js',
            chunkFileNames: 'static/assets/[name]-[hash].js',
            assetFileNames: 'static/assets/[name].[ext]',
          },
        },
      },
    }
  } else {
    const { env, dispose } = await getPlatformProxy()

    return {
      server: {
        watch: {
          ignored: [/\.wrangler/, /\.mf/],
        },
      },
      ssr: {
        external: ['react', 'react-dom'],
      },
      plugins: [
        honox({
          devServer: {
            env,
            plugins: [
              {
                onServerClose: dispose,
              },
            ],
          },
        }),
        pages(),
      ],
    }
  }
})

I've been using cloudflare pages for a long time and am truly grateful. Typically using AWS or GCP for the backend, discovering hono led me to cloudflare's d1.
Given my limited experience with cloudflare d1, I would appreciate it if you could close my PR if it's off the mark.
Thank you!

Copy link

changeset-bot bot commented Mar 18, 2024

🦋 Changeset detected

Latest commit: bfcb35f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/vite-dev-server Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tseijp tseijp changed the title fix(dev-server): add to (#111) fix(dev-server): add .mf to ignoreWatching (#111) Mar 18, 2024
* fix(dev-server): add `/\.mf/` to `ignoreWatching`

* add changeset
@tseijp tseijp force-pushed the fix/add-ignoreWatching-path branch from 0173c41 to bfcb35f Compare March 18, 2024 08:46
@tseijp tseijp changed the title fix(dev-server): add .mf to ignoreWatching (#111) fix(dev-server): add .mf to ignoreWatching Mar 18, 2024
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

@tseijp

Thank you! Merge this now.

@yusukebe yusukebe merged commit fcc98f9 into honojs:main Mar 22, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants