fastify / fastify-vite

Fastify plugin for Vite integration
MIT License
891 stars 75 forks source link

mts file extension is not supported for vite.config #142

Open edwardbrowncross opened 9 months ago

edwardbrowncross commented 9 months ago

Prerequisites

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.

galvez commented 9 months ago

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

favna commented 8 months ago

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

galvez commented 8 months ago

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