feat(deps): upgrade to latest versions of c12, jiti and unbuild (#27995)

This commit is contained in:
Daniel Roe 2024-07-03 12:30:04 +01:00 committed by GitHub
parent 34fd04bb46
commit fb4d11d2b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 118 additions and 570 deletions

View File

@ -37,6 +37,9 @@
"nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6", "nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6",
"typescript": "5.5.3", "typescript": "5.5.3",
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
"c12": "2.0.0-beta.1",
"jiti": "2.0.0-beta.3",
"unbuild": "3.0.0-rc.6",
"@nuxt/kit": "workspace:*", "@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*", "@nuxt/schema": "workspace:*",
"@nuxt/ui-templates": "workspace:*", "@nuxt/ui-templates": "workspace:*",
@ -76,7 +79,7 @@
"globby": "14.0.2", "globby": "14.0.2",
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
"happy-dom": "14.12.3", "happy-dom": "14.12.3",
"jiti": "1.21.6", "jiti": "2.0.0-beta.3",
"markdownlint-cli": "0.41.0", "markdownlint-cli": "0.41.0",
"nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6", "nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6",
"nuxi": "3.12.0", "nuxi": "3.12.0",

View File

@ -27,14 +27,14 @@
}, },
"dependencies": { "dependencies": {
"@nuxt/schema": "workspace:*", "@nuxt/schema": "workspace:*",
"c12": "^1.11.1", "c12": "^2.0.0-beta.1",
"consola": "^3.2.3", "consola": "^3.2.3",
"defu": "^6.1.4", "defu": "^6.1.4",
"destr": "^2.0.3", "destr": "^2.0.3",
"globby": "^14.0.2", "globby": "^14.0.2",
"hash-sum": "^2.0.0", "hash-sum": "^2.0.0",
"ignore": "^5.3.1", "ignore": "^5.3.1",
"jiti": "^1.21.6", "jiti": "^2.0.0-beta.3",
"klona": "^2.0.6", "klona": "^2.0.6",
"mlly": "^1.7.1", "mlly": "^1.7.1",
"pathe": "^1.1.2", "pathe": "^1.1.2",
@ -50,7 +50,7 @@
"@types/hash-sum": "1.0.2", "@types/hash-sum": "1.0.2",
"@types/semver": "7.5.8", "@types/semver": "7.5.8",
"nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6", "nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6",
"unbuild": "latest", "unbuild": "3.0.0-rc.6",
"vite": "5.3.3", "vite": "5.3.3",
"vitest": "1.6.0", "vitest": "1.6.0",
"webpack": "5.92.1" "webpack": "5.92.1"

View File

@ -1,10 +1,10 @@
import { pathToFileURL } from 'node:url' import { pathToFileURL } from 'node:url'
import { normalize } from 'pathe' import { normalize } from 'pathe'
import { interopDefault } from 'mlly' import { interopDefault } from 'mlly'
import jiti from 'jiti' import { createJiti } from 'jiti'
// TODO: use create-require for jest environment // TODO: use create-require for jest environment
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true }) const jiti = createJiti(process.cwd(), { interopDefault: true })
/** @deprecated Do not use CJS utils */ /** @deprecated Do not use CJS utils */
export interface ResolveModuleOptions { export interface ResolveModuleOptions {
@ -37,7 +37,7 @@ function clearRequireCache (id: string) {
const entry = getRequireCacheItem(id) const entry = getRequireCacheItem(id)
if (!entry) { if (!entry) {
delete _require.cache[id] delete jiti.cache[id]
return return
} }
@ -49,13 +49,13 @@ function clearRequireCache (id: string) {
clearRequireCache(child.id) clearRequireCache(child.id)
} }
delete _require.cache[id] delete jiti.cache[id]
} }
/** @deprecated Do not use CJS utils */ /** @deprecated Do not use CJS utils */
function getRequireCacheItem (id: string) { function getRequireCacheItem (id: string) {
try { try {
return _require.cache[id] return jiti.cache[id]
} catch (e) { } catch (e) {
// ignore issues accessing require.cache // ignore issues accessing require.cache
} }
@ -72,7 +72,7 @@ export function getNodeModulesPaths (paths?: string[] | string) {
/** @deprecated Do not use CJS utils */ /** @deprecated Do not use CJS utils */
export function resolveModule (id: string, opts: ResolveModuleOptions = {}) { export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
return normalize(_require.resolve(id, { return normalize(jiti.resolve(id, {
paths: getNodeModulesPaths(opts.paths), paths: getNodeModulesPaths(opts.paths),
})) }))
} }
@ -88,7 +88,7 @@ export function requireModule (id: string, opts: RequireModuleOptions = {}) {
} }
// Try to require // Try to require
const requiredModule = _require(resolvedPath) const requiredModule = jiti(resolvedPath)
return requiredModule return requiredModule
} }

