]> source.dussan.org Git - gitea.git/commitdiff
Switch to `vite-string-plugin` (#25762)
authorsilverwind <me@silverwind.io>
Sat, 8 Jul 2023 04:56:12 +0000 (06:56 +0200)
committerGitHub <noreply@github.com>
Sat, 8 Jul 2023 04:56:12 +0000 (04:56 +0000)
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
package.json
vitest.config.js

index 2db1ec66077d9765c23a58543488776330c5481a..c904826b18223e9273be8b38dd0d643ca8e01559 100644 (file)
@@ -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": {
       "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",
         "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",
index 0866f7e2a1c101e7e528966042d18e4079bf3717..aa8c04fb6e053ebb4c4a6ce5fe80264908d02cbf 100644 (file)
@@ -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": [
index 169a783fdda5b08bf06f6c9583802344137eeb46..0b3a2109487893ef840d89f848fcc4d6a20550e2 100644 (file)
@@ -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: {