matthewp / astro-fastify

A Fastify adapter for Astro
62 stars 16 forks source link

Rollup failed to resolve import #10

Closed zAlweNy26 closed 1 year ago

zAlweNy26 commented 2 years ago

Hi, I'm trying to build for production, but I get this error when I do astro check && tsc --noEmit && astro build:

[vite]: Rollup failed to resolve import "C:UsersdanynDocumentsGitHubexplorershandbook
ode_modules@matthewpastro-fastifylibserver.js" from "@astrojs-ssr-virtual-entry".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

I did what he said:

vite: {
  build: {
    rollupOptions: {
      external: fileURLToPath(new URL('node_modules/@matthewp/astro-fastify/lib/server.js', import.meta.url))
    }
  }
}

But I still get the error.

matthewp commented 2 years ago

@zAlweNy26 That's an odd one. I assume this is a windows resolution issue. I'll take a look. This happens with astro build and not with astro check, I presume?

zAlweNy26 commented 2 years ago

Yes, I am using Windows 11, nothing to do with astro check, just a astro build issue.

espimarisa commented 1 year ago

Hey @matthewp, I can confirm that this is still an issue today - on Windows 10 22H2, pnpm 8.0.0, and Node v20. Running v2.1.5 of the package.

Does not happen with astro check, only happens with astro build. I get the same exact type of error, and adding the path to external does nothing to fix the issue.

Definitely worth looking into, seems like a pretty big roadblock currently.

matthewp commented 1 year ago

Would love a PR if anyone has time to look at this themselves.

SapphicMoe commented 1 year ago

@matthewp I figured out why this is happening. I solved this by appending double forward slashes to the path.

I have submitted a PR to fix this issue: https://github.com/matthewp/astro-fastify/pull/22