Skip to content

Commit

Permalink
Fixed imports of vite.config.extension.ts from projects (#9622)
Browse files Browse the repository at this point in the history
Path that was being used for fs.existsSync was not correct, missing .ts on
the end, so no extensions were being found or applied.

Import of extensions from correct staticPath triggers a TypeError:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

This is a known issue with vite importing from files in other packages
in a monorepo: vitejs/vite#5370

For now, using the workaround of importing via the relative path. Switching
to bun will apparently solve this.
  • Loading branch information
barankyle committed Jan 17, 2024
1 parent e86a70a commit c01356a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ const getProjectConfigExtensions = async (config: UserConfig) => {
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
for (const project of projects) {
const staticPath = path.resolve(__dirname, `../projects/projects/`, project, 'vite.config.extension')
const staticPath = path.resolve(__dirname, `../projects/projects/`, project, 'vite.config.extension.ts')
if (fs.existsSync(staticPath)) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { default: viteConfigExtension } = await import(staticPath)
const { default: viteConfigExtension } = await import(
`../projects/projects/${project}/vite.config.extension.ts`
)
if (typeof viteConfigExtension === 'function') {
const configExtension = await viteConfigExtension()
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down

0 comments on commit c01356a

Please sign in to comment.