Skip to content

Commit

Permalink
test: update tests for enforced dot prefix on relative files output
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeyper committed Dec 18, 2023
1 parent 68eca0c commit 75c9eef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-vite-meta-glob/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nodePath from 'path'
import type babelCore from '@babel/core'
import glob from 'glob'
import { globSync } from 'glob'

export default function viteMetaGlobBabelPlugin({
types: t
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function viteMetaGlobBabelPlugin({
t.isStringLiteral(args[0])
) {
const cwd = nodePath.dirname(sourceFile)
const globPaths = glob.sync(args[0].value, { cwd })
const globPaths = globSync(args[0].value, { cwd, dotRelative: true }).sort()

const replacement = t.objectExpression(
globPaths.map((globPath) =>
Expand Down Expand Up @@ -85,7 +85,7 @@ export default function viteMetaGlobBabelPlugin({
t.isBooleanLiteral(eagerOption[0].value)
) {
const cwd = nodePath.dirname(sourceFile)
const globPaths = glob.sync(args[0].value, { cwd })
const globPaths = globSync(args[0].value, { cwd, dotRelative: true }).sort()

if (eagerOption[0].value.value) {
const identifiers = globPaths.map((_, idx) => t.identifier(`__glob__0_${idx}`))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export const hot = import.meta.hot
export const envVar = process.env.VITE_VAR
export const modules = {
'files/file1.ts': () => import('files/file1.ts')
'./files/file1.ts': () => import('./files/file1.ts')
}
export const eagerModules = {
'files/file1.ts': require('files/file1.ts')
'./files/file1.ts': require('./files/file1.ts')
}
export const hot = module.hot
Expand All @@ -38,10 +38,10 @@ export const hot = import.meta.hot
export const envVar = process.env.VITE_VAR
export const modules = {
'files/file1.ts': () => import('files/file1.ts')
'./files/file1.ts': () => import('./files/file1.ts')
}
export const eagerModules = {
'files/file1.ts': require('files/file1.ts')
'./files/file1.ts': require('./files/file1.ts')
}
export const hot = module.hot
Expand Down Expand Up @@ -82,10 +82,10 @@ export const hot = import.meta.hot
export const envVar = import.meta.env.VITE_VAR
export const modules = {
'files/file1.ts': () => import('files/file1.ts')
'./files/file1.ts': () => import('./files/file1.ts')
}
export const eagerModules = {
'files/file1.ts': require('files/file1.ts')
'./files/file1.ts': require('./files/file1.ts')
}
export const hot = import.meta.hot
Expand Down

0 comments on commit 75c9eef

Please sign in to comment.