nitro icon indicating copy to clipboard operation
nitro copied to clipboard

[vite] Adding a package import causes Nitro vite plugin to fail

Open alan-agius4 opened this issue 4 months ago • 2 comments

Environment

Node: 22.18.0 nitro-nightly: 3.0.0-20250717-115429.740761af

Reproduction

In https://github.com/nitrojs/vite-examples/tree/main/examples/basic-service add an imports field

Example

{
  "name": "nitro-vite-basic-service",
  "version": "0.0.0",
  "scripts": {
    "build": "vite build",
    "dev": "vite dev"
  },
  "imports": {
    "#vite-config": "./vite.config.ts"
  },
  "devDependencies": {
    "nitro": "npm:nitro-nightly",
    "vite": "^7"
  }
}

Describe the bug

When adding a package imports Nitro's virtual modules fail to be resolved

Missing "#nitro-internal-virtual/server-assets" specifier in "nitro-vite-basic-service" package

alan-agius4 avatar Aug 27 '25 07:08 alan-agius4

Can you please try latest nightly build npm:[email protected] (relavant fix was: f5f24698a0c2c4886524c03774ccb3edbf9f0667)

pi0 avatar Aug 27 '25 22:08 pi0

@pi0, I tried this out and I am still seeing the same error.

{
  "name": "nitro-vite-basic-service",
  "version": "0.0.0",
  "scripts": {
    "build": "vite build",
    "dev": "vite dev"
  },
  "imports": {
    "#vite-config": "./vite.config.ts"
  },
  "devDependencies": {
    "nitro": "npm:[email protected]",
    "vite": "^7"
  }
}
$ git clean -dxf
$ npm install
$ npm run dev
$ curl http://localhost:5173/ | grep "Missing"        
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     
<span>Missing "#nitro-internal-virtual/server-assets" specifier in "nitro-vite-basic-service" package</span>

alan-agius4 avatar Aug 28 '25 07:08 alan-agius4