From 743e58f8403498d7a38d179e44aa8a8928d03426 Mon Sep 17 00:00:00 2001 From: hemengke1997 <23536175@qq.com> Date: Mon, 30 Oct 2023 17:01:14 +0800 Subject: [PATCH] fix: fixed manifest being undefined under ssr or standalone env --- migration-v2.0.0.md | 10 +-- .../spa-file-mode/__tests__/file-mode.spec.ts | 4 +- playground/ssr/index.html | 2 +- playground/ssr/package.json | 2 +- playground/ssr/prerender.js | 33 --------- playground/ssr/server.js | 20 ++--- playground/ssr/vite.config.js | 2 +- pnpm-lock.yaml | 25 +++++++ src/node/helper/build.ts | 3 +- src/node/helper/default-options.ts | 11 +++ src/node/helper/file-watcher.ts | 6 +- src/node/helper/io.ts | 74 +++++++++++++++++++ src/node/helper/utils.ts | 73 ++++-------------- src/node/index.ts | 12 +-- src/node/manifest-cache/ManifestCache.ts | 17 +---- src/node/manifest-cache/index.ts | 40 +++++++++- src/node/plugins/inject-script.ts | 4 +- src/node/processor/FileCacheProcessor.ts | 6 +- tests/utils.test.ts | 2 +- tests/vitestSetup.ts | 2 +- tsup.config.ts | 2 + vitest.config.e2e.ts | 2 +- 22 files changed, 201 insertions(+), 151 deletions(-) delete mode 100644 playground/ssr/prerender.js create mode 100644 src/node/helper/default-options.ts create mode 100644 src/node/helper/io.ts diff --git a/migration-v2.0.0.md b/migration-v2.0.0.md index b324c5c..939bd2d 100644 --- a/migration-v2.0.0.md +++ b/migration-v2.0.0.md @@ -60,15 +60,7 @@ html = injectScriptsToHtml(html, (manifest) => [ ]) ``` -2. node环境中,也可以使用 `getManifest` 获取manifest - -```ts -import { getManifest } from 'vite-plugin-public-typescript' - -console.log(getManifest(), 'manifest') -``` - -3. 在业务源码中,使用 `vite-plugin-public-typescript/client` 引入 manifest +2. 在业务源码中,使用 `vite-plugin-public-typescript/client` 引入 manifest ```ts import { manifest } from 'vite-plugin-public-typescript/client' diff --git a/playground/spa-file-mode/__tests__/file-mode.spec.ts b/playground/spa-file-mode/__tests__/file-mode.spec.ts index 0ef256b..8f1a037 100644 --- a/playground/spa-file-mode/__tests__/file-mode.spec.ts +++ b/playground/spa-file-mode/__tests__/file-mode.spec.ts @@ -2,13 +2,15 @@ import { listFiles, readFile } from '~utils' import path from 'node:path' import { beforeAll, describe, expect, test } from 'vitest' +const manifestPath = 'node_modules/.vite-plugin-public-typescript/manifest.json' + describe('file-mode', () => { let jsFiles: string[] let manifest: string beforeAll(() => { try { - manifest = readFile('public-typescript/manifest.json') + manifest = readFile(manifestPath) jsFiles = listFiles('public/out') } catch {} }) diff --git a/playground/ssr/index.html b/playground/ssr/index.html index ad71659..40d3aaf 100644 --- a/playground/ssr/index.html +++ b/playground/ssr/index.html @@ -4,7 +4,7 @@ - Vite App + ssr playground diff --git a/playground/ssr/package.json b/playground/ssr/package.json index 563c4fc..f1e2c4a 100644 --- a/playground/ssr/package.json +++ b/playground/ssr/package.json @@ -8,7 +8,6 @@ "build": "npm run build:client && npm run build:server", "build:client": "vite build --outDir dist/client", "build:server": "vite build --ssr src/entry-server.tsx --outDir dist/server", - "generate": "vite build --outDir dist/static && npm run build:server && node prerender", "serve": "NODE_ENV=production node server", "debug": "node --inspect-brk server" }, @@ -25,6 +24,7 @@ "compression": "^1.7.4", "express": "^4.18.2", "serve-static": "^1.15.0", + "tsx": "^3.14.0", "vite": "^4.5.0" } } diff --git a/playground/ssr/prerender.js b/playground/ssr/prerender.js deleted file mode 100644 index 50c37be..0000000 --- a/playground/ssr/prerender.js +++ /dev/null @@ -1,33 +0,0 @@ -// Pre-render the app into static HTML. -// run `yarn generate` and then `dist/static` can be served as a static site. - -import fs from 'node:fs' -import path from 'node:path' -import { fileURLToPath } from 'node:url' - -const __dirname = path.dirname(fileURLToPath(import.meta.url)) -const toAbsolute = (p) => path.resolve(__dirname, p) - -const template = fs.readFileSync(toAbsolute('dist/static/index.html'), 'utf-8') -const { render } = await import('./dist/server/entry-server.js') - -// determine routes to pre-render from src/pages -const routesToPrerender = fs.readdirSync(toAbsolute('src/pages')).map((file) => { - const name = file.replace(/\.tsx$/, '').toLowerCase() - return name === 'home' ? `/` : `/${name}` -}) - -// eslint-disable-next-line unicorn/prefer-top-level-await -;(async () => { - // pre-render each route... - for (const url of routesToPrerender) { - const context = {} - const appHtml = await render(url, context) - - const html = template.replace(``, appHtml) - - const filePath = `dist/static${url === '/' ? '/index' : url}.html` - fs.writeFileSync(toAbsolute(filePath), html) - console.log('pre-rendered:', filePath) - } -})() diff --git a/playground/ssr/server.js b/playground/ssr/server.js index ac3653e..57c5e01 100644 --- a/playground/ssr/server.js +++ b/playground/ssr/server.js @@ -2,12 +2,13 @@ import express from 'express' import fs from 'node:fs' import path from 'node:path' import { fileURLToPath } from 'node:url' -import { getManifest, injectScriptsToHtml } from 'vite-plugin-public-typescript' +import { injectScriptsToHtml } from 'vite-plugin-public-typescript' const __dirname = path.dirname(fileURLToPath(import.meta.url)) + const isTest = process.env.VITEST -process.env.MY_CUSTOM_SECRET = 'API_KEY_qwertyuiop' +process.env.__Manifest_Path__ = __dirname export async function createServer(root = process.cwd(), isProd = process.env.NODE_ENV === 'production', hmrPort) { const resolve = (p) => path.resolve(__dirname, p) @@ -76,14 +77,11 @@ export async function createServer(root = process.cwd(), isProd = process.env.NO let html = template.replace(``, appHtml) - console.log(getManifest(), 'manifest') - html = injectScriptsToHtml(html, (manifest) => [ { attrs: { src: manifest.ssr, }, - injectTo: 'head-prepend', }, ]) @@ -98,8 +96,10 @@ export async function createServer(root = process.cwd(), isProd = process.env.NO return { app, vite, hmrPort } } -const port = process.env.PORT || 5173 -const { app } = await createServer() -app.listen(port, () => { - console.log(`http://localhost:${port}`) -}) +if (!isTest) { + const port = process.env.PORT || 5173 + const { app } = await createServer() + app.listen(port, () => { + console.log(`http://localhost:${port}`) + }) +} diff --git a/playground/ssr/vite.config.js b/playground/ssr/vite.config.js index 68694a6..a08a261 100644 --- a/playground/ssr/vite.config.js +++ b/playground/ssr/vite.config.js @@ -3,7 +3,7 @@ import { defineConfig } from 'vite' import { publicTypescript } from 'vite-plugin-public-typescript' export default defineConfig({ - plugins: [react(), publicTypescript({ destination: 'memory' })], + plugins: [react(), publicTypescript()], build: { minify: false, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6f780e..e8fdadd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -191,6 +191,9 @@ importers: serve-static: specifier: ^1.15.0 version: 1.15.0 + tsx: + specifier: ^3.14.0 + version: 3.14.0 vite: specifier: ^4.5.0 version: 4.5.0(@types/node@20.8.9) @@ -2054,6 +2057,10 @@ packages: update-browserslist-db: 1.0.11(browserslist@4.21.10) dev: true + /buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: true + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -6334,6 +6341,13 @@ packages: engines: {node: '>=0.10.0'} dev: true + /source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + dev: true + /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -6770,6 +6784,17 @@ packages: - ts-node dev: true + /tsx@3.14.0: + resolution: {integrity: sha512-xHtFaKtHxM9LOklMmJdI3BEnQq/D5F73Of2E1GDrITi9sgoVkvIsrQUTY1G8FlmGtA+awCI4EBlTRRYxkL2sRg==} + hasBin: true + dependencies: + esbuild: 0.18.20 + get-tsconfig: 4.7.2 + source-map-support: 0.5.21 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /tuf-js@2.1.0: resolution: {integrity: sha512-eD7YPPjVlMzdggrOeE8zwoegUaG/rt6Bt3jwoQPunRiNVzgcCE009UDFJKJjG+Gk9wFu6W/Vi+P5d/5QpdD9jA==} engines: {node: ^16.14.0 || >=18.0.0} diff --git a/src/node/helper/build.ts b/src/node/helper/build.ts index cf83596..60fa17d 100644 --- a/src/node/helper/build.ts +++ b/src/node/helper/build.ts @@ -1,6 +1,7 @@ import createDebug from 'debug' import { type BuildResult, type Plugin, build as esbuild } from 'esbuild' import path from 'node:path' +import colors from 'picocolors' import { type ResolvedConfig } from 'vite' import { globalConfig } from '../global-config' import { type BaseCacheProcessor } from '../processor/BaseCacheProcessor' @@ -88,7 +89,7 @@ export async function esbuildTypescript(buildOptions: IBuildOptions) { debug('esbuild success:', filePath) } catch (error) { - console.error(`[${pkgName}]`, error) + console.error(colors.red(`[${pkgName}] `), error) return } diff --git a/src/node/helper/default-options.ts b/src/node/helper/default-options.ts new file mode 100644 index 0000000..b6a1c41 --- /dev/null +++ b/src/node/helper/default-options.ts @@ -0,0 +1,11 @@ +import { type OptionsTypeWithDefault } from './utils' + +export const DEFAULT_OPTIONS: OptionsTypeWithDefault = { + destination: 'memory', + esbuildOptions: {}, + hash: true, + inputDir: 'public-typescript', + manifestName: 'manifest', + outputDir: '/', + cacheDir: 'node_modules/.vite-plugin-public-typescript', +} diff --git a/src/node/helper/file-watcher.ts b/src/node/helper/file-watcher.ts index 8f7e9e8..855b87f 100644 --- a/src/node/helper/file-watcher.ts +++ b/src/node/helper/file-watcher.ts @@ -1,9 +1,11 @@ import createDebug from 'debug' import path from 'node:path' +import colors from 'picocolors' import Watcher from 'watcher' import { globalConfig } from '../global-config' import { build } from './build' -import { _isPublicTypescript, type HmrFile } from './utils' +import { type HmrFile } from './server' +import { _isPublicTypescript, pkgName } from './utils' const debug = createDebug('vite-plugin-public-typescript:file-watcher ===> ') @@ -59,6 +61,6 @@ export function initWatcher(cb: (file: HmrFile) => void) { handleFileChange(filePath, () => cb({ path: filePath, event: 'changed' })) }) } catch (error) { - console.error(error) + console.error(colors.red(`[${pkgName}] `), error) } } diff --git a/src/node/helper/io.ts b/src/node/helper/io.ts new file mode 100644 index 0000000..8fb3f7b --- /dev/null +++ b/src/node/helper/io.ts @@ -0,0 +1,74 @@ +import createDebug from 'debug' +import fs from 'fs-extra' +import path from 'node:path' +import { globalConfig } from '../global-config' +import { extractHashFromFileName, linebreak } from './utils' + +const debug = createDebug('vite-plugin-public-typescript:io ===> ') + +export function detectLastLine(string: string) { + const last = string.at(-1) || '' + + return /(?:\r?\n)/g.test(last) +} + +const newline = /\r\n|\r|\n/g +export function setEol(text: string) { + if (!detectLastLine(text)) { + text += linebreak + } + + return text.replaceAll(newline, linebreak) +} + +export function readJsonFile(file: string): Record { + if (!fs.existsSync(file)) { + return {} + } + + const cacheJson = fs.readFileSync(file, 'utf-8') + if (cacheJson) { + return JSON.parse(cacheJson) + } + + return {} +} + +export function writeFile(filename: string, content: string, hash = true): void { + const dir = path.dirname(filename) + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }) + } + + const newContent = setEol(content) + + if (fs.existsSync(filename)) { + if (hash) { + const _hash = globalConfig.get().hash + if (extractHashFromFileName(filename, _hash)) { + // if filename has hash, skip write file + debug('skip writeFile, filename has hash') + return + } + } + + // Read content first + // if content is same, skip write file + const oldContent = fs.readFileSync(filename, 'utf-8') + debug('oldContent:', oldContent, 'newContent:', newContent) + if (oldContent && newContent === oldContent) { + debug('skip writeFile, content is same with old content:', oldContent) + return + } + } + + fs.writeFileSync(filename, newContent) + + debug('writeFile success:', filename) +} + +export function writeJsonFile(filename: string, content: Record) { + const formattedContent = JSON.stringify(content || {}, null, 2) + writeFile(filename, formattedContent, false) + return true +} diff --git a/src/node/helper/utils.ts b/src/node/helper/utils.ts index 11cf907..db6d7d2 100644 --- a/src/node/helper/utils.ts +++ b/src/node/helper/utils.ts @@ -8,7 +8,7 @@ import { type ResolvedConfig, createLogger, normalizePath } from 'vite' import { type VPPTPluginOptions } from '..' import { name as pkgName } from '../../../package.json' import { globalConfig } from '../global-config' -import { manifestCache } from '../manifest-cache' +import { manifestCache, saveManifestPathToDisk } from '../manifest-cache' import { initCacheProcessor } from '../processor/processor' import { disableManifestHmr } from './server' @@ -60,23 +60,6 @@ export function isWindows() { return typeof process != 'undefined' && process.platform === 'win32' } -export const linebreak = isWindows() ? '\r\n' : '\n' - -export function detectLastLine(string: string) { - const last = string.at(-1) || '' - - return /(?:\r?\n)/g.test(last) -} - -const newline = /\r\n|\r|\n/g -export function setEol(text: string) { - if (!detectLastLine(text)) { - text += linebreak - } - - return text.replaceAll(newline, linebreak) -} - export function isObject(o: unknown): o is Object { return Object.prototype.toString.call(o) === '[object Object]' } @@ -109,49 +92,14 @@ export function converEmptyObjectToNull(obj: unknown) { return obj } -export function writeFile(filename: string, content: string): void { - const dir = path.dirname(filename) - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }) - } - - const newContent = setEol(content) - - if (fs.existsSync(filename)) { - const { hash } = globalConfig.get() - if (extractHashFromFileName(filename, hash)) { - // if filename has hash, skip write file - debug('skip writeFile, filename has hash') - return - } - // Read content first - // if content is same, skip write file - const oldContent = fs.readFileSync(filename, 'utf-8') - debug('oldContent:', oldContent, 'newContent:', newContent) - if (oldContent && newContent === oldContent) { - debug('skip writeFile, content is same with old content:', oldContent) - return - } - } - - fs.writeFileSync(filename, newContent) +const HASH_LEN = 8 - debug('writeFile success:', filename) -} +export const linebreak = isWindows() ? '\r\n' : '\n' -function getHashLen(hash: VPPTPluginOptions['hash']) { +export function getHashLen(hash: VPPTPluginOptions['hash']) { return typeof hash === 'number' ? hash : HASH_LEN } -const HASH_LEN = 8 -export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VPPTPluginOptions['hash']) { - if (!chunk) { - return '' - } - const hashLen = getHashLen(hash) - return createHash('md5').update(chunk).digest('hex').slice(0, Math.max(0, hashLen)) -} - export function extractHashFromFileName(filename: string, hash: VPPTPluginOptions['hash']) { const hashLen = getHashLen(hash) const regex = new RegExp(`\\.([\\w\\d]{${hashLen}})\\.?`) @@ -162,6 +110,14 @@ export function extractHashFromFileName(filename: string, hash: VPPTPluginOption return '' } +export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VPPTPluginOptions['hash']) { + if (!chunk) { + return '' + } + const hashLen = getHashLen(hash) + return createHash('md5').update(chunk).digest('hex').slice(0, Math.max(0, hashLen)) +} + export function validateOptions(options: OptionsTypeWithDefault) { let { outputDir } = options // ensure outputDir is Dir @@ -261,7 +217,10 @@ export async function setupGlobalConfig(viteConfig: ResolvedConfig, opts: Option export async function setupManifestCache(viteConfig: ResolvedConfig, opts: OptionsTypeWithDefault) { const cacheDir = path.resolve(viteConfig.root, opts.cacheDir) - manifestCache.setManifestPath(normalizePath(`${cacheDir}/${opts.manifestName}.json`)) + + manifestCache.setManifestPath(`${cacheDir}/${opts.manifestName}.json`) + + saveManifestPathToDisk() // no need to set `_pathToDisk` manually anymore manifestCache.beforeSet = (value) => { diff --git a/src/node/index.ts b/src/node/index.ts index 43be4e4..53a6260 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -5,11 +5,11 @@ import path from 'node:path' import { type PluginOption, type ResolvedConfig } from 'vite' import { globalConfig } from './global-config' import { buildAllOnce } from './helper/build' +import { DEFAULT_OPTIONS } from './helper/default-options' import { initWatcher } from './helper/file-watcher' import { reloadPage } from './helper/server' import { _isPublicTypescript, - type OptionsTypeWithDefault, findAllOldJsFile, isEmptyObject, isManifestFile, @@ -90,16 +90,6 @@ export interface VPPTPluginOptions { base?: string } -export const DEFAULT_OPTIONS: OptionsTypeWithDefault = { - destination: 'memory', - esbuildOptions: {}, - hash: true, - inputDir: 'public-typescript', - manifestName: 'manifest', - outputDir: '/', - cacheDir: 'node_modules/.vite-plugin-public-typescript', -} - export default function publicTypescript(options: VPPTPluginOptions = {}) { const opts = { ...DEFAULT_OPTIONS, diff --git a/src/node/manifest-cache/ManifestCache.ts b/src/node/manifest-cache/ManifestCache.ts index f3d058c..9cb6344 100644 --- a/src/node/manifest-cache/ManifestCache.ts +++ b/src/node/manifest-cache/ManifestCache.ts @@ -2,7 +2,7 @@ import createDebug from 'debug' import fs from 'fs-extra' import path from 'node:path' import onChange from 'on-change' -import { writeFile } from '../helper/utils' +import { readJsonFile, writeJsonFile } from '../helper/io' const debug = createDebug('vite-plugin-public-typescript:ManifestCache ===> ') @@ -101,21 +101,12 @@ export class ManifestCache() +export const manifestCache = new ManifestCache() -export function getManifest(): Record { - return manifestCache.getManifestJson() +const ManifestCachePath = normalizePath(`${DEFAULT_OPTIONS.cacheDir}/_manifest_path.json`) + +function getManifestPath(root?: string) { + if (isInTest()) { + root = process.env.__Manifest_Path__ + } + if (!root) { + root = globalConfig.get().viteConfig?.root || process.cwd() + } + + return normalizePath(path.resolve(root, ManifestCachePath)) +} + +export function saveManifestPathToDisk() { + // save manifest path to cache dir + fs.ensureDir(DEFAULT_OPTIONS.cacheDir) + writeJsonFile(getManifestPath(), { + manifestPath: manifestCache.manifestPath, + }) } -export { manifestCache } +export function getManifest(root?: string) { + const manifestPath = readJsonFile(getManifestPath(root))?.manifestPath + + if (manifestPath) { + return readJsonFile(manifestPath) + } + + return {} +} diff --git a/src/node/plugins/inject-script.ts b/src/node/plugins/inject-script.ts index 595aa53..4f713e1 100644 --- a/src/node/plugins/inject-script.ts +++ b/src/node/plugins/inject-script.ts @@ -1,11 +1,11 @@ import { type HtmlTagDescriptor, type PluginOption } from 'vite' import { VPPT_DATA_ATTR, injectTagsToHtml } from '../helper/html' -import { manifestCache } from '../manifest-cache' +import { getManifest } from '../manifest-cache' export type Scripts = (manifest: Record) => Omit[] function generateScriptTags(scripts: Scripts) { - const _scripts = scripts(manifestCache.getManifestJson()) + const _scripts = scripts(getManifest()) const tags: HtmlTagDescriptor[] = _scripts.map((s) => ({ ...s, attrs: { diff --git a/src/node/processor/FileCacheProcessor.ts b/src/node/processor/FileCacheProcessor.ts index 0b876a2..4263bb2 100644 --- a/src/node/processor/FileCacheProcessor.ts +++ b/src/node/processor/FileCacheProcessor.ts @@ -1,9 +1,11 @@ import createDebug from 'debug' import fs from 'fs-extra' import path from 'node:path' +import colors from 'picocolors' import { normalizePath } from 'vite' import { globalConfig } from '../global-config' -import { findAllOldJsFile, writeFile } from '../helper/utils' +import { writeFile } from '../helper/io' +import { findAllOldJsFile, pkgName } from '../helper/utils' import { type CacheValueEx } from '../manifest-cache' import { type ManifestCache } from '../manifest-cache/ManifestCache' import { type AddFileArgs, type DeleteFileArgs, ManifestCacheProcessor } from './ManifestCacheProcessor' @@ -35,7 +37,7 @@ export class FileCacheProcessor extends ManifestCacheProcessor { publicDir, }) } catch (error) { - console.error(error) + console.error(colors.red(`[${pkgName}] `), error) } debug('deleteOldJsFile - oldFiles:', oldFiles) diff --git a/tests/utils.test.ts b/tests/utils.test.ts index 444bcf8..9816f88 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -1,13 +1,13 @@ import path from 'node:path' import { describe, expect, test } from 'vitest' import { globalConfig } from '../src/node/global-config' +import { setEol } from '../src/node/helper/io' import { eq, extractHashFromFileName, getContentHash, isPublicTypescript, linebreak, - setEol, validateOptions, } from '../src/node/helper/utils' diff --git a/tests/vitestSetup.ts b/tests/vitestSetup.ts index dc6fb24..95e2f78 100644 --- a/tests/vitestSetup.ts +++ b/tests/vitestSetup.ts @@ -1,8 +1,8 @@ import path from 'node:path' import { type InlineConfig, type ResolvedConfig, resolveConfig } from 'vite' import { beforeEach } from 'vitest' -import { DEFAULT_OPTIONS } from '../src/node' import { type GlobalConfig } from '../src/node/global-config/GlobalConfigBuilder' +import { DEFAULT_OPTIONS } from '../src/node/helper/default-options' import { setupGlobalConfig } from '../src/node/helper/utils' import { type CacheValueEx } from '../src/node/manifest-cache' diff --git a/tsup.config.ts b/tsup.config.ts index 7187559..1acdba2 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -11,6 +11,8 @@ const commonConfig = (option: Options): Options => { dts: true, minify: false, external: [/^virtual:.*/], + shims: true, + splitting: true, } } diff --git a/vitest.config.e2e.ts b/vitest.config.e2e.ts index bf32d9c..f99e0bc 100644 --- a/vitest.config.e2e.ts +++ b/vitest.config.e2e.ts @@ -11,7 +11,7 @@ export default defineConfig({ }, }, test: { - include: ['./playground/spa/**/*.spec.[tj]s'], + include: ['./playground/**/*.spec.[tj]s'], reporters: 'dot', coverage: { provider: undefined,