fastify/fastify-vite

mts file extension is not supported for vite.config

edwardbrowncross opened this issue · 3 comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.26.0

Plugin version

6.0.5

Node.js version

18.19.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

20.04

Description

If the vite.config file has a mts file extension (vite.config.mts), which is a file extension Vite suggests in its documentation, calling server.vite.ready() throws an error similar to the following:

node_modules/@fastify/vite/config.js:245
    bundle.dir = resolve(vite.root, vite.build.outDir)
                              ^

TypeError: Cannot read properties of null (reading 'root')

This is as a result of 'mts' not appearing in this array:
https://github.com/fastify/fastify-vite/blob/dev/packages/fastify-vite/config.js#L200

Steps to Reproduce

Change the file extension of your vite.config file to .mts

Expected Behavior

I expect the Vite config file to be detected, as Vite itself can detect it.

Good catch, will release a patch later today after work.

@galvez Any updates on this? I had to change my vitest config from .ts to .mjs in lieue of this issue being resolved.

Hey — I'll find some time tonight to get this sorted out and push a new release.