Skip to content

Commit e3448fa

Browse files
committed
chore(vite): restore utils required for dev-bundler
1 parent 7abd982 commit e3448fa

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/vite/src/dev-bundler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { pathToFileURL } from 'node:url'
22
import { existsSync } from 'node:fs'
3+
import { writeFile } from 'node:fs/promises'
34
import { builtinModules } from 'node:module'
45
import { isAbsolute, normalize, resolve } from 'pathe'
56
import type * as vite from 'vite'
67
import type { isExternal } from 'externality'
78
import { genDynamicImport, genObjectFromRawEntries } from 'knitwork'
8-
import fse from 'fs-extra'
99
import { debounce } from 'perfect-debounce'
1010
import { isIgnored, logger } from '@nuxt/kit'
1111
import { hashId, isCSS, uniq } from './utils'
@@ -236,7 +236,7 @@ export async function initViteDevBundler (ctx: ViteBuildContext, onBuild: () =>
236236
const _doBuild = async () => {
237237
const start = Date.now()
238238
const { code, ids } = await bundleRequest(options, ctx.entry)
239-
await fse.writeFile(resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'), code, 'utf-8')
239+
await writeFile(resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'), code, 'utf-8')
240240
// Have CSS in the manifest to prevent FOUC on dev SSR
241241
const manifestIds: string[] = []
242242
for (const i of ids) {

packages/vite/src/utils/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
import { hash } from 'ohash'
2+
13
export { isVue } from '../../../nuxt/src/core/utils/plugins'
24

5+
export function uniq<T> (arr: T[]): T[] {
6+
return Array.from(new Set(arr))
7+
}
8+
39
// Copied from vue-bundle-renderer utils
410
const IS_CSS_RE = /\.(?:css|scss|sass|postcss|pcss|less|stylus|styl)(?:\?[^.]+)?$/
511

612
export function isCSS (file: string) {
713
return IS_CSS_RE.test(file)
814
}
915

16+
export function hashId (id: string) {
17+
return '$id_' + hash(id)
18+
}
19+
1020
export function matchWithStringOrRegex (value: string, matcher: string | RegExp) {
1121
if (typeof matcher === 'string') {
1222
return value === matcher

0 commit comments

Comments
 (0)