Update package dependencies and remove unused files from node_modules
This commit is contained in:
58
node_modules/vitefu/src/index.d.cts
generated
vendored
58
node_modules/vitefu/src/index.d.cts
generated
vendored
@@ -1,58 +0,0 @@
|
||||
// CJS types like `index.d.ts` but dumbed down and doesn't import from `vite`. Thanks TypeScript.
|
||||
|
||||
export interface CrawlFrameworkPkgsOptions {
|
||||
root: string
|
||||
isBuild: boolean
|
||||
viteUserConfig?: any
|
||||
isFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
isFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
isSemiFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
isSemiFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
}
|
||||
|
||||
export interface CrawlFrameworkPkgsResult {
|
||||
optimizeDeps: {
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
}
|
||||
ssr: {
|
||||
noExternal: string[]
|
||||
external: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export declare function crawlFrameworkPkgs(
|
||||
options: CrawlFrameworkPkgsOptions
|
||||
): Promise<CrawlFrameworkPkgsResult>
|
||||
|
||||
export declare function findDepPkgJsonPath(
|
||||
dep: string,
|
||||
parent: string
|
||||
): Promise<string | undefined>
|
||||
|
||||
export declare function findClosestPkgJsonPath(
|
||||
dir: string,
|
||||
predicate?: (pkgJsonPath: string) => boolean | Promise<boolean>
|
||||
): Promise<string | undefined>
|
||||
|
||||
export declare function pkgNeedsOptimization(
|
||||
pkgJson: Record<string, any>,
|
||||
pkgJsonPath: string
|
||||
): Promise<boolean>
|
||||
|
||||
export declare function isDepExcluded(
|
||||
dep: string,
|
||||
optimizeDepsExclude: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepIncluded(
|
||||
dep: string,
|
||||
optimizeDepsInclude: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepNoExternaled(
|
||||
dep: string,
|
||||
ssrNoExternal: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepExternaled(dep: string, ssrExternal: any): boolean
|
178
node_modules/vitefu/src/index.d.ts
generated
vendored
178
node_modules/vitefu/src/index.d.ts
generated
vendored
@@ -1,178 +0,0 @@
|
||||
import type { DepOptimizationOptions, SSROptions, UserConfig } from 'vite'
|
||||
|
||||
export interface CrawlFrameworkPkgsOptions {
|
||||
/**
|
||||
* Path to the root of the project that contains the `package.json`
|
||||
*/
|
||||
root: string
|
||||
/**
|
||||
* Whether we're currently in a Vite build
|
||||
*/
|
||||
isBuild: boolean
|
||||
/**
|
||||
* Optional. If a Vite user config is passed, the output Vite config will respect the
|
||||
* set `optimizeDeps` and `ssr` options so it doesn't override it
|
||||
*/
|
||||
viteUserConfig?: UserConfig
|
||||
/**
|
||||
* Whether this is a framework package by checking it's `package.json`.
|
||||
* A framework package is one that exports special files that can't be processed
|
||||
* by esbuild natively. For example, exporting `.framework` files.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return pkgJson.keywords?.includes('my-framework')
|
||||
* ```
|
||||
*/
|
||||
isFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
/**
|
||||
* Whether this is a framework package by checking it's name. This is
|
||||
* usually used as a fast path. Return `true` or `false` if you know 100%
|
||||
* if it's a framework package or not. Return `undefined` to fallback to
|
||||
* `isFrameworkPkgByJson`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return SPECIAL_PACKAGES.includes(pkgName) || undefined
|
||||
* ```
|
||||
*/
|
||||
isFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
/**
|
||||
* Whether this is a semi-framework package by checking it's `package.json`.
|
||||
* A semi-framework package is one that **doesn't** export special files but
|
||||
* consumes other APIs of the framework. For example, it only does
|
||||
* `import { debounce } from 'my-framework/utils'`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return Object.keys(pkgJson.dependencies || {}).includes('my-framework')
|
||||
* ```
|
||||
*/
|
||||
isSemiFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
/**
|
||||
* Whether this is a semi-framework package by checking it's name. This is
|
||||
* usually used as a fast path. Return `true` or `false` if you know 100%
|
||||
* if it's a semi-framework package or not. Return `undefined` to fallback to
|
||||
* `isSemiFrameworkPkgByJson`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return SPECIAL_SEMI_PACKAGES.includes(pkgName) || undefined
|
||||
* ```
|
||||
*/
|
||||
isSemiFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
}
|
||||
|
||||
export interface CrawlFrameworkPkgsResult {
|
||||
optimizeDeps: {
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
}
|
||||
ssr: {
|
||||
noExternal: string[]
|
||||
external: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crawls for framework packages starting from `<root>/package.json` to build
|
||||
* out a partial Vite config. See the source code for details of how this is built.
|
||||
*/
|
||||
export declare function crawlFrameworkPkgs(
|
||||
options: CrawlFrameworkPkgsOptions
|
||||
): Promise<CrawlFrameworkPkgsResult>
|
||||
|
||||
/**
|
||||
* Find the `package.json` of a dep, starting from the parent, e.g. `process.cwd()`.
|
||||
* A simplified implementation of https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
||||
* (PACKAGE_RESOLVE) for `package.json` specifically.
|
||||
*/
|
||||
export declare function findDepPkgJsonPath(
|
||||
dep: string,
|
||||
parent: string
|
||||
): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Find the closest `package.json` path by walking `dir` upwards.
|
||||
*
|
||||
* Pass a function to `predicate` to check if the current `package.json` is the
|
||||
* one you're looking for. For example, finding `package.json` that has the
|
||||
* `name` field only. Throwing inside the `predicate` is safe and acts the same
|
||||
* as returning false.
|
||||
*/
|
||||
export declare function findClosestPkgJsonPath(
|
||||
dir: string,
|
||||
predicate?: (pkgJsonPath: string) => boolean | Promise<boolean>
|
||||
): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Check if a package needs to be optimized by Vite, aka if it's CJS-only
|
||||
*/
|
||||
export declare function pkgNeedsOptimization(
|
||||
pkgJson: Record<string, any>,
|
||||
pkgJsonPath: string
|
||||
): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `optimizeDeps.exclude` config
|
||||
* @param dep Dependency to be included
|
||||
* @param optimizeDepsExclude Existing `optimizeDeps.exclude` config
|
||||
* @example
|
||||
* ```ts
|
||||
* optimizeDeps: {
|
||||
* include: includesToAdd.filter((dep) => !isDepExcluded(dep, existingExclude))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepExcluded(
|
||||
dep: string,
|
||||
optimizeDepsExclude: NonNullable<DepOptimizationOptions['exclude']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `optimizeDeps.include` config
|
||||
* @param dep Dependency to be excluded
|
||||
* @param optimizeDepsInclude Existing `optimizeDeps.include` config
|
||||
* @example
|
||||
* ```ts
|
||||
* optimizeDeps: {
|
||||
* exclude: excludesToAdd.filter((dep) => !isDepIncluded(dep, existingInclude))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepIncluded(
|
||||
dep: string,
|
||||
optimizeDepsInclude: NonNullable<DepOptimizationOptions['include']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `ssr.noExternal` config
|
||||
* @param dep Dependency to be excluded
|
||||
* @param ssrNoExternal Existing `ssr.noExternal` config
|
||||
* @example
|
||||
* ```ts
|
||||
* ssr: {
|
||||
* external: externalsToAdd.filter((dep) => !isDepNoExternal(dep, existingNoExternal))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepNoExternaled(
|
||||
dep: string,
|
||||
ssrNoExternal: NonNullable<SSROptions['noExternal']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `ssr.external` config
|
||||
* @param dep Dependency to be noExternaled
|
||||
* @param ssrExternal Existing `ssr.external` config
|
||||
* @example
|
||||
* ```ts
|
||||
* ssr: {
|
||||
* noExternal: noExternalsToAdd.filter((dep) => !isDepExternal(dep, existingExternal))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepExternaled(
|
||||
dep: string,
|
||||
ssrExternal: NonNullable<SSROptions['external']>
|
||||
): boolean
|
22
node_modules/vitefu/src/index.js
generated
vendored
22
node_modules/vitefu/src/index.js
generated
vendored
@@ -1,6 +1,5 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import fsSync from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
import {
|
||||
isDepIncluded,
|
||||
@@ -13,20 +12,25 @@ import {
|
||||
let pnp
|
||||
if (process.versions.pnp) {
|
||||
try {
|
||||
const { createRequire } = (await import('module')).default
|
||||
pnp = createRequire(import.meta.url)('pnpapi')
|
||||
} catch {}
|
||||
}
|
||||
|
||||
export { isDepIncluded, isDepExcluded, isDepNoExternaled, isDepExternaled }
|
||||
|
||||
/** @type {import('./index.d.ts').crawlFrameworkPkgs} */
|
||||
/** @type {import('..').crawlFrameworkPkgs} */
|
||||
export async function crawlFrameworkPkgs(options) {
|
||||
const pkgJsonPath = await findClosestPkgJsonPath(options.root)
|
||||
if (!pkgJsonPath) {
|
||||
// don't throw as package.json is not required
|
||||
return {
|
||||
optimizeDeps: { include: [], exclude: [] },
|
||||
ssr: { noExternal: [], external: [] }
|
||||
// @ts-expect-error don't throw in deno as package.json is not required
|
||||
if (typeof Deno !== 'undefined') {
|
||||
return {
|
||||
optimizeDeps: { include: [], exclude: [] },
|
||||
ssr: { noExternal: [], external: [] }
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Cannot find package.json from ${options.root}`)
|
||||
}
|
||||
}
|
||||
const pkgJson = await readJson(pkgJsonPath).catch((e) => {
|
||||
@@ -189,7 +193,7 @@ export async function crawlFrameworkPkgs(options) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').findDepPkgJsonPath} */
|
||||
/** @type {import('..').findDepPkgJsonPath} */
|
||||
export async function findDepPkgJsonPath(dep, parent) {
|
||||
if (pnp) {
|
||||
try {
|
||||
@@ -217,7 +221,7 @@ export async function findDepPkgJsonPath(dep, parent) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').findClosestPkgJsonPath} */
|
||||
/** @type {import('..').findClosestPkgJsonPath} */
|
||||
export async function findClosestPkgJsonPath(dir, predicate = undefined) {
|
||||
if (dir.endsWith('package.json')) {
|
||||
dir = path.dirname(dir)
|
||||
@@ -237,7 +241,7 @@ export async function findClosestPkgJsonPath(dir, predicate = undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').pkgNeedsOptimization} */
|
||||
/** @type {import('..').pkgNeedsOptimization} */
|
||||
export async function pkgNeedsOptimization(pkgJson, pkgJsonPath) {
|
||||
// only optimize if is cjs, using the below as heuristic
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/162
|
||||
|
19
node_modules/vitefu/src/sync.cjs
generated
vendored
19
node_modules/vitefu/src/sync.cjs
generated
vendored
@@ -1,11 +1,11 @@
|
||||
// contains synchronous API only so it can be exported as CJS and ESM
|
||||
|
||||
/** @type {import('./index.d.ts').isDepIncluded} */
|
||||
/** @type {import('..').isDepIncluded} */
|
||||
function isDepIncluded(dep, optimizeDepsInclude) {
|
||||
return optimizeDepsInclude.some((id) => parseIncludeStr(id) === dep)
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepExcluded} */
|
||||
/** @type {import('..').isDepExcluded} */
|
||||
function isDepExcluded(dep, optimizeDepsExclude) {
|
||||
dep = parseIncludeStr(dep)
|
||||
return optimizeDepsExclude.some(
|
||||
@@ -13,7 +13,7 @@ function isDepExcluded(dep, optimizeDepsExclude) {
|
||||
)
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepNoExternaled} */
|
||||
/** @type {import('..').isDepNoExternaled} */
|
||||
function isDepNoExternaled(dep, ssrNoExternal) {
|
||||
if (ssrNoExternal === true) {
|
||||
return true
|
||||
@@ -22,18 +22,9 @@ function isDepNoExternaled(dep, ssrNoExternal) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepExternaled} */
|
||||
/** @type {import('..').isDepExternaled} */
|
||||
function isDepExternaled(dep, ssrExternal) {
|
||||
// If `ssrExternal` is `true`, it just means that all linked
|
||||
// dependencies should also be externalized by default. It doesn't
|
||||
// mean that a dependency is being explicitly externalized. So we
|
||||
// return `false` in this case.
|
||||
// @ts-expect-error can be true in Vite 6
|
||||
if (ssrExternal === true) {
|
||||
return false
|
||||
} else {
|
||||
return ssrExternal.includes(dep)
|
||||
}
|
||||
return ssrExternal.includes(dep)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user