From 8551275e32347e89a4d2fdd2728bf6a2dd5f21cf Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 19 May 2022 18:36:28 +0800 Subject: [PATCH 1/3] refactor: make `ssr-html` esm --- package.json | 1 + playground/ssr-html/__tests__/serve.ts | 2 +- playground/ssr-html/package.json | 1 + playground/ssr-html/server.js | 18 ++++----- pnpm-lock.yaml | 51 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index bcfa5acb5efdf0..7556fde1cbb39c 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@types/debug": "^4.1.7", "@types/estree": "^0.0.51", "@types/etag": "^1.8.1", + "@types/express": "^4.17.13", "@types/fs-extra": "^9.0.13", "@types/hash-sum": "^1.0.0", "@types/less": "^3.0.3", diff --git a/playground/ssr-html/__tests__/serve.ts b/playground/ssr-html/__tests__/serve.ts index 9f18771acd26d4..f8c41aa00a3c77 100644 --- a/playground/ssr-html/__tests__/serve.ts +++ b/playground/ssr-html/__tests__/serve.ts @@ -10,7 +10,7 @@ export const port = ports['ssr-html'] export async function serve() { await kill(port) - const { createServer } = require(path.resolve(rootDir, 'server.js')) + const { createServer } = await import(path.resolve(rootDir, 'server.js')) const { app, vite } = await createServer(rootDir, hmrPorts['ssr-html']) return new Promise((resolve, reject) => { diff --git a/playground/ssr-html/package.json b/playground/ssr-html/package.json index b6d7cabe1b4cf5..d847e62c958754 100644 --- a/playground/ssr-html/package.json +++ b/playground/ssr-html/package.json @@ -1,6 +1,7 @@ { "name": "test-ssr-html", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "node server", diff --git a/playground/ssr-html/server.js b/playground/ssr-html/server.js index c94701afcfe771..bdb422940ae31a 100644 --- a/playground/ssr-html/server.js +++ b/playground/ssr-html/server.js @@ -1,7 +1,7 @@ -// @ts-check -const fs = require('fs') -const path = require('path') -const express = require('express') +import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' +import express from 'express' const isTest = process.env.NODE_ENV === 'test' || !!process.env.VITE_TEST_BUILD @@ -22,8 +22,9 @@ const DYNAMIC_STYLES = ` ` -async function createServer(root = process.cwd(), hmrPort) { - const resolve = (p) => path.resolve(__dirname, p) +export async function createServer(root = process.cwd(), hmrPort) { + const { createServer } = await import('vite') + const resolve = (p) => path.resolve(fileURLToPath(import.meta.url), '..', p) const app = express() @@ -31,7 +32,7 @@ async function createServer(root = process.cwd(), hmrPort) { * @type {import('vite').ViteDevServer} */ let vite - vite = await require('vite').createServer({ + vite = await createServer({ root, logLevel: isTest ? 'error' : 'info', server: { @@ -93,6 +94,3 @@ if (!isTest) { }) ) } - -// for test use -exports.createServer = createServer diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4f5275c59186b..90952c460b3ffb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,7 @@ importers: '@types/debug': ^4.1.7 '@types/estree': ^0.0.51 '@types/etag': ^1.8.1 + '@types/express': ^4.17.13 '@types/fs-extra': ^9.0.13 '@types/hash-sum': ^1.0.0 '@types/less': ^3.0.3 @@ -74,6 +75,7 @@ importers: '@types/debug': 4.1.7 '@types/estree': 0.0.51 '@types/etag': 1.8.1 + '@types/express': 4.17.13 '@types/fs-extra': 9.0.13 '@types/hash-sum': 1.0.0 '@types/less': 3.0.3 @@ -2020,6 +2022,13 @@ packages: '@babel/types': 7.17.10 dev: true + /@types/body-parser/1.19.2: + resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} + dependencies: + '@types/connect': 3.4.35 + '@types/node': 17.0.32 + dev: true + /@types/braces/3.0.1: resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} dev: true @@ -2034,6 +2043,12 @@ packages: resolution: {integrity: sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==} dev: true + /@types/connect/3.4.35: + resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} + dependencies: + '@types/node': 17.0.32 + dev: true + /@types/convert-source-map/1.5.2: resolution: {integrity: sha512-tHs++ZeXer40kCF2JpE51Hg7t4HPa18B1b1Dzy96S0eCw8QKECNMYMfwa1edK/x8yCN0r4e6ewvLcc5CsVGkdg==} dev: true @@ -2064,6 +2079,23 @@ packages: '@types/node': 17.0.32 dev: true + /@types/express-serve-static-core/4.17.28: + resolution: {integrity: sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==} + dependencies: + '@types/node': 17.0.32 + '@types/qs': 6.9.7 + '@types/range-parser': 1.2.4 + dev: true + + /@types/express/4.17.13: + resolution: {integrity: sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==} + dependencies: + '@types/body-parser': 1.19.2 + '@types/express-serve-static-core': 4.17.28 + '@types/qs': 6.9.7 + '@types/serve-static': 1.13.10 + dev: true + /@types/fs-extra/9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: @@ -2092,6 +2124,10 @@ packages: '@types/braces': 3.0.1 dev: true + /@types/mime/1.3.2: + resolution: {integrity: sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==} + dev: true + /@types/mime/2.0.3: resolution: {integrity: sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q==} dev: true @@ -2127,6 +2163,14 @@ packages: resolution: {integrity: sha512-7th8Opn+0XlN0O6qzO7dXOPwL6rigq/EwRS2DntaTHwSw8cLaYKeAPt5dWEKHSL+ffVSUl1itTPUC06+FlsV4Q==} dev: true + /@types/qs/6.9.7: + resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} + dev: true + + /@types/range-parser/1.2.4: + resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==} + dev: true + /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: @@ -2147,6 +2191,13 @@ packages: resolution: {integrity: sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==} dev: true + /@types/serve-static/1.13.10: + resolution: {integrity: sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==} + dependencies: + '@types/mime': 1.3.2 + '@types/node': 17.0.32 + dev: true + /@types/stack-trace/0.0.29: resolution: {integrity: sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g==} dev: true From b3bb707bdfc07e83ce5fc5b1a75be07d9ef5f55c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 21 May 2022 13:52:31 +0800 Subject: [PATCH 2/3] chore: migrate tests to esm --- .eslintrc.cjs | 6 ++++ playground/css-sourcemap/vite.config.js | 14 +++++---- playground/data-uri/package.json | 1 + playground/define/package.json | 1 + playground/define/vite.config.js | 6 ++-- playground/dynamic-import/nested/index.js | 1 - playground/dynamic-import/package.json | 1 + playground/dynamic-import/vite.config.js | 31 ++++++++++--------- playground/env-nested/package.json | 1 + playground/env-nested/vite.config.js | 4 +-- playground/env/package.json | 1 + playground/env/vite.config.js | 4 +-- playground/extensions/package.json | 1 + playground/extensions/vite.config.js | 6 ++-- playground/file-delete-restore/package.json | 1 + playground/file-delete-restore/vite.config.js | 10 +++--- playground/fs-serve/package.json | 1 + playground/fs-serve/root/vite.config.js | 10 +++--- playground/glob-import/package.json | 1 + playground/lib/package.json | 1 + playground/lib/vite.config.js | 12 +++---- playground/lib/vite.dyimport.config.js | 12 +++---- playground/vue-jsx/package.json | 1 + playground/vue-jsx/vite.config.js | 13 ++++---- playground/vue-lib/package.json | 1 + playground/vue-server-origin/package.json | 1 + playground/vue-sourcemap/package.json | 1 + playground/wasm/package.json | 1 + playground/wasm/vite.config.ts | 1 + playground/worker/package.json | 1 + playground/worker/vite.config.js | 6 ++-- 31 files changed, 87 insertions(+), 65 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 961fe199582d87..c40c65d21aabb1 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -70,6 +70,12 @@ module.exports = defineConfig({ 'node/no-unpublished-import': 'off', 'node/no-unpublished-require': 'off', 'node/no-unsupported-features/es-syntax': 'off', + 'node/no-unsupported-features/node-builtins': [ + 'error', + { + version: '>=14.6.0' + } + ], '@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR diff --git a/playground/css-sourcemap/vite.config.js b/playground/css-sourcemap/vite.config.js index 4fbeaa9a13aeb0..3ba9dea9ceb8af 100644 --- a/playground/css-sourcemap/vite.config.js +++ b/playground/css-sourcemap/vite.config.js @@ -1,9 +1,11 @@ -const MagicString = require('magic-string') +import { fileURLToPath } from 'url' +import { dirname } from 'path' +import MagicString from 'magic-string' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +const __dirname = dirname(fileURLToPath(import.meta.url)) + +export default defineConfig({ resolve: { alias: { '@': __dirname @@ -58,4 +60,4 @@ module.exports = { } } ] -} +}) diff --git a/playground/data-uri/package.json b/playground/data-uri/package.json index 4d30ad97b9acbb..e451e787201def 100644 --- a/playground/data-uri/package.json +++ b/playground/data-uri/package.json @@ -2,6 +2,7 @@ "name": "test-data-uri", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/define/package.json b/playground/define/package.json index 7c46b3020125fe..4d9e0581a120a4 100644 --- a/playground/define/package.json +++ b/playground/define/package.json @@ -2,6 +2,7 @@ "name": "test-define", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/define/vite.config.js b/playground/define/vite.config.js index fb49d658f49e90..36b26846f99c46 100644 --- a/playground/define/vite.config.js +++ b/playground/define/vite.config.js @@ -1,4 +1,6 @@ -module.exports = { +import { defineConfig } from 'vite' + +export default defineConfig({ define: { __EXP__: 'false', __STRING__: '"hello"', @@ -20,4 +22,4 @@ module.exports = { ÖUNICODE_LETTERɵ: 789, __VAR_NAME__: false } -} +}) diff --git a/playground/dynamic-import/nested/index.js b/playground/dynamic-import/nested/index.js index 61f817ce7dd7bc..76b071ca8c3f60 100644 --- a/playground/dynamic-import/nested/index.js +++ b/playground/dynamic-import/nested/index.js @@ -48,7 +48,6 @@ document.querySelector('.mxdjson').addEventListener('click', async () => { // data URLs (`blob:`) const code1 = 'export const msg = "blob"' const blob = new Blob([code1], { type: 'text/javascript;charset=UTF-8' }) -// eslint-disable-next-line node/no-unsupported-features/node-builtins const blobURL = URL.createObjectURL(blob) document.querySelector('.issue-2658-1').addEventListener('click', async () => { const { msg } = await import(/*@vite-ignore*/ blobURL) diff --git a/playground/dynamic-import/package.json b/playground/dynamic-import/package.json index 3b66d0af1873cc..6668840231a74f 100644 --- a/playground/dynamic-import/package.json +++ b/playground/dynamic-import/package.json @@ -2,6 +2,7 @@ "name": "test-dynamic-import", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/dynamic-import/vite.config.js b/playground/dynamic-import/vite.config.js index 50b90639fddd7f..f886912f873379 100644 --- a/playground/dynamic-import/vite.config.js +++ b/playground/dynamic-import/vite.config.js @@ -1,30 +1,33 @@ -const fs = require('fs') -const path = require('path') -const vite = require('vite') +import { copyFileSync } from 'fs' +import { dirname, resolve } from 'path' +import { fileURLToPath } from 'url' +import { defineConfig } from 'vite' -module.exports = vite.defineConfig({ +const __dirname = dirname(fileURLToPath(import.meta.url)) + +export default defineConfig({ plugins: [ { name: 'copy', writeBundle() { - fs.copyFileSync( - path.resolve(__dirname, 'qux.js'), - path.resolve(__dirname, 'dist/qux.js') + copyFileSync( + resolve(__dirname, 'qux.js'), + resolve(__dirname, 'dist/qux.js') ) - fs.copyFileSync( - path.resolve(__dirname, 'mxd.js'), - path.resolve(__dirname, 'dist/mxd.js') + copyFileSync( + resolve(__dirname, 'mxd.js'), + resolve(__dirname, 'dist/mxd.js') ) - fs.copyFileSync( - path.resolve(__dirname, 'mxd.json'), - path.resolve(__dirname, 'dist/mxd.json') + copyFileSync( + resolve(__dirname, 'mxd.json'), + resolve(__dirname, 'dist/mxd.json') ) } } ], resolve: { alias: { - '@': path.resolve(__dirname, 'alias') + '@': resolve(__dirname, 'alias') } } }) diff --git a/playground/env-nested/package.json b/playground/env-nested/package.json index 530b4e621005b0..63f13559a83bd5 100644 --- a/playground/env-nested/package.json +++ b/playground/env-nested/package.json @@ -2,6 +2,7 @@ "name": "test-env-nested", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/env-nested/vite.config.js b/playground/env-nested/vite.config.js index 0e46100698650d..85a2d44e7a6a92 100644 --- a/playground/env-nested/vite.config.js +++ b/playground/env-nested/vite.config.js @@ -1,5 +1,5 @@ -const { defineConfig } = require('vite') +import { defineConfig } from 'vite' -module.exports = defineConfig({ +export default defineConfig({ envDir: './envs' }) diff --git a/playground/env/package.json b/playground/env/package.json index 271cbf0a7d20c0..7b0166b70dbe77 100644 --- a/playground/env/package.json +++ b/playground/env/package.json @@ -2,6 +2,7 @@ "name": "test-env", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "cross-env VITE_INLINE=inline-serve vite", "build": "cross-env VITE_INLINE=inline-build vite build", diff --git a/playground/env/vite.config.js b/playground/env/vite.config.js index c96c8f84a321ef..9ac7c5dd09b836 100644 --- a/playground/env/vite.config.js +++ b/playground/env/vite.config.js @@ -1,6 +1,6 @@ -const { defineConfig } = require('vite') +import { defineConfig } from 'vite' -module.exports = defineConfig({ +export default defineConfig({ base: '/env/', envPrefix: ['VITE_', 'CUSTOM_PREFIX_'], build: { diff --git a/playground/extensions/package.json b/playground/extensions/package.json index c653486edf6be6..5fc4c86ef7570e 100644 --- a/playground/extensions/package.json +++ b/playground/extensions/package.json @@ -2,6 +2,7 @@ "name": "test-extensions", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/extensions/vite.config.js b/playground/extensions/vite.config.js index 53c744b71d3637..d57649267ae2be 100644 --- a/playground/extensions/vite.config.js +++ b/playground/extensions/vite.config.js @@ -1,6 +1,8 @@ -module.exports = { +import { defineConfig } from 'vite' + +export default defineConfig({ resolve: { alias: [{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }], extensions: ['.js'] } -} +}) diff --git a/playground/file-delete-restore/package.json b/playground/file-delete-restore/package.json index b9c511aacfa62e..35fe1b9d25a07e 100644 --- a/playground/file-delete-restore/package.json +++ b/playground/file-delete-restore/package.json @@ -2,6 +2,7 @@ "name": "test-file-delete-restore", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/file-delete-restore/vite.config.js b/playground/file-delete-restore/vite.config.js index 51cb5c54bd6821..900b4f810e898f 100644 --- a/playground/file-delete-restore/vite.config.js +++ b/playground/file-delete-restore/vite.config.js @@ -1,12 +1,10 @@ -const react = require('@vitejs/plugin-react') +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ plugins: [react()], build: { // to make tests faster minify: false } -} +}) diff --git a/playground/fs-serve/package.json b/playground/fs-serve/package.json index c50be06a8cb286..24e22b9c8de439 100644 --- a/playground/fs-serve/package.json +++ b/playground/fs-serve/package.json @@ -1,6 +1,7 @@ { "name": "test-fs-serve", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite root", diff --git a/playground/fs-serve/root/vite.config.js b/playground/fs-serve/root/vite.config.js index 585a91f9d6346d..915e8b99e8eeed 100644 --- a/playground/fs-serve/root/vite.config.js +++ b/playground/fs-serve/root/vite.config.js @@ -1,9 +1,7 @@ -const path = require('path') +import path from 'path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ build: { rollupOptions: { input: { @@ -23,4 +21,4 @@ module.exports = { define: { ROOT: JSON.stringify(path.dirname(__dirname).replace(/\\/g, '/')) } -} +}) diff --git a/playground/glob-import/package.json b/playground/glob-import/package.json index 2dd90e31b73b25..398304d1810aad 100644 --- a/playground/glob-import/package.json +++ b/playground/glob-import/package.json @@ -1,6 +1,7 @@ { "name": "test-import-context", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite", diff --git a/playground/lib/package.json b/playground/lib/package.json index 66b827b7c84179..1eea45ea8e7cc3 100644 --- a/playground/lib/package.json +++ b/playground/lib/package.json @@ -2,6 +2,7 @@ "name": "@example/my-lib", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/lib/vite.config.js b/playground/lib/vite.config.js index 72c040d38d6dcf..b16e5426affce2 100644 --- a/playground/lib/vite.config.js +++ b/playground/lib/vite.config.js @@ -1,10 +1,8 @@ -const fs = require('fs') -const path = require('path') +import fs from 'fs' +import path from 'path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ build: { lib: { entry: path.resolve(__dirname, 'src/main.js'), @@ -28,4 +26,4 @@ module.exports = { } } ] -} +}) diff --git a/playground/lib/vite.dyimport.config.js b/playground/lib/vite.dyimport.config.js index 1f64018c5850cf..2540a7f797361f 100644 --- a/playground/lib/vite.dyimport.config.js +++ b/playground/lib/vite.dyimport.config.js @@ -1,10 +1,8 @@ -const fs = require('fs') -const path = require('path') +import fs from 'fs' +import path from 'path' +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +export default defineConfig({ build: { lib: { entry: path.resolve(__dirname, 'src/main2.js'), @@ -14,4 +12,4 @@ module.exports = { }, outDir: 'dist/lib' } -} +}) diff --git a/playground/vue-jsx/package.json b/playground/vue-jsx/package.json index 697b9f312fd9b1..e725ccca0c8dee 100644 --- a/playground/vue-jsx/package.json +++ b/playground/vue-jsx/package.json @@ -2,6 +2,7 @@ "name": "test-vue-jsx", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/playground/vue-jsx/vite.config.js b/playground/vue-jsx/vite.config.js index 2f4ea255c95094..f7b3259acd44d4 100644 --- a/playground/vue-jsx/vite.config.js +++ b/playground/vue-jsx/vite.config.js @@ -1,10 +1,9 @@ -const vueJsxPlugin = require('@vitejs/plugin-vue-jsx') -const vuePlugin = require('@vitejs/plugin-vue') +import { defineConfig } from 'vite' -/** - * @type {import('vite').UserConfig} - */ -module.exports = { +import vueJsxPlugin from '@vitejs/plugin-vue-jsx' +import vuePlugin from '@vitejs/plugin-vue' + +export default defineConfig({ plugins: [ vueJsxPlugin({ include: [/\.tesx$/, /\.[jt]sx$/] @@ -39,4 +38,4 @@ export default defineComponent(() => { optimizeDeps: { disabled: true } -} +}) diff --git a/playground/vue-lib/package.json b/playground/vue-lib/package.json index 684e5ea83cb429..9beccf28554470 100644 --- a/playground/vue-lib/package.json +++ b/playground/vue-lib/package.json @@ -1,6 +1,7 @@ { "name": "test-vue-lib", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev-consumer": "vite --config ./vite.config.consumer.ts", diff --git a/playground/vue-server-origin/package.json b/playground/vue-server-origin/package.json index 869de55c22ee3d..7d1e17d1fdc830 100644 --- a/playground/vue-server-origin/package.json +++ b/playground/vue-server-origin/package.json @@ -1,6 +1,7 @@ { "name": "test-vue-server-origin", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite", diff --git a/playground/vue-sourcemap/package.json b/playground/vue-sourcemap/package.json index 55b4deef42c77d..e25703f7d0965d 100644 --- a/playground/vue-sourcemap/package.json +++ b/playground/vue-sourcemap/package.json @@ -1,6 +1,7 @@ { "name": "test-vue-sourcemap", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite", diff --git a/playground/wasm/package.json b/playground/wasm/package.json index bd9c954441f73e..c97896ada0c4d7 100644 --- a/playground/wasm/package.json +++ b/playground/wasm/package.json @@ -1,6 +1,7 @@ { "name": "test-wasm", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite", diff --git a/playground/wasm/vite.config.ts b/playground/wasm/vite.config.ts index 43833d2f95d302..9edb9ca19425a8 100644 --- a/playground/wasm/vite.config.ts +++ b/playground/wasm/vite.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'vite' + export default defineConfig({ build: { // make can no emit light.wasm diff --git a/playground/worker/package.json b/playground/worker/package.json index d66a96e84d59f2..9eb6ba7588bbec 100644 --- a/playground/worker/package.json +++ b/playground/worker/package.json @@ -1,6 +1,7 @@ { "name": "test-worker", "private": true, + "type": "module", "version": "0.0.0", "scripts": { "dev": "vite", diff --git a/playground/worker/vite.config.js b/playground/worker/vite.config.js index b7760bc4d7a240..27afc3fdc8184c 100644 --- a/playground/worker/vite.config.js +++ b/playground/worker/vite.config.js @@ -1,7 +1,7 @@ -const vueJsx = require('@vitejs/plugin-vue-jsx') -const vite = require('vite') +import vueJsx from '@vitejs/plugin-vue-jsx' +import { defineConfig } from 'vite' -module.exports = vite.defineConfig({ +export default defineConfig({ base: '/iife/', worker: { format: 'iife', From d3afd7f13aacbe03763f15b898bee6c12bfad013 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 21 May 2022 14:08:16 +0800 Subject: [PATCH 3/3] chore: cleanup --- package.json | 1 - pnpm-lock.yaml | 51 -------------------------------------------------- 2 files changed, 52 deletions(-) diff --git a/package.json b/package.json index 7556fde1cbb39c..bcfa5acb5efdf0 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "@types/debug": "^4.1.7", "@types/estree": "^0.0.51", "@types/etag": "^1.8.1", - "@types/express": "^4.17.13", "@types/fs-extra": "^9.0.13", "@types/hash-sum": "^1.0.0", "@types/less": "^3.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 90952c460b3ffb..b4f5275c59186b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,7 +18,6 @@ importers: '@types/debug': ^4.1.7 '@types/estree': ^0.0.51 '@types/etag': ^1.8.1 - '@types/express': ^4.17.13 '@types/fs-extra': ^9.0.13 '@types/hash-sum': ^1.0.0 '@types/less': ^3.0.3 @@ -75,7 +74,6 @@ importers: '@types/debug': 4.1.7 '@types/estree': 0.0.51 '@types/etag': 1.8.1 - '@types/express': 4.17.13 '@types/fs-extra': 9.0.13 '@types/hash-sum': 1.0.0 '@types/less': 3.0.3 @@ -2022,13 +2020,6 @@ packages: '@babel/types': 7.17.10 dev: true - /@types/body-parser/1.19.2: - resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} - dependencies: - '@types/connect': 3.4.35 - '@types/node': 17.0.32 - dev: true - /@types/braces/3.0.1: resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} dev: true @@ -2043,12 +2034,6 @@ packages: resolution: {integrity: sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==} dev: true - /@types/connect/3.4.35: - resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} - dependencies: - '@types/node': 17.0.32 - dev: true - /@types/convert-source-map/1.5.2: resolution: {integrity: sha512-tHs++ZeXer40kCF2JpE51Hg7t4HPa18B1b1Dzy96S0eCw8QKECNMYMfwa1edK/x8yCN0r4e6ewvLcc5CsVGkdg==} dev: true @@ -2079,23 +2064,6 @@ packages: '@types/node': 17.0.32 dev: true - /@types/express-serve-static-core/4.17.28: - resolution: {integrity: sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==} - dependencies: - '@types/node': 17.0.32 - '@types/qs': 6.9.7 - '@types/range-parser': 1.2.4 - dev: true - - /@types/express/4.17.13: - resolution: {integrity: sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==} - dependencies: - '@types/body-parser': 1.19.2 - '@types/express-serve-static-core': 4.17.28 - '@types/qs': 6.9.7 - '@types/serve-static': 1.13.10 - dev: true - /@types/fs-extra/9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: @@ -2124,10 +2092,6 @@ packages: '@types/braces': 3.0.1 dev: true - /@types/mime/1.3.2: - resolution: {integrity: sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==} - dev: true - /@types/mime/2.0.3: resolution: {integrity: sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q==} dev: true @@ -2163,14 +2127,6 @@ packages: resolution: {integrity: sha512-7th8Opn+0XlN0O6qzO7dXOPwL6rigq/EwRS2DntaTHwSw8cLaYKeAPt5dWEKHSL+ffVSUl1itTPUC06+FlsV4Q==} dev: true - /@types/qs/6.9.7: - resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} - dev: true - - /@types/range-parser/1.2.4: - resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==} - dev: true - /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: @@ -2191,13 +2147,6 @@ packages: resolution: {integrity: sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==} dev: true - /@types/serve-static/1.13.10: - resolution: {integrity: sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==} - dependencies: - '@types/mime': 1.3.2 - '@types/node': 17.0.32 - dev: true - /@types/stack-trace/0.0.29: resolution: {integrity: sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g==} dev: true