fix(admin-vite-plugin): Normalize file paths and add tests (#9595)
**What** - #9338 had a regression which caused the import path in some virtual modules to be invalid on Windows. - This PR fixes the issue so we now again create the correct import paths, and adds tests to prevent this from slipping in again.
This commit is contained in:
committed by
GitHub
parent
84fa6ccde5
commit
813efeae51
@@ -20,7 +20,7 @@ import {
|
||||
traverse,
|
||||
} from "../babel"
|
||||
import { logger } from "../logger"
|
||||
import { crawl, getParserOptions } from "../utils"
|
||||
import { crawl, getParserOptions, normalizePath } from "../utils"
|
||||
import { getConfigArgument, getModel, validateLink } from "./helpers"
|
||||
|
||||
type CustomFieldDisplay = {
|
||||
@@ -288,5 +288,6 @@ function generateCustomFieldConfigName(index: number): string {
|
||||
}
|
||||
|
||||
function generateImport(file: string, index: number): string {
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${file}"`
|
||||
const path = normalizePath(file)
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${path}"`
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
traverse,
|
||||
} from "../babel"
|
||||
import { logger } from "../logger"
|
||||
import { crawl, getParserOptions } from "../utils"
|
||||
import { crawl, getParserOptions, normalizePath } from "../utils"
|
||||
import { getConfigArgument, getModel, validateLink } from "./helpers"
|
||||
|
||||
type CustomFieldConfigField = {
|
||||
@@ -263,7 +263,8 @@ function generateCustomFieldConfigName(index: number): string {
|
||||
}
|
||||
|
||||
function generateImport(file: string, index: number): string {
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${file}"`
|
||||
const path = normalizePath(file)
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${path}"`
|
||||
}
|
||||
|
||||
function getForms(
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
traverse,
|
||||
} from "../babel"
|
||||
import { logger } from "../logger"
|
||||
import { crawl, getParserOptions } from "../utils"
|
||||
import { crawl, getParserOptions, normalizePath } from "../utils"
|
||||
import { getConfigArgument, getModel } from "./helpers"
|
||||
|
||||
type ParsedCustomFieldLink = {
|
||||
@@ -138,7 +138,8 @@ function generateCustomFieldConfigName(index: number): string {
|
||||
}
|
||||
|
||||
function generateImport(file: string, index: number): string {
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${file}"`
|
||||
const path = normalizePath(file)
|
||||
return `import ${generateCustomFieldConfigName(index)} from "${path}"`
|
||||
}
|
||||
|
||||
function getLink(
|
||||
|
||||
Reference in New Issue
Block a user