View File

@ -70,7 +70,7 @@
"@unhead/vue": "^1.9.14", "@unhead/vue": "^1.9.14",
"@vue/shared": "^3.4.31", "@vue/shared": "^3.4.31",
"acorn": "8.12.0", "acorn": "8.12.0",
"c12": "^1.11.1", "c12": "^2.0.0-beta.1",
"chokidar": "^3.6.0", "chokidar": "^3.6.0",
"compatx": "^0.1.8", "compatx": "^0.1.8",
"consola": "^3.2.3", "consola": "^3.2.3",
@ -85,7 +85,7 @@
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
"hookable": "^5.5.3", "hookable": "^5.5.3",
"ignore": "^5.3.1", "ignore": "^5.3.1",
"jiti": "^1.21.6", "jiti": "^2.0.0-beta.3",
"klona": "^2.0.6", "klona": "^2.0.6",
"knitwork": "^1.1.0", "knitwork": "^1.1.0",
"magic-string": "^0.30.10", "magic-string": "^0.30.10",
@ -125,7 +125,7 @@
"@types/estree": "1.0.5", "@types/estree": "1.0.5",
"@vitejs/plugin-vue": "5.0.5", "@vitejs/plugin-vue": "5.0.5",
"@vue/compiler-sfc": "3.4.31", "@vue/compiler-sfc": "3.4.31",
"unbuild": "latest", "unbuild": "3.0.0-rc.6",
"vite": "5.3.3", "vite": "5.3.3",
"vitest": "1.6.0" "vitest": "1.6.0"
}, },

View File

