mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
chore(vite): restore utils required for dev-bundler
This commit is contained in:
parent
7abd982f85
commit
e3448fa0da
@ -1,11 +1,11 @@
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { writeFile } from 'node:fs/promises'
|
||||
import { builtinModules } from 'node:module'
|
||||
import { isAbsolute, normalize, resolve } from 'pathe'
|
||||
import type * as vite from 'vite'
|
||||
import type { isExternal } from 'externality'
|
||||
import { genDynamicImport, genObjectFromRawEntries } from 'knitwork'
|
||||
import fse from 'fs-extra'
|
||||
import { debounce } from 'perfect-debounce'
|
||||
import { isIgnored, logger } from '@nuxt/kit'
|
||||
import { hashId, isCSS, uniq } from './utils'
|
||||
@ -236,7 +236,7 @@ export async function initViteDevBundler (ctx: ViteBuildContext, onBuild: () =>
|
||||
const _doBuild = async () => {
|
||||
const start = Date.now()
|
||||
const { code, ids } = await bundleRequest(options, ctx.entry)
|
||||
await fse.writeFile(resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'), code, 'utf-8')
|
||||
await writeFile(resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'), code, 'utf-8')
|
||||
// Have CSS in the manifest to prevent FOUC on dev SSR
|
||||
const manifestIds: string[] = []
|
||||
for (const i of ids) {
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { hash } from 'ohash'
|
||||
|
||||
export { isVue } from '../../../nuxt/src/core/utils/plugins'
|
||||
|
||||
export function uniq<T> (arr: T[]): T[] {
|
||||
return Array.from(new Set(arr))
|
||||
}
|
||||
|
||||
// Copied from vue-bundle-renderer utils
|
||||
const IS_CSS_RE = /\.(?:css|scss|sass|postcss|pcss|less|stylus|styl)(?:\?[^.]+)?$/
|
||||
|
||||
@ -7,6 +13,10 @@ export function isCSS (file: string) {
|
||||
return IS_CSS_RE.test(file)
|
||||
}
|
||||
|
||||
export function hashId (id: string) {
|
||||
return '$id_' + hash(id)
|
||||
}
|
||||
|
||||
export function matchWithStringOrRegex (value: string, matcher: string | RegExp) {
|
||||
if (typeof matcher === 'string') {
|
||||
return value === matcher
|
||||
|
Loading…
Reference in New Issue
Block a user