From e8cedbbc28cc9c9ad6881f551263ca992a9ee3b1 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Sat, 11 Feb 2023 03:28:22 +0800 Subject: [PATCH 1/6] refactor(playground): move to ESM module and add type check for config --- playground/alias/vite.config.js | 11 +- playground/assets-sanitize/vite.config.js | 5 +- .../__tests__/relative-base/vite.config.js | 3 +- .../__tests__/runtime-base/vite.config.js | 3 +- .../assets/vite.config-relative-base.js | 14 +- playground/assets/vite.config-runtime-base.js | 15 +-- playground/assets/vite.config.js | 39 +++--- playground/backend-integration/vite.config.js | 14 +- playground/cli-module/vite.config.js | 1 + playground/cli/vite.config.js | 5 +- .../config/packages/entry/vite.config.ts | 1 + playground/css-codesplit-cjs/vite.config.js | 8 +- playground/css-codesplit/vite.config.js | 8 +- playground/css-sourcemap/vite.config.js | 11 +- playground/css/vite.config-relative-base.js | 14 +- playground/css/vite.config.js | 121 +++++++++--------- playground/define/vite.config.js | 49 +++---- playground/dynamic-import/vite.config.js | 9 +- playground/env-nested/vite.config.js | 5 +- playground/env/vite.config.js | 5 +- playground/extensions/vite.config.js | 7 +- playground/external/vite.config.js | 1 + playground/fs-serve/root/vite.config.js | 11 +- playground/glob-import/vite.config.ts | 1 + playground/hmr/vite.config.ts | 1 + playground/html/vite.config.js | 11 +- playground/js-sourcemap/vite.config.js | 10 +- .../legacy/vite.config-custom-filename.js | 8 +- .../legacy/vite.config-multiple-output.js | 3 +- playground/legacy/vite.config.js | 12 +- playground/lib/vite.config.js | 75 +++++------ playground/lib/vite.dyimport.config.js | 12 +- playground/lib/vite.nominify.config.js | 8 +- playground/minify/vite.config.js | 1 + .../multiple-entrypoints/vite.config.js | 9 +- playground/nested-deps/vite.config.js | 10 +- playground/object-hooks/vite.config.ts | 1 + playground/optimize-deps/vite.config.js | 11 +- .../__tests__/preload-disabled/vite.config.js | 3 +- .../__tests__/resolve-deps/vite.config.js | 3 +- .../preload/vite.config-preload-disabled.ts | 1 + .../preload/vite.config-resolve-deps.ts | 1 + playground/preload/vite.config.ts | 1 + playground/resolve-config/root/vite.config.ts | 7 +- playground/resolve/vite.config.js | 11 +- playground/ssr-noexternal/vite.config.js | 2 +- playground/ssr-resolve/vite.config.js | 1 + playground/ssr-webworker/vite.config.js | 3 + playground/tailwind-sourcemap/vite.config.js | 10 +- playground/tailwind/vite.config.ts | 1 + playground/transform-plugin/vite.config.js | 9 +- playground/wasm/vite.config.ts | 1 + playground/worker/__tests__/es/vite.config.js | 3 +- .../worker/__tests__/iife/vite.config.js | 3 +- .../__tests__/relative-base/vite.config.js | 3 +- .../__tests__/sourcemap-hidden/vite.config.js | 4 +- .../__tests__/sourcemap-inline/vite.config.js | 4 +- .../worker/__tests__/sourcemap/vite.config.js | 4 +- playground/worker/vite.config-es.js | 8 +- playground/worker/vite.config-iife.js | 7 +- .../worker/vite.config-relative-base.js | 9 +- playground/worker/vite.config-sourcemap.js | 21 +-- 62 files changed, 354 insertions(+), 299 deletions(-) diff --git a/playground/alias/vite.config.js b/playground/alias/vite.config.js index cdabb2594d8367..a0423eb75e4ae7 100644 --- a/playground/alias/vite.config.js +++ b/playground/alias/vite.config.js @@ -1,9 +1,8 @@ -const path = require('node:path') +// @ts-check +import path from 'node:path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ resolve: { alias: [ { find: 'fs', replacement: path.resolve(__dirname, 'test.js') }, @@ -39,4 +38,4 @@ module.exports = { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: true, }, -} +}) diff --git a/playground/assets-sanitize/vite.config.js b/playground/assets-sanitize/vite.config.js index c259a739d608b0..331ae14e189337 100644 --- a/playground/assets-sanitize/vite.config.js +++ b/playground/assets-sanitize/vite.config.js @@ -1,6 +1,7 @@ -const { defineConfig } = require('vite') +// @ts-check +import { defineConfig } from 'vite' -module.exports = defineConfig({ +export default defineConfig({ build: { //speed up build minify: false, diff --git a/playground/assets/__tests__/relative-base/vite.config.js b/playground/assets/__tests__/relative-base/vite.config.js index 6837b8ef975a3d..80cc0fd001524f 100644 --- a/playground/assets/__tests__/relative-base/vite.config.js +++ b/playground/assets/__tests__/relative-base/vite.config.js @@ -1 +1,2 @@ -module.exports = require('../../vite.config-relative-base') +// @ts-check +export { default } from '../../vite.config-relative-base' diff --git a/playground/assets/__tests__/runtime-base/vite.config.js b/playground/assets/__tests__/runtime-base/vite.config.js index fdc2a616ab2d80..8fef6220d2f94d 100644 --- a/playground/assets/__tests__/runtime-base/vite.config.js +++ b/playground/assets/__tests__/runtime-base/vite.config.js @@ -1 +1,2 @@ -module.exports = require('../../vite.config-runtime-base') +// @ts-check +export { default } from '../../vite.config-runtime-base' diff --git a/playground/assets/vite.config-relative-base.js b/playground/assets/vite.config-relative-base.js index 7edbaf07c95c29..0d7c1bc213d735 100644 --- a/playground/assets/vite.config-relative-base.js +++ b/playground/assets/vite.config-relative-base.js @@ -1,15 +1,14 @@ -/** - * @type {import('vite').UserConfig} - */ +// @ts-check +import { defineConfig } from 'vite' +import baseConfig from './vite.config.js' -const baseConfig = require('./vite.config.js') -module.exports = { +export default defineConfig({ ...baseConfig, base: './', // relative base to make dist portable build: { ...baseConfig.build, outDir: 'dist/relative-base', - watch: false, + watch: null, minify: false, assetsInlineLimit: 0, rollupOptions: { @@ -20,7 +19,8 @@ module.exports = { }, }, }, + // @ts-expect-error refer to playground/vitestSetup.ts testConfig: { baseRoute: '/relative-base/', }, -} +}) diff --git a/playground/assets/vite.config-runtime-base.js b/playground/assets/vite.config-runtime-base.js index 7d2c042c9211e5..4f823167290311 100644 --- a/playground/assets/vite.config-runtime-base.js +++ b/playground/assets/vite.config-runtime-base.js @@ -1,22 +1,19 @@ -const path = require('node:path') +// @ts-check +import { defineConfig } from 'vite' +import baseConfig from './vite.config.js' const dynamicBaseAssetsCode = ` globalThis.__toAssetUrl = url => '/' + url globalThis.__publicBase = '/' ` -const baseConfig = require('./vite.config.js') - -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ ...baseConfig, base: './', // overwrite the original base: '/foo/' build: { ...baseConfig.build, outDir: 'dist', - watch: false, + watch: null, minify: false, assetsInlineLimit: 0, rollupOptions: { @@ -61,4 +58,4 @@ module.exports = { } }, }, -} +}) diff --git a/playground/assets/vite.config.js b/playground/assets/vite.config.js index e6d2ba3fb460d2..8638fb7340973d 100644 --- a/playground/assets/vite.config.js +++ b/playground/assets/vite.config.js @@ -1,21 +1,22 @@ -const path = require('node:path') +// @ts-check +import path from 'node:path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { - base: '/foo', - publicDir: 'static', - resolve: { - alias: { - '@': path.resolve(__dirname, 'nested'), +export default /** @type {import('vite').UserConfig} */ ( + defineConfig({ + base: '/foo', + publicDir: 'static', + resolve: { + alias: { + '@': path.resolve(__dirname, 'nested'), + }, }, - }, - assetsInclude: ['**/*.unknown'], - build: { - outDir: 'dist/foo', - assetsInlineLimit: 8192, // 8kb - manifest: true, - watch: {}, - }, -} + assetsInclude: ['**/*.unknown'], + build: { + outDir: 'dist/foo', + assetsInlineLimit: 8192, // 8kb + manifest: true, + watch: {}, + }, + }) +) diff --git a/playground/backend-integration/vite.config.js b/playground/backend-integration/vite.config.js index 245f1324ded5ed..b8f16ae18414a6 100644 --- a/playground/backend-integration/vite.config.js +++ b/playground/backend-integration/vite.config.js @@ -1,6 +1,7 @@ -const path = require('node:path') -const glob = require('fast-glob') -const normalizePath = require('vite').normalizePath +// @ts-check +import path from 'node:path' +import glob from 'fast-glob' +import { defineConfig, normalizePath } from 'vite' /** * @returns {import('vite').Plugin} @@ -40,10 +41,7 @@ function BackendIntegrationExample() { } } -/** - * @returns {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ base: '/dev/', plugins: [BackendIntegrationExample()], -} +}) diff --git a/playground/cli-module/vite.config.js b/playground/cli-module/vite.config.js index ed7ac01c2d6612..1644092b68f0d0 100644 --- a/playground/cli-module/vite.config.js +++ b/playground/cli-module/vite.config.js @@ -1,3 +1,4 @@ +// @ts-check // eslint-disable-next-line import/no-nodejs-modules import { URL } from 'url' import { defineConfig } from 'vite' diff --git a/playground/cli/vite.config.js b/playground/cli/vite.config.js index 5a5d90cdd8d570..41b38de3658c5d 100644 --- a/playground/cli/vite.config.js +++ b/playground/cli/vite.config.js @@ -1,6 +1,7 @@ -const { defineConfig } = require('vite') +// @ts-check +import { defineConfig } from 'vite' -module.exports = defineConfig({ +export default defineConfig({ server: { host: 'localhost', headers: { diff --git a/playground/config/packages/entry/vite.config.ts b/playground/config/packages/entry/vite.config.ts index 7a4e9a682ae040..8eb679d713f52d 100644 --- a/playground/config/packages/entry/vite.config.ts +++ b/playground/config/packages/entry/vite.config.ts @@ -1,3 +1,4 @@ +// @ts-check import moduleCondition from '@vite/test-config-plugin-module-condition' import { array } from '../siblings/foo' diff --git a/playground/css-codesplit-cjs/vite.config.js b/playground/css-codesplit-cjs/vite.config.js index 7646d17279e514..37951d3d7c65b0 100644 --- a/playground/css-codesplit-cjs/vite.config.js +++ b/playground/css-codesplit-cjs/vite.config.js @@ -1,6 +1,8 @@ -const { resolve } = require('node:path') +// @ts-check +import { resolve } from 'node:path' +import { defineConfig } from 'vite' -module.exports = { +export default defineConfig({ build: { outDir: './dist', manifest: true, @@ -17,4 +19,4 @@ module.exports = { }, }, }, -} +}) diff --git a/playground/css-codesplit/vite.config.js b/playground/css-codesplit/vite.config.js index 870060f7e6c382..e4d2965d20bca7 100644 --- a/playground/css-codesplit/vite.config.js +++ b/playground/css-codesplit/vite.config.js @@ -1,6 +1,8 @@ -const { resolve } = require('node:path') +// @ts-check +import { resolve } from 'node:path' +import { defineConfig } from 'vite' -module.exports = { +export default defineConfig({ build: { manifest: true, rollupOptions: { @@ -18,4 +20,4 @@ module.exports = { }, }, }, -} +}) diff --git a/playground/css-sourcemap/vite.config.js b/playground/css-sourcemap/vite.config.js index 64067165873701..60e74138c13379 100644 --- a/playground/css-sourcemap/vite.config.js +++ b/playground/css-sourcemap/vite.config.js @@ -1,9 +1,8 @@ -const MagicString = require('magic-string') +// @ts-check +import { defineConfig } from 'vite' +import MagicString from 'magic-string' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ resolve: { alias: { '@': __dirname, @@ -58,4 +57,4 @@ module.exports = { }, }, ], -} +}) diff --git a/playground/css/vite.config-relative-base.js b/playground/css/vite.config-relative-base.js index 7edbaf07c95c29..0d7c1bc213d735 100644 --- a/playground/css/vite.config-relative-base.js +++ b/playground/css/vite.config-relative-base.js @@ -1,15 +1,14 @@ -/** - * @type {import('vite').UserConfig} - */ +// @ts-check +import { defineConfig } from 'vite' +import baseConfig from './vite.config.js' -const baseConfig = require('./vite.config.js') -module.exports = { +export default defineConfig({ ...baseConfig, base: './', // relative base to make dist portable build: { ...baseConfig.build, outDir: 'dist/relative-base', - watch: false, + watch: null, minify: false, assetsInlineLimit: 0, rollupOptions: { @@ -20,7 +19,8 @@ module.exports = { }, }, }, + // @ts-expect-error refer to playground/vitestSetup.ts testConfig: { baseRoute: '/relative-base/', }, -} +}) diff --git a/playground/css/vite.config.js b/playground/css/vite.config.js index b95395e8946fb8..7561fcecd885ba 100644 --- a/playground/css/vite.config.js +++ b/playground/css/vite.config.js @@ -1,72 +1,75 @@ -const path = require('node:path') +// @ts-check +import path from 'node:path' +import { defineConfig } from 'vite' // trigger scss bug: https://github.com/sass/dart-sass/issues/710 // make sure Vite handles safely +// @ts-expect-error refer to https://github.com/vitejs/vite/pull/11079 globalThis.window = {} +// @ts-expect-error refer to https://github.com/vitejs/vite/pull/11079 globalThis.location = new URL('http://localhost/') -/** - * @type {import('vite').UserConfig} - */ -module.exports = { - build: { - cssTarget: 'chrome61', - }, - esbuild: { - logOverride: { - 'unsupported-css-property': 'silent', +export default /** @type {import('vite').UserConfig} */ ( + defineConfig({ + build: { + cssTarget: 'chrome61', }, - }, - resolve: { - alias: { - '=': __dirname, - spacefolder: __dirname + '/folder with space', - '#alias': __dirname + '/aliased/foo.css', - '#alias?inline': __dirname + '/aliased/foo.css?inline', - '#alias-module': __dirname + '/aliased/bar.module.css', + esbuild: { + logOverride: { + 'unsupported-css-property': 'silent', + }, + }, + resolve: { + alias: { + '=': __dirname, + spacefolder: __dirname + '/folder with space', + '#alias': __dirname + '/aliased/foo.css', + '#alias?inline': __dirname + '/aliased/foo.css?inline', + '#alias-module': __dirname + '/aliased/bar.module.css', + }, }, - }, - css: { - modules: { - generateScopedName: '[name]__[local]___[hash:base64:5]', + css: { + modules: { + generateScopedName: '[name]__[local]___[hash:base64:5]', - // example of how getJSON can be used to generate - // typescript typings for css modules class names + // example of how getJSON can be used to generate + // typescript typings for css modules class names - // getJSON(cssFileName, json, _outputFileName) { - // let typings = 'declare const classNames: {\n' - // for (let className in json) { - // typings += ` "${className}": string;\n` - // } - // typings += '};\n' - // typings += 'export default classNames;\n' - // const { join, dirname, basename } = require('path') - // const typingsFile = join( - // dirname(cssFileName), - // basename(cssFileName) + '.d.ts' - // ) - // require('fs').writeFileSync(typingsFile, typings) - // }, - }, - preprocessorOptions: { - scss: { - additionalData: `$injectedColor: orange;`, - importer: [ - function (url) { - return url === 'virtual-dep' ? { contents: '' } : null - }, - function (url) { - return url.endsWith('.wxss') ? { contents: '' } : null - }, - ], + // getJSON(cssFileName, json, _outputFileName) { + // let typings = 'declare const classNames: {\n' + // for (let className in json) { + // typings += ` "${className}": string;\n` + // } + // typings += '};\n' + // typings += 'export default classNames;\n' + // const { join, dirname, basename } = require('path') + // const typingsFile = join( + // dirname(cssFileName), + // basename(cssFileName) + '.d.ts' + // ) + // require('fs').writeFileSync(typingsFile, typings) + // }, }, - styl: { - additionalData: `$injectedColor ?= orange`, - imports: [ - './options/relative-import.styl', - path.join(__dirname, 'options/absolute-import.styl'), - ], + preprocessorOptions: { + scss: { + additionalData: `$injectedColor: orange;`, + importer: [ + function (url) { + return url === 'virtual-dep' ? { contents: '' } : null + }, + function (url) { + return url.endsWith('.wxss') ? { contents: '' } : null + }, + ], + }, + styl: { + additionalData: `$injectedColor ?= orange`, + imports: [ + './options/relative-import.styl', + path.join(__dirname, 'options/absolute-import.styl'), + ], + }, }, }, - }, -} + }) +) diff --git a/playground/define/vite.config.js b/playground/define/vite.config.js index 41cb419d03b38f..c88ecdf27aa5ba 100644 --- a/playground/define/vite.config.js +++ b/playground/define/vite.config.js @@ -1,25 +1,30 @@ -module.exports = { - define: { - __EXP__: 'false', - __STRING__: '"hello"', - __NUMBER__: 123, - __BOOLEAN__: true, - __OBJ__: { - foo: 1, - bar: { - baz: 2, - }, - process: { - env: { - SOMEVAR: '"PROCESS MAY BE PROPERTY"', +// @ts-check +import { defineConfig } from 'vite' + +export default /** @type {import('vite').UserConfig} */ ( + defineConfig({ + define: { + __EXP__: 'false', + __STRING__: '"hello"', + __NUMBER__: 123, + __BOOLEAN__: true, + __OBJ__: { + foo: 1, + bar: { + baz: 2, + }, + process: { + env: { + SOMEVAR: '"PROCESS MAY BE PROPERTY"', + }, }, }, + 'process.env.NODE_ENV': '"dev"', + 'process.env.SOMEVAR': '"SOMEVAR"', + $DOLLAR: 456, + ÖUNICODE_LETTERɵ: 789, + __VAR_NAME__: false, + __STRINGIFIED_OBJ__: JSON.stringify({ foo: true }), }, - 'process.env.NODE_ENV': '"dev"', - 'process.env.SOMEVAR': '"SOMEVAR"', - $DOLLAR: 456, - ÖUNICODE_LETTERɵ: 789, - __VAR_NAME__: false, - __STRINGIFIED_OBJ__: JSON.stringify({ foo: true }), - }, -} + }) +) diff --git a/playground/dynamic-import/vite.config.js b/playground/dynamic-import/vite.config.js index f9f231a1a335cb..0db051956bd13a 100644 --- a/playground/dynamic-import/vite.config.js +++ b/playground/dynamic-import/vite.config.js @@ -1,8 +1,9 @@ -const fs = require('node:fs') -const path = require('node:path') -const vite = require('vite') +// @ts-check +import fs from 'node:fs' +import path from 'node:path' +import vite from 'vite' -module.exports = vite.defineConfig({ +export default vite.defineConfig({ plugins: [ { name: 'copy', diff --git a/playground/env-nested/vite.config.js b/playground/env-nested/vite.config.js index 8f85449e41e4de..e9c9445a576974 100644 --- a/playground/env-nested/vite.config.js +++ b/playground/env-nested/vite.config.js @@ -1,5 +1,6 @@ -const { defineConfig } = require('vite') +// @ts-check +import { defineConfig } from 'vite' -module.exports = defineConfig({ +export default defineConfig({ envDir: './envs', }) diff --git a/playground/env/vite.config.js b/playground/env/vite.config.js index 3b2d5e3e7674ab..3c1fa9783514f7 100644 --- a/playground/env/vite.config.js +++ b/playground/env/vite.config.js @@ -1,8 +1,9 @@ -const { defineConfig } = require('vite') +// @ts-check +import { defineConfig } from 'vite' process.env.EXPAND = 'expand' -module.exports = defineConfig({ +export default defineConfig({ base: '/env/', envPrefix: ['VITE_', 'CUSTOM_PREFIX_'], build: { diff --git a/playground/extensions/vite.config.js b/playground/extensions/vite.config.js index 4ed3195b219bff..e19dff64c9a8b0 100644 --- a/playground/extensions/vite.config.js +++ b/playground/extensions/vite.config.js @@ -1,6 +1,9 @@ -module.exports = { +// @ts-check +import { defineConfig } from 'vite' + +export default defineConfig({ resolve: { alias: [{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }], extensions: ['.js'], }, -} +}) diff --git a/playground/external/vite.config.js b/playground/external/vite.config.js index 14259ecde860b0..c8c8f08425c99c 100644 --- a/playground/external/vite.config.js +++ b/playground/external/vite.config.js @@ -1,3 +1,4 @@ +// @ts-check import { defineConfig } from 'vite' export default defineConfig({ diff --git a/playground/fs-serve/root/vite.config.js b/playground/fs-serve/root/vite.config.js index ca7fefd0108870..33da5fc50e3585 100644 --- a/playground/fs-serve/root/vite.config.js +++ b/playground/fs-serve/root/vite.config.js @@ -1,9 +1,8 @@ -const path = require('node:path') +// @ts-check +import path from 'node:path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ build: { rollupOptions: { input: { @@ -31,4 +30,4 @@ module.exports = { define: { ROOT: JSON.stringify(path.dirname(__dirname).replace(/\\/g, '/')), }, -} +}) diff --git a/playground/glob-import/vite.config.ts b/playground/glob-import/vite.config.ts index 87a057ba6112ad..f654d4c76f80fc 100644 --- a/playground/glob-import/vite.config.ts +++ b/playground/glob-import/vite.config.ts @@ -1,3 +1,4 @@ +// @ts-check import fs from 'node:fs' import path from 'node:path' import { defineConfig } from 'vite' diff --git a/playground/hmr/vite.config.ts b/playground/hmr/vite.config.ts index b771693a5aab0f..ef5219c9aa21b0 100644 --- a/playground/hmr/vite.config.ts +++ b/playground/hmr/vite.config.ts @@ -1,3 +1,4 @@ +// @ts-check import { defineConfig } from 'vite' import type { Plugin } from 'vite' diff --git a/playground/html/vite.config.js b/playground/html/vite.config.js index f7eb421975ee00..d50c72cb9a499d 100644 --- a/playground/html/vite.config.js +++ b/playground/html/vite.config.js @@ -1,9 +1,8 @@ -const { resolve } = require('node:path') +// @ts-check +import { resolve } from 'node:path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ base: './', build: { rollupOptions: { @@ -189,4 +188,4 @@ ${ }, }, ], -} +}) diff --git a/playground/js-sourcemap/vite.config.js b/playground/js-sourcemap/vite.config.js index 6733986f9b1110..18b0b16b597f6f 100644 --- a/playground/js-sourcemap/vite.config.js +++ b/playground/js-sourcemap/vite.config.js @@ -1,8 +1,8 @@ -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +// @ts-check +import { defineConfig } from 'vite' + +export default defineConfig({ build: { sourcemap: true, }, -} +}) diff --git a/playground/legacy/vite.config-custom-filename.js b/playground/legacy/vite.config-custom-filename.js index 8c9dcda38fc3d0..82ba86d9d460b5 100644 --- a/playground/legacy/vite.config-custom-filename.js +++ b/playground/legacy/vite.config-custom-filename.js @@ -1,6 +1,8 @@ -const legacy = require('@vitejs/plugin-legacy').default +// @ts-check +import { defineConfig } from 'vite' +import legacy from '@vitejs/plugin-legacy' -module.exports = { +export default defineConfig({ plugins: [legacy({ modernPolyfills: true })], build: { manifest: true, @@ -12,4 +14,4 @@ module.exports = { }, }, }, -} +}) diff --git a/playground/legacy/vite.config-multiple-output.js b/playground/legacy/vite.config-multiple-output.js index 63032be9f66af5..bcf6147b2fd3f7 100644 --- a/playground/legacy/vite.config-multiple-output.js +++ b/playground/legacy/vite.config-multiple-output.js @@ -1,5 +1,6 @@ -import legacy from '@vitejs/plugin-legacy' +// @ts-check import { defineConfig } from 'vite' +import legacy from '@vitejs/plugin-legacy' export default defineConfig({ plugins: [legacy({ modernPolyfills: true })], diff --git a/playground/legacy/vite.config.js b/playground/legacy/vite.config.js index 54de28b31949de..ec5165fd0d55ac 100644 --- a/playground/legacy/vite.config.js +++ b/playground/legacy/vite.config.js @@ -1,8 +1,10 @@ -const fs = require('node:fs') -const path = require('node:path') -const legacy = require('@vitejs/plugin-legacy').default +// @ts-check +import fs from 'node:fs' +import path from 'node:path' +import legacy from '@vitejs/plugin-legacy' +import { defineConfig } from 'vite' -module.exports = { +export default defineConfig({ base: './', plugins: [ legacy({ @@ -41,4 +43,4 @@ module.exports = { .replace(/