@ -1,7 +1,7 @@
import { pathToFileURL } from 'node:url' import { pathToFileURL } from 'node:url'
import type { EventType } from '@parcel/watcher' import type { EventType } from '@parcel/watcher'
import type { FSWatcher } from 'chokidar' import type { FSWatcher } from 'chokidar'
import chokidar from 'chokidar' import { watch as chokidarWatch } from 'chokidar'
import { isIgnored, logger, tryResolveModule, useNuxt } from '@nuxt/kit' import { isIgnored, logger, tryResolveModule, useNuxt } from '@nuxt/kit'
import { interopDefault } from 'mlly' import { interopDefault } from 'mlly'
import { debounce } from 'perfect-debounce' import { debounce } from 'perfect-debounce'
@ -77,7 +77,7 @@ async function watch (nuxt: Nuxt) {
function createWatcher () { function createWatcher () {
const nuxt = useNuxt() const nuxt = useNuxt()
const watcher = chokidar.watch(nuxt.options._layers.map(i => i.config.srcDir as string).filter(Boolean), { const watcher = chokidarWatch(nuxt.options._layers.map(i => i.config.srcDir as string).filter(Boolean), {
...nuxt.options.watchers.chokidar, ...nuxt.options.watchers.chokidar,
ignoreInitial: true, ignoreInitial: true,
ignored: [ ignored: [
@ -110,7 +110,7 @@ function createGranularWatcher () {
} }
for (const dir of pathsToWatch) { for (const dir of pathsToWatch) {
pending++ pending++
const watcher = chokidar.watch(dir, { ...nuxt.options.watchers.chokidar, ignoreInitial: false, depth: 0, ignored: [isIgnored, '**/node_modules'] }) const watcher = chokidarWatch(dir, { ...nuxt.options.watchers.chokidar, ignoreInitial: false, depth: 0, ignored: [isIgnored, '**/node_modules'] })
const watchers: Record<string, FSWatcher> = {} const watchers: Record<string, FSWatcher> = {}
watcher.on('all', (event, path) => { watcher.on('all', (event, path) => {
@ -123,7 +123,7 @@ function createGranularWatcher () {
delete watchers[path] delete watchers[path]
} }
if (event === 'addDir' && path !== dir && !ignoredDirs.has(path) && !pathsToWatch.includes(path) && !(path in watchers) && !isIgnored(path)) { if (event === 'addDir' && path !== dir && !ignoredDirs.has(path) && !pathsToWatch.includes(path) && !(path in watchers) && !isIgnored(path)) {
watchers[path] = chokidar.watch(path, { ...nuxt.options.watchers.chokidar, ignored: [isIgnored] }) watchers[path] = chokidarWatch(path, { ...nuxt.options.watchers.chokidar, ignored: [isIgnored] })
watchers[path].on('all', (event, p) => nuxt.callHook('builder:watch', event, normalize(p))) watchers[path].on('all', (event, p) => nuxt.callHook('builder:watch', event, normalize(p)))
nuxt.hook('close', () => watchers[path]?.close()) nuxt.hook('close', () => watchers[path]?.close())
} }

View File

@ -1,8 +1,8 @@
import { existsSync } from 'node:fs' import { existsSync } from 'node:fs'
import { mkdir, writeFile } from 'node:fs/promises' import { mkdir, writeFile } from 'node:fs/promises'
import { fileURLToPath, pathToFileURL } from 'node:url' import { fileURLToPath, pathToFileURL } from 'node:url'
import { dirname, resolve } from 'pathe' import { resolve } from 'pathe'
import chokidar from 'chokidar' import { watch } from 'chokidar'
import { interopDefault } from 'mlly' import { interopDefault } from 'mlly'
import { defu } from 'defu' import { defu } from 'defu'
import { debounce } from 'perfect-debounce' import { debounce } from 'perfect-debounce'
@ -13,7 +13,7 @@ import {
} from 'untyped' } from 'untyped'
import type { Schema, SchemaDefinition } from 'untyped' import type { Schema, SchemaDefinition } from 'untyped'
import untypedPlugin from 'untyped/babel-plugin' import untypedPlugin from 'untyped/babel-plugin'
import jiti from 'jiti' import { createJiti } from 'jiti'
export default defineNuxtModule({ export default defineNuxtModule({
meta: { meta: {
@ -23,11 +23,9 @@ export default defineNuxtModule({
const resolver = createResolver(import.meta.url) const resolver = createResolver(import.meta.url)
// Initialize untyped/jiti loader // Initialize untyped/jiti loader
const _resolveSchema = jiti(dirname(fileURLToPath(import.meta.url)), { const _resolveSchema = createJiti(fileURLToPath(import.meta.url), {
esmResolve: true,
interopDefault: true, interopDefault: true,
cache: false, cache: false,
requireCache: false,
transformOptions: { transformOptions: {
babel: { babel: {
plugins: [untypedPlugin], plugins: [untypedPlugin],
@ -77,7 +75,7 @@ export default defineNuxtModule({
const filesToWatch = await Promise.all(nuxt.options._layers.map(layer => const filesToWatch = await Promise.all(nuxt.options._layers.map(layer =>
resolver.resolve(layer.config.rootDir, 'nuxt.schema.*'), resolver.resolve(layer.config.rootDir, 'nuxt.schema.*'),
)) ))
const watcher = chokidar.watch(filesToWatch, { const watcher = watch(filesToWatch, {
...nuxt.options.watchers.chokidar, ...nuxt.options.watchers.chokidar,
ignoreInitial: true, ignoreInitial: true,
}) })

View File

@ -45,13 +45,13 @@
"@vue/compiler-core": "3.4.31", "@vue/compiler-core": "3.4.31",
"@vue/compiler-sfc": "3.4.31", "@vue/compiler-sfc": "3.4.31",
"@vue/language-core": "2.0.24", "@vue/language-core": "2.0.24",
"c12": "1.11.1", "c12": "2.0.0-beta.1",
"esbuild-loader": "4.2.0", "esbuild-loader": "4.2.0",
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
"ignore": "5.3.1", "ignore": "5.3.1",
"nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6", "nitro": "npm:nitro-nightly@3.0.0-beta-28659787.859de2d6",
"ofetch": "1.3.4", "ofetch": "1.3.4",
"unbuild": "latest", "unbuild": "3.0.0-rc.6",
"unctx": "2.3.1", "unctx": "2.3.1",
"unenv": "1.9.0", "unenv": "1.9.0",
"vite": "5.3.3", "vite": "5.3.3",

View File

@ -25,7 +25,7 @@
"execa": "9.3.0", "execa": "9.3.0",
"globby": "14.0.2", "globby": "14.0.2",
"html-minifier": "4.0.0", "html-minifier": "4.0.0",
"jiti": "1.21.6", "jiti": "2.0.0-beta.3",
"knitwork": "1.1.0", "knitwork": "1.1.0",
"pathe": "1.1.2", "pathe": "1.1.2",
"prettier": "3.3.2", "prettier": "3.3.2",

View File

@ -28,7 +28,7 @@
"@types/clear": "0.1.4", "@types/clear": "0.1.4",
"@types/estree": "1.0.5", "@types/estree": "1.0.5",
"rollup": "4.18.0", "rollup": "4.18.0",
"unbuild": "latest", "unbuild": "3.0.0-rc.6",
"vue": "3.4.31" "vue": "3.4.31"
}, },
"dependencies": { "dependencies": {

View File

@ -78,7 +78,7 @@
"@types/webpack-bundle-analyzer": "4.7.0", "@types/webpack-bundle-analyzer": "4.7.0",
"@types/webpack-hot-middleware": "2.25.9", "@types/webpack-hot-middleware": "2.25.9",
"rollup": "4.18.0", "rollup": "4.18.0",
"unbuild": "latest", "unbuild": "3.0.0-rc.6",
"vue": "3.4.31" "vue": "3.4.31"
}, },
"peerDependencies": { "peerDependencies": {

File diff suppressed because it is too large Load Diff