From 8edbe81fa223f8073e8a291a330498fbc05c6de5 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Mon, 7 Mar 2022 22:39:16 +0100 Subject: [PATCH] fix: bug --- packages/vite/src/node/importGlob.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/vite/src/node/importGlob.ts b/packages/vite/src/node/importGlob.ts index 5382d674ac145f..9ce13c13b45a87 100644 --- a/packages/vite/src/node/importGlob.ts +++ b/packages/vite/src/node/importGlob.ts @@ -133,18 +133,19 @@ export async function transformImportGlob( ;[importee] = await normalizeUrl(file, pos) } imports.push(importee) - if ( - options?.as === 'raw' || - // TODO remove assert syntax for the Vite 3.0 release. - options?.assert?.type === 'raw' - ) { - logger.warn( - colors.yellow( - colors.bold( - "(!) Use `import.meta.globEager('/dir/*.js', { as: 'raw' })` instead of `import.meta.globEager('/dir/*.js', { assert: { type: 'raw' } })` (it will be deprecated in Vite 3.0)." + // TODO remove assert syntax for the Vite 3.0 release. + const isRawAssert = options?.assert?.type === 'raw' + const isRawType = options?.as === 'raw' + if (isRawType || isRawAssert) { + if (isRawAssert) { + logger.warn( + colors.yellow( + colors.bold( + "(!) Use `import.meta.globEager('/dir/*.js', { as: 'raw' })` instead of `import.meta.globEager('/dir/*.js', { assert: { type: 'raw' } })` (it will be deprecated in Vite 3.0)." + ) ) ) - ) + } entries += ` ${JSON.stringify(file)}: ${JSON.stringify( await fsp.readFile(path.join(base, file), 'utf-8') )},`