♻️ Make vite configs compatible with the native config loader

Replace __dirname with import.meta.dirname in the plugins workspace
vite configs (root paths and the plugins-runtime tsconfigPath) and in
frontend/vite.config.js, dropping the fileURLToPath fallback.

Import vite.config.iife with the explicit .ts extension in the
plugin-api-test-suite headless/tests configs and allow it in
tsconfig.node.json (moduleResolution Bundler + noEmit), matching the
mcp/packages/plugin precedent.

Remove .storybook/vitest.setup.ts and its setupFiles entry;
@storybook/addon-vitest 10.3+ provisions preview annotations
automatically.

These clear the Vite `configLoader: 'native'` warnings ahead of that
loader becoming the default.

AI-assisted-by: omen-alpha
This commit is contained in:
Andrey Antukh 2026-09-07 20:42:50 +00:00
parent e4d1816117
commit 05ea09f2ba
15 changed files with 17 additions and 27 deletions

View File

@ -1,6 +0,0 @@
import { setProjectAnnotations } from '@storybook/react-vite';
import * as projectAnnotations from './preview';
// This is an important step to apply the right configuration when testing your stories.
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
setProjectAnnotations([projectAnnotations]);

View File

@ -7,12 +7,8 @@ import { playwright } from '@vitest/browser-playwright'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url";
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin"; import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
const dirname = const dirname = import.meta.dirname;
typeof __dirname !== "undefined"
? __dirname
: path.dirname(fileURLToPath(import.meta.url));
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon // More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
export default defineConfig({ export default defineConfig({
@ -45,15 +41,14 @@ export default defineConfig({
{browser: "chromium"}, {browser: "chromium"},
], ],
}, },
setupFiles: [".storybook/vitest.setup.ts"],
}, },
}, },
], ],
}, },
resolve: { resolve: {
alias: { alias: {
"@target": resolve(__dirname, "./target/storybook"), "@target": resolve(dirname, "./target/storybook"),
"@public": resolve(__dirname, "./resources/public/js/"), "@public": resolve(dirname, "./resources/public/js/"),
}, },
}, },
}); });

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
test: { test: {
watch: false, watch: false,
globals: true, globals: true,

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
test: { test: {
globals: true, globals: true,
environment: 'jsdom', environment: 'jsdom',

View File

@ -1,7 +1,7 @@
/// <reference types="vitest/config" /> /// <reference types="vitest/config" />
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
server: { server: {
port: 4202, port: 4202,
host: '0.0.0.0', host: '0.0.0.0',

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
test: { test: {
testTimeout: 20000, testTimeout: 20000,
watch: false, watch: false,

View File

@ -1,7 +1,7 @@
/// <reference types="vitest/config" /> /// <reference types="vitest/config" />
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
server: { server: {
port: 4202, port: 4202,
host: '0.0.0.0', host: '0.0.0.0',

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
test: { test: {
watch: false, watch: false,
globals: true, globals: true,

View File

@ -4,6 +4,7 @@
"outDir": "../../dist/out-tsc", "outDir": "../../dist/out-tsc",
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Bundler", "moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"types": ["node"], "types": ["node"],
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true "noUnusedParameters": true

View File

@ -1,4 +1,4 @@
import { iifeConfig } from './vite.config.iife'; import { iifeConfig } from './vite.config.iife.ts';
// Builds the CI test entry as a single self-executing (IIFE) bundle, evaluated // Builds the CI test entry as a single self-executing (IIFE) bundle, evaluated
// inside the Penpot plugin sandbox via `globalThis.ɵloadPlugin({ code })` by the // inside the Penpot plugin sandbox via `globalThis.ɵloadPlugin({ code })` by the

View File

@ -12,7 +12,7 @@ import { defineConfig, type UserConfig } from 'vite';
*/ */
export function iifeConfig(name: string, entry: string): UserConfig { export function iifeConfig(name: string, entry: string): UserConfig {
return defineConfig({ return defineConfig({
root: __dirname, root: import.meta.dirname,
resolve: { resolve: {
tsconfigPaths: true, tsconfigPaths: true,
}, },

View File

@ -1,4 +1,4 @@
import { iifeConfig } from './vite.config.iife'; import { iifeConfig } from './vite.config.iife.ts';
// Builds the test cases as a single self-executing (IIFE) bundle that publishes // Builds the test cases as a single self-executing (IIFE) bundle that publishes
// the discovered tests on `globalThis.__penpotReloadedTests`. The UI "Reload" // the discovered tests on `globalThis.__penpotReloadedTests`. The UI "Reload"

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
// Emit relative asset URLs in index.html so the built plugin works when served // Emit relative asset URLs in index.html so the built plugin works when served
// from a subdirectory (Penpot serves the bundled plugins under `/plugins/...`). // from a subdirectory (Penpot serves the bundled plugins under `/plugins/...`).
// Vite resolves `./` to `/` for the dev server, so `pnpm run dev` is unaffected. // Vite resolves `./` to `/` for the dev server, so `pnpm run dev` is unaffected.

View File

@ -2,7 +2,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
test: { test: {
watch: false, watch: false,
globals: true, globals: true,

View File

@ -7,7 +7,7 @@ import * as path from 'path';
import checker from 'vite-plugin-checker'; import checker from 'vite-plugin-checker';
export default defineConfig({ export default defineConfig({
root: __dirname, root: import.meta.dirname,
cacheDir: '../node_modules/.vite/plugins-runtime', cacheDir: '../node_modules/.vite/plugins-runtime',
resolve: { resolve: {
@ -17,7 +17,7 @@ export default defineConfig({
plugins: [ plugins: [
dts({ dts({
entryRoot: 'src', entryRoot: 'src',
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), tsconfigPath: path.join(import.meta.dirname, 'tsconfig.lib.json'),
}), }),
checker({ checker({
typescript: { typescript: {