From 62f3c0fe76f215cbe88b1a76408b09d74ad14f92 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 8 Jul 2023 06:56:12 +0200 Subject: [PATCH] Switch to `vite-string-plugin` (#25762) Switch to [`vite-string-plugin`](https://github.com/silverwind/vite-string-plugin) to load SVGs as string during tests. The plugin will also be useful once we switch to vite. --- package-lock.json | 33 ++++++++++----------------------- package.json | 2 +- vitest.config.js | 16 +--------------- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2db1ec660..c904826b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,6 @@ "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "3.2.1", "@playwright/test": "1.35.1", - "@rollup/pluginutils": "5.0.2", "@stoplight/spectral-cli": "6.8.0", "@vitejs/plugin-vue": "4.2.3", "eslint": "8.43.0", @@ -80,6 +79,7 @@ "stylelint-stylistic": "0.4.2", "svgo": "3.0.2", "updates": "14.2.8", + "vite-string-plugin": "1.1.0", "vitest": "0.32.2" }, "engines": { @@ -1294,28 +1294,6 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, - "node_modules/@rollup/pluginutils": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", - "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "estree-walker": "^2.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0||^2.0.0||^3.0.0" - }, - "peerDependenciesMeta": { - "rollup": { - "optional": true - } - } - }, "node_modules/@stoplight/better-ajv-errors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-1.0.3.tgz", @@ -10743,6 +10721,15 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/vite-string-plugin": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vite-string-plugin/-/vite-string-plugin-1.1.0.tgz", + "integrity": "sha512-RMxstCLl6Zyyz4tkzzHDFrrVvom1GAxjo2lTmgfus5CZYOnFNcJ2iQiDaFpc4KAOHSNkBNtkj5YauSs+f1gqCA==", + "dev": true, + "engines": { + "node": ">=16" + } + }, "node_modules/vite/node_modules/rollup": { "version": "3.25.3", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.3.tgz", diff --git a/package.json b/package.json index 0866f7e2a..aa8c04fb6 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "3.2.1", "@playwright/test": "1.35.1", - "@rollup/pluginutils": "5.0.2", "@stoplight/spectral-cli": "6.8.0", "@vitejs/plugin-vue": "4.2.3", "eslint": "8.43.0", @@ -79,6 +78,7 @@ "stylelint-stylistic": "0.4.2", "svgo": "3.0.2", "updates": "14.2.8", + "vite-string-plugin": "1.1.0", "vitest": "0.32.2" }, "browserslist": [ diff --git a/vitest.config.js b/vitest.config.js index 169a783fd..0b3a21094 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -1,20 +1,6 @@ import {defineConfig} from 'vitest/dist/config.js'; -import {readFile} from 'node:fs/promises'; -import {dataToEsm} from '@rollup/pluginutils'; -import {extname} from 'node:path'; import vue from '@vitejs/plugin-vue'; - -function stringPlugin() { - return { - name: 'string-plugin', - enforce: 'pre', - async load(id) { - const path = id.split('?')[0]; - if (extname(path) !== '.svg') return null; - return dataToEsm(await readFile(path, 'utf8')); - } - }; -} +import {stringPlugin} from 'vite-string-plugin'; export default defineConfig({ test: {