From 87ecce5008190b0e53d50cd86612a8125ab7b30a Mon Sep 17 00:00:00 2001 From: Rom Date: Tue, 8 Mar 2022 09:12:55 +0100 Subject: [PATCH] fix: deprecate `{ assert: { type: raw }}` in favor of `{ as: raw }` (fix #7017) (#7215) --- docs/guide/features.md | 4 +- packages/playground/glob-import/index.html | 2 +- packages/vite/src/node/importGlob.ts | 37 ++++++++++++++----- packages/vite/src/node/optimizer/scan.ts | 12 ++++-- .../vite/src/node/plugins/importAnalysis.ts | 1 + .../src/node/plugins/importAnalysisBuild.ts | 1 + packages/vite/types/importMeta.d.ts | 16 +++++--- 7 files changed, 51 insertions(+), 22 deletions(-) diff --git a/docs/guide/features.md b/docs/guide/features.md index a892182678fc1b..7bf870646da909 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -298,10 +298,10 @@ const modules = { } ``` -`import.meta.glob` and `import.meta.globEager` also support importing files as strings, similar to [Importing Asset as String](https://vitejs.dev/guide/assets.html#importing-asset-as-string). Here, we use the [Import Assertions](https://github.com/tc39/proposal-import-assertions#synopsis) syntax to import. +`import.meta.glob` and `import.meta.globEager` also support importing files as strings (similar to [Importing Asset as String](https://vitejs.dev/guide/assets.html#importing-asset-as-string)) with the [Import Reflection](https://github.com/tc39/proposal-import-reflection) syntax: ```js -const modules = import.meta.glob('./dir/*.js', { assert: { type: 'raw' } }) +const modules = import.meta.glob('./dir/*.js', { as: 'raw' }) ``` The above will be transformed into the following: diff --git a/packages/playground/glob-import/index.html b/packages/playground/glob-import/index.html index bb5e2f3c18f752..52d41b817a169c 100644 --- a/packages/playground/glob-import/index.html +++ b/packages/playground/glob-import/index.html @@ -40,7 +40,7 @@