Ajout de promotion et de commande
This commit is contained in:
+2406
File diff suppressed because it is too large
Load Diff
+20
@@ -0,0 +1,20 @@
|
||||
# vite ⚡
|
||||
|
||||
> Next Generation Frontend Tooling
|
||||
|
||||
- 💡 Instant Server Start
|
||||
- ⚡️ Lightning Fast HMR
|
||||
- 🛠️ Rich Features
|
||||
- 📦 Optimized Build
|
||||
- 🔩 Universal Plugin Interface
|
||||
- 🔑 Fully Typed APIs
|
||||
|
||||
Vite (French word for "fast", pronounced `/vit/`) is a new breed of frontend build tool that significantly improves the frontend development experience. It consists of two major parts:
|
||||
|
||||
- A dev server that serves your source files over [native ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), with [rich built-in features](https://vite.dev/guide/features.html) and astonishingly fast [Hot Module Replacement (HMR)](https://vite.dev/guide/features.html#hot-module-replacement).
|
||||
|
||||
- A [build command](https://vite.dev/guide/build.html) that bundles your code with [Rollup](https://rollupjs.org), pre-configured to output highly optimized static assets for production.
|
||||
|
||||
In addition, Vite is highly extensible via its [Plugin API](https://vite.dev/guide/api-plugin.html) and [JavaScript API](https://vite.dev/guide/api-javascript.html) with full typing support.
|
||||
|
||||
[Read the Docs to Learn More](https://vite.dev).
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
(*
|
||||
Copyright (c) 2015-present, Facebook, Inc.
|
||||
|
||||
This source code is licensed under the MIT license found in the
|
||||
LICENSE file at
|
||||
https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
|
||||
*)
|
||||
|
||||
property targetTab: null
|
||||
property targetTabIndex: -1
|
||||
property targetWindow: null
|
||||
property theProgram: "Google Chrome"
|
||||
|
||||
on run argv
|
||||
set theURL to item 1 of argv
|
||||
|
||||
-- Allow requested program to be optional,
|
||||
-- default to Google Chrome
|
||||
if (count of argv) > 1 then
|
||||
set theProgram to item 2 of argv
|
||||
end if
|
||||
|
||||
using terms from application "Google Chrome"
|
||||
tell application theProgram
|
||||
|
||||
if (count every window) = 0 then
|
||||
make new window
|
||||
end if
|
||||
|
||||
-- 1: Looking for tab running debugger
|
||||
-- then, Reload debugging tab if found
|
||||
-- then return
|
||||
set found to my lookupTabWithUrl(theURL)
|
||||
if found then
|
||||
set targetWindow's active tab index to targetTabIndex
|
||||
tell targetTab to reload
|
||||
tell targetWindow to activate
|
||||
set index of targetWindow to 1
|
||||
return
|
||||
end if
|
||||
|
||||
-- 2: Looking for Empty tab
|
||||
-- In case debugging tab was not found
|
||||
-- We try to find an empty tab instead
|
||||
set found to my lookupTabWithUrl("chrome://newtab/")
|
||||
if found then
|
||||
set targetWindow's active tab index to targetTabIndex
|
||||
set URL of targetTab to theURL
|
||||
tell targetWindow to activate
|
||||
return
|
||||
end if
|
||||
|
||||
-- 3: Create new tab
|
||||
-- both debugging and empty tab were not found
|
||||
-- make a new tab with url
|
||||
tell window 1
|
||||
activate
|
||||
make new tab with properties {URL:theURL}
|
||||
end tell
|
||||
end tell
|
||||
end using terms from
|
||||
end run
|
||||
|
||||
-- Function:
|
||||
-- Lookup tab with given url
|
||||
-- if found, store tab, index, and window in properties
|
||||
-- (properties were declared on top of file)
|
||||
on lookupTabWithUrl(lookupUrl)
|
||||
using terms from application "Google Chrome"
|
||||
tell application theProgram
|
||||
-- Find a tab with the given url
|
||||
set found to false
|
||||
set theTabIndex to -1
|
||||
repeat with theWindow in every window
|
||||
set theTabIndex to 0
|
||||
repeat with theTab in every tab of theWindow
|
||||
set theTabIndex to theTabIndex + 1
|
||||
if (theTab's URL as string) contains lookupUrl then
|
||||
-- assign tab, tab index, and window to properties
|
||||
set targetTab to theTab
|
||||
set targetTabIndex to theTabIndex
|
||||
set targetWindow to theWindow
|
||||
set found to true
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
|
||||
if found then
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
end tell
|
||||
end using terms from
|
||||
return found
|
||||
end lookupTabWithUrl
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env node
|
||||
import { performance } from 'node:perf_hooks'
|
||||
import module from 'node:module'
|
||||
|
||||
if (!import.meta.url.includes('node_modules')) {
|
||||
try {
|
||||
// only available as dev dependency
|
||||
await import('source-map-support').then((r) => r.default.install())
|
||||
} catch {}
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
throw new Error('UNHANDLED PROMISE REJECTION', { cause: err })
|
||||
})
|
||||
}
|
||||
|
||||
global.__vite_start_time = performance.now()
|
||||
|
||||
// check debug mode first before requiring the CLI.
|
||||
const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
|
||||
const filterIndex = process.argv.findIndex((arg) =>
|
||||
/^(?:-f|--filter)$/.test(arg),
|
||||
)
|
||||
const profileIndex = process.argv.indexOf('--profile')
|
||||
|
||||
if (debugIndex > 0) {
|
||||
let value = process.argv[debugIndex + 1]
|
||||
if (!value || value.startsWith('-')) {
|
||||
value = 'vite:*'
|
||||
} else {
|
||||
// support debugging multiple flags with comma-separated list
|
||||
value = value
|
||||
.split(',')
|
||||
.map((v) => `vite:${v}`)
|
||||
.join(',')
|
||||
}
|
||||
process.env.DEBUG = `${
|
||||
process.env.DEBUG ? process.env.DEBUG + ',' : ''
|
||||
}${value}`
|
||||
|
||||
if (filterIndex > 0) {
|
||||
const filter = process.argv[filterIndex + 1]
|
||||
if (filter && !filter.startsWith('-')) {
|
||||
process.env.VITE_DEBUG_FILTER = filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
try {
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.8.0+ and only called if it exists
|
||||
module.enableCompileCache?.()
|
||||
// flush the cache after 10s because the cache is not flushed until process end
|
||||
// for dev server, the cache is never flushed unless manually flushed because the process.exit is called
|
||||
// also flushing the cache in SIGINT handler seems to cause the process to hang
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.12.0+ and only called if it exists
|
||||
module.flushCompileCache?.()
|
||||
} catch {}
|
||||
}, 10 * 1000).unref()
|
||||
} catch {}
|
||||
return import('../dist/node/cli.js')
|
||||
}
|
||||
|
||||
if (profileIndex > 0) {
|
||||
process.argv.splice(profileIndex, 1)
|
||||
const next = process.argv[profileIndex]
|
||||
if (next && !next.startsWith('-')) {
|
||||
process.argv.splice(profileIndex, 1)
|
||||
}
|
||||
const inspector = await import('node:inspector').then((r) => r.default)
|
||||
const session = (global.__vite_profile_session = new inspector.Session())
|
||||
session.connect()
|
||||
session.post('Profiler.enable', () => {
|
||||
session.post('Profiler.start', start)
|
||||
})
|
||||
} else {
|
||||
start()
|
||||
}
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
/// <reference path="./types/importMeta.d.ts" />
|
||||
|
||||
// CSS modules
|
||||
type CSSModuleClasses = { readonly [key: string]: string }
|
||||
|
||||
declare module '*.module.css' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.scss' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.sass' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.less' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.styl' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.stylus' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.pcss' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.sss' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
|
||||
// CSS
|
||||
declare module '*.css' {}
|
||||
declare module '*.scss' {}
|
||||
declare module '*.sass' {}
|
||||
declare module '*.less' {}
|
||||
declare module '*.styl' {}
|
||||
declare module '*.stylus' {}
|
||||
declare module '*.pcss' {}
|
||||
declare module '*.sss' {}
|
||||
|
||||
// Built-in asset types
|
||||
// see `src/node/constants.ts`
|
||||
|
||||
// images
|
||||
declare module '*.apng' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.bmp' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.png' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.jpg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.jpeg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.jfif' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.pjpeg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.pjp' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.gif' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.svg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ico' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.webp' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.avif' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.cur' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.jxl' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// media
|
||||
declare module '*.mp4' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.webm' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ogg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.mp3' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.wav' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.flac' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.aac' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.opus' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.mov' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.m4a' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.vtt' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// fonts
|
||||
declare module '*.woff' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.woff2' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.eot' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ttf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.otf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// other
|
||||
declare module '*.webmanifest' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.pdf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.txt' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// wasm?init
|
||||
declare module '*.wasm?init' {
|
||||
const initWasm: (
|
||||
options?: WebAssembly.Imports,
|
||||
) => Promise<WebAssembly.Instance>
|
||||
export default initWasm
|
||||
}
|
||||
|
||||
// web worker
|
||||
declare module '*?worker' {
|
||||
const workerConstructor: {
|
||||
new (options?: { name?: string }): Worker
|
||||
}
|
||||
export default workerConstructor
|
||||
}
|
||||
|
||||
declare module '*?worker&inline' {
|
||||
const workerConstructor: {
|
||||
new (options?: { name?: string }): Worker
|
||||
}
|
||||
export default workerConstructor
|
||||
}
|
||||
|
||||
declare module '*?worker&url' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?sharedworker' {
|
||||
const sharedWorkerConstructor: {
|
||||
new (options?: { name?: string }): SharedWorker
|
||||
}
|
||||
export default sharedWorkerConstructor
|
||||
}
|
||||
|
||||
declare module '*?sharedworker&inline' {
|
||||
const sharedWorkerConstructor: {
|
||||
new (options?: { name?: string }): SharedWorker
|
||||
}
|
||||
export default sharedWorkerConstructor
|
||||
}
|
||||
|
||||
declare module '*?sharedworker&url' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?raw' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?url' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?inline' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?no-inline' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?url&inline' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?url&no-inline' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare interface VitePreloadErrorEvent extends Event {
|
||||
payload: Error
|
||||
}
|
||||
|
||||
declare interface WindowEventMap {
|
||||
'vite:preloadError': VitePreloadErrorEvent
|
||||
}
|
||||
+1134
File diff suppressed because it is too large
Load Diff
+24
@@ -0,0 +1,24 @@
|
||||
const context = (() => {
|
||||
if (typeof globalThis !== "undefined") {
|
||||
return globalThis;
|
||||
} else if (typeof self !== "undefined") {
|
||||
return self;
|
||||
} else if (typeof window !== "undefined") {
|
||||
return window;
|
||||
} else {
|
||||
return Function("return this")();
|
||||
}
|
||||
})();
|
||||
const defines = __DEFINES__;
|
||||
Object.keys(defines).forEach((key) => {
|
||||
const segments = key.split(".");
|
||||
let target = context;
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
const segment = segments[i];
|
||||
if (i === segments.length - 1) {
|
||||
target[segment] = defines[key];
|
||||
} else {
|
||||
target = target[segment] || (target[segment] = {});
|
||||
}
|
||||
}
|
||||
});
|
||||
+3987
File diff suppressed because it is too large
Load Diff
+553
File diff suppressed because it is too large
Load Diff
+822
File diff suppressed because it is too large
Load Diff
+8218
File diff suppressed because one or more lines are too long
+49531
File diff suppressed because one or more lines are too long
+7113
File diff suppressed because it is too large
Load Diff
+949
File diff suppressed because it is too large
Load Diff
+149
@@ -0,0 +1,149 @@
|
||||
import path, { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const { version } = JSON.parse(
|
||||
readFileSync(new URL("../../package.json", import.meta.url)).toString()
|
||||
);
|
||||
const ROLLUP_HOOKS = [
|
||||
"options",
|
||||
"buildStart",
|
||||
"buildEnd",
|
||||
"renderStart",
|
||||
"renderError",
|
||||
"renderChunk",
|
||||
"writeBundle",
|
||||
"generateBundle",
|
||||
"banner",
|
||||
"footer",
|
||||
"augmentChunkHash",
|
||||
"outputOptions",
|
||||
"renderDynamicImport",
|
||||
"resolveFileUrl",
|
||||
"resolveImportMeta",
|
||||
"intro",
|
||||
"outro",
|
||||
"closeBundle",
|
||||
"closeWatcher",
|
||||
"load",
|
||||
"moduleParsed",
|
||||
"watchChange",
|
||||
"resolveDynamicImport",
|
||||
"resolveId",
|
||||
"shouldTransformCachedModule",
|
||||
"transform",
|
||||
"onLog"
|
||||
];
|
||||
const VERSION = version;
|
||||
const DEFAULT_MAIN_FIELDS = [
|
||||
"browser",
|
||||
"module",
|
||||
"jsnext:main",
|
||||
// moment still uses this...
|
||||
"jsnext"
|
||||
];
|
||||
const DEFAULT_CLIENT_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS);
|
||||
const DEFAULT_SERVER_MAIN_FIELDS = Object.freeze(
|
||||
DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser")
|
||||
);
|
||||
const DEV_PROD_CONDITION = `development|production`;
|
||||
const DEFAULT_CONDITIONS = ["module", "browser", "node", DEV_PROD_CONDITION];
|
||||
const DEFAULT_CLIENT_CONDITIONS = Object.freeze(
|
||||
DEFAULT_CONDITIONS.filter((c) => c !== "node")
|
||||
);
|
||||
const DEFAULT_SERVER_CONDITIONS = Object.freeze(
|
||||
DEFAULT_CONDITIONS.filter((c) => c !== "browser")
|
||||
);
|
||||
const ESBUILD_MODULES_TARGET = [
|
||||
"es2020",
|
||||
"edge88",
|
||||
"firefox78",
|
||||
"chrome87",
|
||||
"safari14"
|
||||
];
|
||||
const DEFAULT_CONFIG_FILES = [
|
||||
"vite.config.js",
|
||||
"vite.config.mjs",
|
||||
"vite.config.ts",
|
||||
"vite.config.cjs",
|
||||
"vite.config.mts",
|
||||
"vite.config.cts"
|
||||
];
|
||||
const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
|
||||
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
||||
const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
|
||||
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
||||
const FS_PREFIX = `/@fs/`;
|
||||
const CLIENT_PUBLIC_PATH = `/@vite/client`;
|
||||
const ENV_PUBLIC_PATH = `/@vite/env`;
|
||||
const VITE_PACKAGE_DIR = resolve(
|
||||
// import.meta.url is `dist/node/constants.js` after bundle
|
||||
fileURLToPath(import.meta.url),
|
||||
"../../.."
|
||||
);
|
||||
const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
|
||||
const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
|
||||
const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
|
||||
const KNOWN_ASSET_TYPES = [
|
||||
// images
|
||||
"apng",
|
||||
"bmp",
|
||||
"png",
|
||||
"jpe?g",
|
||||
"jfif",
|
||||
"pjpeg",
|
||||
"pjp",
|
||||
"gif",
|
||||
"svg",
|
||||
"ico",
|
||||
"webp",
|
||||
"avif",
|
||||
"cur",
|
||||
"jxl",
|
||||
// media
|
||||
"mp4",
|
||||
"webm",
|
||||
"ogg",
|
||||
"mp3",
|
||||
"wav",
|
||||
"flac",
|
||||
"aac",
|
||||
"opus",
|
||||
"mov",
|
||||
"m4a",
|
||||
"vtt",
|
||||
// fonts
|
||||
"woff2?",
|
||||
"eot",
|
||||
"ttf",
|
||||
"otf",
|
||||
// other
|
||||
"webmanifest",
|
||||
"pdf",
|
||||
"txt"
|
||||
];
|
||||
const DEFAULT_ASSETS_RE = new RegExp(
|
||||
`\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`,
|
||||
"i"
|
||||
);
|
||||
const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
|
||||
const loopbackHosts = /* @__PURE__ */ new Set([
|
||||
"localhost",
|
||||
"127.0.0.1",
|
||||
"::1",
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001"
|
||||
]);
|
||||
const wildcardHosts = /* @__PURE__ */ new Set([
|
||||
"0.0.0.0",
|
||||
"::",
|
||||
"0000:0000:0000:0000:0000:0000:0000:0000"
|
||||
]);
|
||||
const DEFAULT_DEV_PORT = 5173;
|
||||
const DEFAULT_PREVIEW_PORT = 4173;
|
||||
const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
|
||||
const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
||||
const METADATA_FILENAME = "_metadata.json";
|
||||
const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR";
|
||||
const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR";
|
||||
|
||||
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CLIENT_CONDITIONS, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_SERVER_CONDITIONS, DEFAULT_SERVER_MAIN_FIELDS, DEP_VERSION_RE, DEV_PROD_CONDITION, ENV_ENTRY, ENV_PUBLIC_PATH, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, defaultAllowedOrigins, loopbackHosts, wildcardHosts };
|
||||
+4222
File diff suppressed because it is too large
Load Diff
+194
@@ -0,0 +1,194 @@
|
||||
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
||||
import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-D4NMHUTW.js';
|
||||
export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-D4NMHUTW.js';
|
||||
export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
|
||||
export { version as esbuildVersion } from 'esbuild';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:fs/promises';
|
||||
import 'node:url';
|
||||
import 'node:util';
|
||||
import 'node:perf_hooks';
|
||||
import 'node:module';
|
||||
import 'node:crypto';
|
||||
import 'picomatch';
|
||||
import 'path';
|
||||
import 'fs';
|
||||
import 'fdir';
|
||||
import 'node:child_process';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'tty';
|
||||
import 'util';
|
||||
import 'net';
|
||||
import 'events';
|
||||
import 'url';
|
||||
import 'http';
|
||||
import 'stream';
|
||||
import 'os';
|
||||
import 'child_process';
|
||||
import 'node:os';
|
||||
import 'node:net';
|
||||
import 'node:dns';
|
||||
import 'vite/module-runner';
|
||||
import 'node:buffer';
|
||||
import 'module';
|
||||
import 'node:readline';
|
||||
import 'node:process';
|
||||
import 'node:events';
|
||||
import 'tinyglobby';
|
||||
import 'crypto';
|
||||
import 'node:assert';
|
||||
import 'node:v8';
|
||||
import 'node:worker_threads';
|
||||
import 'https';
|
||||
import 'tls';
|
||||
import 'zlib';
|
||||
import 'buffer';
|
||||
import 'assert';
|
||||
import 'node:querystring';
|
||||
import 'node:zlib';
|
||||
|
||||
const CSS_LANGS_RE = (
|
||||
// eslint-disable-next-line regexp/no-unused-capturing-group
|
||||
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
||||
);
|
||||
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
||||
class SplitVendorChunkCache {
|
||||
cache;
|
||||
constructor() {
|
||||
this.cache = /* @__PURE__ */ new Map();
|
||||
}
|
||||
reset() {
|
||||
this.cache = /* @__PURE__ */ new Map();
|
||||
}
|
||||
}
|
||||
function splitVendorChunk(options = {}) {
|
||||
const cache = options.cache ?? new SplitVendorChunkCache();
|
||||
return (id, { getModuleInfo }) => {
|
||||
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
||||
return "vendor";
|
||||
}
|
||||
};
|
||||
}
|
||||
function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
||||
if (cache.has(id)) {
|
||||
return cache.get(id);
|
||||
}
|
||||
if (importStack.includes(id)) {
|
||||
cache.set(id, false);
|
||||
return false;
|
||||
}
|
||||
const mod = getModuleInfo(id);
|
||||
if (!mod) {
|
||||
cache.set(id, false);
|
||||
return false;
|
||||
}
|
||||
if (mod.isEntry) {
|
||||
cache.set(id, true);
|
||||
return true;
|
||||
}
|
||||
const someImporterIs = mod.importers.some(
|
||||
(importer) => staticImportedByEntry(
|
||||
importer,
|
||||
getModuleInfo,
|
||||
cache,
|
||||
importStack.concat(id)
|
||||
)
|
||||
);
|
||||
cache.set(id, someImporterIs);
|
||||
return someImporterIs;
|
||||
}
|
||||
function splitVendorChunkPlugin() {
|
||||
const caches = [];
|
||||
function createSplitVendorChunk(output, config) {
|
||||
const cache = new SplitVendorChunkCache();
|
||||
caches.push(cache);
|
||||
const build = config.build ?? {};
|
||||
const format = output.format;
|
||||
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
||||
return splitVendorChunk({ cache });
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: "vite:split-vendor-chunk",
|
||||
config(config) {
|
||||
let outputs = config.build?.rollupOptions?.output;
|
||||
if (outputs) {
|
||||
outputs = arraify(outputs);
|
||||
for (const output of outputs) {
|
||||
const viteManualChunks = createSplitVendorChunk(output, config);
|
||||
if (viteManualChunks) {
|
||||
if (output.manualChunks) {
|
||||
if (typeof output.manualChunks === "function") {
|
||||
const userManualChunks = output.manualChunks;
|
||||
output.manualChunks = (id, api) => {
|
||||
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
||||
};
|
||||
} else {
|
||||
console.warn(
|
||||
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
output.manualChunks = viteManualChunks;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: createSplitVendorChunk({}, config)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
buildStart() {
|
||||
caches.forEach((cache) => cache.reset());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createFetchableDevEnvironment(name, config, context) {
|
||||
if (typeof Request === "undefined" || typeof Response === "undefined") {
|
||||
throw new TypeError(
|
||||
"FetchableDevEnvironment requires a global `Request` and `Response` object."
|
||||
);
|
||||
}
|
||||
if (!context.handleRequest) {
|
||||
throw new TypeError(
|
||||
"FetchableDevEnvironment requires a `handleRequest` method during initialisation."
|
||||
);
|
||||
}
|
||||
return new FetchableDevEnvironment(name, config, context);
|
||||
}
|
||||
function isFetchableDevEnvironment(environment) {
|
||||
return environment instanceof FetchableDevEnvironment;
|
||||
}
|
||||
class FetchableDevEnvironment extends DevEnvironment {
|
||||
_handleRequest;
|
||||
constructor(name, config, context) {
|
||||
super(name, config, context);
|
||||
this._handleRequest = context.handleRequest;
|
||||
}
|
||||
async dispatchFetch(request) {
|
||||
if (!(request instanceof Request)) {
|
||||
throw new TypeError(
|
||||
"FetchableDevEnvironment `dispatchFetch` must receive a `Request` object."
|
||||
);
|
||||
}
|
||||
const response = await this._handleRequest(request);
|
||||
if (!(response instanceof Response)) {
|
||||
throw new TypeError(
|
||||
"FetchableDevEnvironment `context.handleRequest` must return a `Response` object."
|
||||
);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
export { DevEnvironment, createFetchableDevEnvironment, isCSSRequest, isFetchableDevEnvironment, splitVendorChunk, splitVendorChunkPlugin };
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
|
||||
import { Update, HotPayload } from '../../types/hmrPayload.js';
|
||||
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
||||
import { N as NormalizedModuleRunnerTransport, E as ExternalFetchResult, V as ViteFetchResult, M as ModuleRunnerTransport, F as FetchFunctionOptions, a as FetchResult } from './moduleRunnerTransport.d-DJ_mE5sf.js';
|
||||
export { b as ModuleRunnerTransportHandlers, c as createWebSocketModuleRunnerTransport } from './moduleRunnerTransport.d-DJ_mE5sf.js';
|
||||
|
||||
interface SourceMapLike {
|
||||
version: number;
|
||||
mappings?: string;
|
||||
names?: string[];
|
||||
sources?: string[];
|
||||
sourcesContent?: string[];
|
||||
}
|
||||
declare class DecodedMap {
|
||||
map: SourceMapLike;
|
||||
_encoded: string;
|
||||
_decoded: undefined | number[][][];
|
||||
_decodedMemo: Stats;
|
||||
url: string;
|
||||
version: number;
|
||||
names: string[];
|
||||
resolvedSources: string[];
|
||||
constructor(map: SourceMapLike, from: string);
|
||||
}
|
||||
interface Stats {
|
||||
lastKey: number;
|
||||
lastNeedle: number;
|
||||
lastIndex: number;
|
||||
}
|
||||
|
||||
type CustomListenersMap = Map<string, ((data: any) => void)[]>;
|
||||
interface HotModule {
|
||||
id: string;
|
||||
callbacks: HotCallback[];
|
||||
}
|
||||
interface HotCallback {
|
||||
deps: string[];
|
||||
fn: (modules: Array<ModuleNamespace | undefined>) => void;
|
||||
}
|
||||
interface HMRLogger {
|
||||
error(msg: string | Error): void;
|
||||
debug(...msg: unknown[]): void;
|
||||
}
|
||||
declare class HMRClient {
|
||||
logger: HMRLogger;
|
||||
private transport;
|
||||
private importUpdatedModule;
|
||||
hotModulesMap: Map<string, HotModule>;
|
||||
disposeMap: Map<string, (data: any) => void | Promise<void>>;
|
||||
pruneMap: Map<string, (data: any) => void | Promise<void>>;
|
||||
dataMap: Map<string, any>;
|
||||
customListenersMap: CustomListenersMap;
|
||||
ctxToListenersMap: Map<string, CustomListenersMap>;
|
||||
currentFirstInvalidatedBy: string | undefined;
|
||||
constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
|
||||
notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
|
||||
send(payload: HotPayload): void;
|
||||
clear(): void;
|
||||
prunePaths(paths: string[]): Promise<void>;
|
||||
protected warnFailedUpdate(err: Error, path: string | string[]): void;
|
||||
private updateQueue;
|
||||
private pendingUpdateQueue;
|
||||
/**
|
||||
* buffer multiple hot updates triggered by the same src change
|
||||
* so that they are invoked in the same order they were sent.
|
||||
* (otherwise the order may be inconsistent because of the http request round trip)
|
||||
*/
|
||||
queueUpdate(payload: Update): Promise<void>;
|
||||
private fetchUpdate;
|
||||
}
|
||||
|
||||
interface DefineImportMetadata {
|
||||
/**
|
||||
* Imported names before being transformed to `ssrImportKey`
|
||||
*
|
||||
* import foo, { bar as baz, qux } from 'hello'
|
||||
* => ['default', 'bar', 'qux']
|
||||
*
|
||||
* import * as namespace from 'world
|
||||
* => undefined
|
||||
*/
|
||||
importedNames?: string[];
|
||||
}
|
||||
interface SSRImportMetadata extends DefineImportMetadata {
|
||||
isDynamicImport?: boolean;
|
||||
}
|
||||
|
||||
declare const ssrModuleExportsKey = "__vite_ssr_exports__";
|
||||
declare const ssrImportKey = "__vite_ssr_import__";
|
||||
declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
|
||||
declare const ssrExportAllKey = "__vite_ssr_exportAll__";
|
||||
declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
|
||||
|
||||
interface ModuleRunnerDebugger {
|
||||
(formatter: unknown, ...args: unknown[]): void;
|
||||
}
|
||||
declare class ModuleRunner {
|
||||
options: ModuleRunnerOptions;
|
||||
evaluator: ModuleEvaluator;
|
||||
private debug?;
|
||||
evaluatedModules: EvaluatedModules;
|
||||
hmrClient?: HMRClient;
|
||||
private readonly envProxy;
|
||||
private readonly transport;
|
||||
private readonly resetSourceMapSupport?;
|
||||
private readonly concurrentModuleNodePromises;
|
||||
private closed;
|
||||
constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
||||
/**
|
||||
* URL to execute. Accepts file path, server path or id relative to the root.
|
||||
*/
|
||||
import<T = any>(url: string): Promise<T>;
|
||||
/**
|
||||
* Clear all caches including HMR listeners.
|
||||
*/
|
||||
clearCache(): void;
|
||||
/**
|
||||
* Clears all caches, removes all HMR listeners, and resets source map support.
|
||||
* This method doesn't stop the HMR connection.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Returns `true` if the runtime has been closed by calling `close()` method.
|
||||
*/
|
||||
isClosed(): boolean;
|
||||
private processImport;
|
||||
private isCircularModule;
|
||||
private isCircularImport;
|
||||
private cachedRequest;
|
||||
private cachedModule;
|
||||
private getModuleInformation;
|
||||
protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
|
||||
}
|
||||
|
||||
interface RetrieveFileHandler {
|
||||
(path: string): string | null | undefined | false;
|
||||
}
|
||||
interface RetrieveSourceMapHandler {
|
||||
(path: string): null | {
|
||||
url: string;
|
||||
map: any;
|
||||
};
|
||||
}
|
||||
interface InterceptorOptions {
|
||||
retrieveFile?: RetrieveFileHandler;
|
||||
retrieveSourceMap?: RetrieveSourceMapHandler;
|
||||
}
|
||||
|
||||
interface ModuleRunnerImportMeta extends ImportMeta {
|
||||
url: string;
|
||||
env: ImportMetaEnv;
|
||||
hot?: ViteHotContext;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface ModuleRunnerContext {
|
||||
[ssrModuleExportsKey]: Record<string, any>;
|
||||
[ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>;
|
||||
[ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>;
|
||||
[ssrExportAllKey]: (obj: any) => void;
|
||||
[ssrImportMetaKey]: ModuleRunnerImportMeta;
|
||||
}
|
||||
interface ModuleEvaluator {
|
||||
/**
|
||||
* Number of prefixed lines in the transformed code.
|
||||
*/
|
||||
startOffset?: number;
|
||||
/**
|
||||
* Run code that was transformed by Vite.
|
||||
* @param context Function context
|
||||
* @param code Transformed code
|
||||
* @param module The module node
|
||||
*/
|
||||
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
|
||||
/**
|
||||
* Run externalized module.
|
||||
* @param file File URL to the external module
|
||||
*/
|
||||
runExternalModule(file: string): Promise<any>;
|
||||
}
|
||||
type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
|
||||
url: string;
|
||||
id: string;
|
||||
};
|
||||
type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
||||
interface ModuleRunnerHmr {
|
||||
/**
|
||||
* Configure HMR logger.
|
||||
*/
|
||||
logger?: false | HMRLogger;
|
||||
}
|
||||
interface ModuleRunnerOptions {
|
||||
/**
|
||||
* Root of the project
|
||||
* @deprecated not used and to be removed
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* A set of methods to communicate with the server.
|
||||
*/
|
||||
transport: ModuleRunnerTransport;
|
||||
/**
|
||||
* Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
|
||||
* Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
|
||||
* You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite.
|
||||
*/
|
||||
sourcemapInterceptor?: false | 'node' | 'prepareStackTrace' | InterceptorOptions;
|
||||
/**
|
||||
* Disable HMR or configure HMR options.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
hmr?: boolean | ModuleRunnerHmr;
|
||||
/**
|
||||
* Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
|
||||
*/
|
||||
evaluatedModules?: EvaluatedModules;
|
||||
}
|
||||
interface ImportMetaEnv {
|
||||
[key: string]: any;
|
||||
BASE_URL: string;
|
||||
MODE: string;
|
||||
DEV: boolean;
|
||||
PROD: boolean;
|
||||
SSR: boolean;
|
||||
}
|
||||
|
||||
declare class EvaluatedModuleNode {
|
||||
id: string;
|
||||
url: string;
|
||||
importers: Set<string>;
|
||||
imports: Set<string>;
|
||||
evaluated: boolean;
|
||||
meta: ResolvedResult | undefined;
|
||||
promise: Promise<any> | undefined;
|
||||
exports: any | undefined;
|
||||
file: string;
|
||||
map: DecodedMap | undefined;
|
||||
constructor(id: string, url: string);
|
||||
}
|
||||
declare class EvaluatedModules {
|
||||
readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
|
||||
readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
|
||||
readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
|
||||
/**
|
||||
* Returns the module node by the resolved module ID. Usually, module ID is
|
||||
* the file system path with query and/or hash. It can also be a virtual module.
|
||||
*
|
||||
* Module runner graph will have 1 to 1 mapping with the server module graph.
|
||||
* @param id Resolved module ID
|
||||
*/
|
||||
getModuleById(id: string): EvaluatedModuleNode | undefined;
|
||||
/**
|
||||
* Returns all modules related to the file system path. Different modules
|
||||
* might have different query parameters or hash, so it's possible to have
|
||||
* multiple modules for the same file.
|
||||
* @param file The file system path of the module
|
||||
*/
|
||||
getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
|
||||
/**
|
||||
* Returns the module node by the URL that was used in the import statement.
|
||||
* Unlike module graph on the server, the URL is not resolved and is used as is.
|
||||
* @param url Server URL that was used in the import statement
|
||||
*/
|
||||
getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
|
||||
/**
|
||||
* Ensure that module is in the graph. If the module is already in the graph,
|
||||
* it will return the existing module node. Otherwise, it will create a new
|
||||
* module node and add it to the graph.
|
||||
* @param id Resolved module ID
|
||||
* @param url URL that was used in the import statement
|
||||
*/
|
||||
ensureModule(id: string, url: string): EvaluatedModuleNode;
|
||||
invalidateModule(node: EvaluatedModuleNode): void;
|
||||
/**
|
||||
* Extracts the inlined source map from the module code and returns the decoded
|
||||
* source map. If the source map is not inlined, it will return null.
|
||||
* @param id Resolved module ID
|
||||
*/
|
||||
getModuleSourceMapById(id: string): DecodedMap | null;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
declare class ESModulesEvaluator implements ModuleEvaluator {
|
||||
readonly startOffset: number;
|
||||
runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
|
||||
runExternalModule(filepath: string): Promise<any>;
|
||||
}
|
||||
|
||||
export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, FetchFunctionOptions, FetchResult, ModuleRunner, ModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
||||
export type { FetchFunction, HMRLogger, InterceptorOptions, ModuleEvaluator, ModuleRunnerContext, ModuleRunnerHmr, ModuleRunnerImportMeta, ModuleRunnerOptions, ResolvedResult, SSRImportMetadata };
|
||||
+1311
File diff suppressed because it is too large
Load Diff
+87
@@ -0,0 +1,87 @@
|
||||
import { HotPayload } from '../../types/hmrPayload.js';
|
||||
|
||||
interface FetchFunctionOptions {
|
||||
cached?: boolean;
|
||||
startOffset?: number;
|
||||
}
|
||||
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
||||
interface CachedFetchResult {
|
||||
/**
|
||||
* If module cached in the runner, we can just confirm
|
||||
* it wasn't invalidated on the server side.
|
||||
*/
|
||||
cache: true;
|
||||
}
|
||||
interface ExternalFetchResult {
|
||||
/**
|
||||
* The path to the externalized module starting with file://,
|
||||
* by default this will be imported via a dynamic "import"
|
||||
* instead of being transformed by vite and loaded with vite runner
|
||||
*/
|
||||
externalize: string;
|
||||
/**
|
||||
* Type of the module. Will be used to determine if import statement is correct.
|
||||
* For example, if Vite needs to throw an error if variable is not actually exported
|
||||
*/
|
||||
type: 'module' | 'commonjs' | 'builtin' | 'network';
|
||||
}
|
||||
interface ViteFetchResult {
|
||||
/**
|
||||
* Code that will be evaluated by vite runner
|
||||
* by default this will be wrapped in an async function
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* File path of the module on disk.
|
||||
* This will be resolved as import.meta.url/filename
|
||||
* Will be equal to `null` for virtual modules
|
||||
*/
|
||||
file: string | null;
|
||||
/**
|
||||
* Module ID in the server module graph.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Module URL used in the import.
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* Invalidate module on the client side.
|
||||
*/
|
||||
invalidate: boolean;
|
||||
}
|
||||
type InvokeMethods = {
|
||||
fetchModule: (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
||||
};
|
||||
|
||||
type ModuleRunnerTransportHandlers = {
|
||||
onMessage: (data: HotPayload) => void;
|
||||
onDisconnection: () => void;
|
||||
};
|
||||
/**
|
||||
* "send and connect" or "invoke" must be implemented
|
||||
*/
|
||||
interface ModuleRunnerTransport {
|
||||
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void;
|
||||
disconnect?(): Promise<void> | void;
|
||||
send?(data: HotPayload): Promise<void> | void;
|
||||
invoke?(data: HotPayload): Promise<{
|
||||
result: any;
|
||||
} | {
|
||||
error: any;
|
||||
}>;
|
||||
timeout?: number;
|
||||
}
|
||||
interface NormalizedModuleRunnerTransport {
|
||||
connect?(onMessage?: (data: HotPayload) => void): Promise<void> | void;
|
||||
disconnect?(): Promise<void> | void;
|
||||
send(data: HotPayload): Promise<void>;
|
||||
invoke<T extends keyof InvokeMethods>(name: T, data: Parameters<InvokeMethods[T]>): Promise<ReturnType<Awaited<InvokeMethods[T]>>>;
|
||||
}
|
||||
declare const createWebSocketModuleRunnerTransport: (options: {
|
||||
createConnection: () => WebSocket;
|
||||
pingInterval?: number;
|
||||
}) => Required<Pick<ModuleRunnerTransport, "connect" | "disconnect" | "send">>;
|
||||
|
||||
export { createWebSocketModuleRunnerTransport as c };
|
||||
export type { ExternalFetchResult as E, FetchFunctionOptions as F, ModuleRunnerTransport as M, NormalizedModuleRunnerTransport as N, ViteFetchResult as V, FetchResult as a, ModuleRunnerTransportHandlers as b };
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
const description =
|
||||
' See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.'
|
||||
|
||||
warnCjsUsage()
|
||||
|
||||
// type utils
|
||||
module.exports.defineConfig = (config) => config
|
||||
|
||||
// proxy cjs utils (sync functions)
|
||||
Object.assign(module.exports, require('./dist/node-cjs/publicUtils.cjs'))
|
||||
|
||||
// async functions, can be redirect from ESM build
|
||||
const asyncFunctions = [
|
||||
'build',
|
||||
'createServer',
|
||||
'preview',
|
||||
'transformWithEsbuild',
|
||||
'resolveConfig',
|
||||
'optimizeDeps',
|
||||
'formatPostcssSourceMap',
|
||||
'loadConfigFromFile',
|
||||
'preprocessCSS',
|
||||
'createBuilder',
|
||||
'runnerImport',
|
||||
]
|
||||
asyncFunctions.forEach((name) => {
|
||||
module.exports[name] = (...args) =>
|
||||
import('./dist/node/index.js').then((i) => i[name](...args))
|
||||
})
|
||||
|
||||
// variables and sync functions that cannot be used from cjs build
|
||||
const disallowedVariables = [
|
||||
// was not exposed in cjs from the beginning
|
||||
'parseAst',
|
||||
'parseAstAsync',
|
||||
'buildErrorMessage',
|
||||
'sortUserPlugins',
|
||||
// Environment API related variables that are too big to include in the cjs build
|
||||
'DevEnvironment',
|
||||
'BuildEnvironment',
|
||||
'createIdResolver',
|
||||
'createRunnableDevEnvironment',
|
||||
// can be redirected from ESM, but doesn't make sense as it's Environment API related
|
||||
'fetchModule',
|
||||
'moduleRunnerTransform',
|
||||
// can be exposed, but doesn't make sense as it's Environment API related
|
||||
'createServerHotChannel',
|
||||
'createServerModuleRunner',
|
||||
'createServerModuleRunnerTransport',
|
||||
'isRunnableDevEnvironment',
|
||||
'createFetchableDevEnvironment',
|
||||
'isFetchableDevEnvironment',
|
||||
]
|
||||
disallowedVariables.forEach((name) => {
|
||||
Object.defineProperty(module.exports, name, {
|
||||
get() {
|
||||
throw new Error(
|
||||
`${name} is not available in the CJS build of Vite.` + description,
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
function warnCjsUsage() {
|
||||
if (process.env.VITE_CJS_IGNORE_WARNING) return
|
||||
const logLevelIndex = process.argv.findIndex((arg) =>
|
||||
/^(?:-l|--logLevel)/.test(arg),
|
||||
)
|
||||
if (logLevelIndex > 0) {
|
||||
const logLevelValue = process.argv[logLevelIndex + 1]
|
||||
if (logLevelValue === 'silent' || logLevelValue === 'error') {
|
||||
return
|
||||
}
|
||||
if (/silent|error/.test(process.argv[logLevelIndex])) {
|
||||
return
|
||||
}
|
||||
}
|
||||
const yellow = (str) => `\u001b[33m${str}\u001b[39m`
|
||||
console.warn(
|
||||
yellow("The CJS build of Vite's Node API is deprecated." + description),
|
||||
)
|
||||
if (process.env.VITE_CJS_TRACE) {
|
||||
const e = {}
|
||||
const stackTraceLimit = Error.stackTraceLimit
|
||||
Error.stackTraceLimit = 100
|
||||
Error.captureStackTrace(e)
|
||||
Error.stackTraceLimit = stackTraceLimit
|
||||
console.log(
|
||||
e.stack
|
||||
.split('\n')
|
||||
.slice(1)
|
||||
.filter((line) => !line.includes('(node:'))
|
||||
.join('\n'),
|
||||
)
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @deprecated The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
|
||||
*/
|
||||
declare const module: any
|
||||
|
||||
export = module
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default false
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default true
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"name": "vite",
|
||||
"version": "6.4.1",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
"description": "Native-ESM powered web dev build tool",
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"keywords": [
|
||||
"frontend",
|
||||
"framework",
|
||||
"hmr",
|
||||
"dev-server",
|
||||
"build-tool",
|
||||
"vite"
|
||||
],
|
||||
"main": "./dist/node/index.js",
|
||||
"types": "./dist/node/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module-sync": "./dist/node/index.js",
|
||||
"import": "./dist/node/index.js",
|
||||
"require": "./index.cjs"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./client.d.ts"
|
||||
},
|
||||
"./module-runner": "./dist/node/module-runner.js",
|
||||
"./dist/client/*": "./dist/client/*",
|
||||
"./types/*": {
|
||||
"types": "./types/*"
|
||||
},
|
||||
"./types/internal/*": null,
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"module-runner": [
|
||||
"dist/node/module-runner.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"imports": {
|
||||
"#module-sync-enabled": {
|
||||
"module-sync": "./misc/true.js",
|
||||
"default": "./misc/false.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist",
|
||||
"misc/**/*.js",
|
||||
"client.d.ts",
|
||||
"index.cjs",
|
||||
"index.d.cts",
|
||||
"types"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitejs/vite.git",
|
||||
"directory": "packages/vite"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitejs/vite/issues"
|
||||
},
|
||||
"homepage": "https://vite.dev",
|
||||
"funding": "https://github.com/vitejs/vite?sponsor=1",
|
||||
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup": "^4.34.9",
|
||||
"tinyglobby": "^0.2.13"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ampproject/remapping": "^2.3.0",
|
||||
"@babel/parser": "^7.27.0",
|
||||
"@jridgewell/trace-mapping": "^0.3.25",
|
||||
"@polka/compression": "^1.0.0-next.25",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.3",
|
||||
"@rollup/plugin-dynamic-import-vars": "2.1.4",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "16.0.1",
|
||||
"@rollup/pluginutils": "^5.1.4",
|
||||
"@types/escape-html": "^1.0.4",
|
||||
"@types/pnpapi": "^0.0.5",
|
||||
"artichokie": "^0.3.1",
|
||||
"cac": "^6.7.14",
|
||||
"chokidar": "^3.6.0",
|
||||
"connect": "^3.7.0",
|
||||
"convert-source-map": "^2.0.0",
|
||||
"cors": "^2.8.5",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"debug": "^4.4.0",
|
||||
"dep-types": "link:./src/types",
|
||||
"dotenv": "^16.5.0",
|
||||
"dotenv-expand": "^12.0.2",
|
||||
"es-module-lexer": "^1.6.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"estree-walker": "^3.0.3",
|
||||
"etag": "^1.8.1",
|
||||
"http-proxy": "^1.18.1",
|
||||
"launch-editor-middleware": "^2.10.0",
|
||||
"lightningcss": "^1.29.3",
|
||||
"magic-string": "^0.30.17",
|
||||
"mlly": "^1.7.4",
|
||||
"mrmime": "^2.0.1",
|
||||
"nanoid": "^5.1.5",
|
||||
"open": "^10.1.1",
|
||||
"parse5": "^7.2.1",
|
||||
"pathe": "^2.0.3",
|
||||
"periscopic": "^4.0.2",
|
||||
"picocolors": "^1.1.1",
|
||||
"postcss-import": "^16.1.0",
|
||||
"postcss-load-config": "^6.0.1",
|
||||
"postcss-modules": "^6.0.1",
|
||||
"resolve.exports": "^2.0.3",
|
||||
"rollup-plugin-dts": "^6.2.1",
|
||||
"rollup-plugin-esbuild": "^6.2.1",
|
||||
"rollup-plugin-license": "^3.6.0",
|
||||
"sass": "^1.86.3",
|
||||
"sass-embedded": "^1.86.3",
|
||||
"sirv": "^3.0.2",
|
||||
"source-map-support": "^0.5.21",
|
||||
"strip-literal": "^3.0.0",
|
||||
"terser": "^5.39.0",
|
||||
"tsconfck": "^3.1.5",
|
||||
"tslib": "^2.8.1",
|
||||
"types": "link:./types",
|
||||
"ufo": "^1.6.1",
|
||||
"ws": "^8.18.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"less": "*",
|
||||
"lightningcss": "^1.21.0",
|
||||
"sass": "*",
|
||||
"sass-embedded": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.16.0",
|
||||
"tsx": "^4.8.1",
|
||||
"yaml": "^2.4.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"jiti": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"sass-embedded": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"lightningcss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
},
|
||||
"tsx": {
|
||||
"optional": true
|
||||
},
|
||||
"yaml": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx scripts/dev.ts",
|
||||
"build": "premove dist && pnpm build-bundle && pnpm build-types",
|
||||
"build-bundle": "rollup --config rollup.config.ts --configPlugin esbuild",
|
||||
"build-types": "pnpm build-types-temp && pnpm build-types-roll && pnpm build-types-check",
|
||||
"build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node/tsconfig.build.json",
|
||||
"build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin esbuild && premove temp",
|
||||
"build-types-check": "tsc --project tsconfig.check.json",
|
||||
"typecheck": "tsc --noEmit && tsc --noEmit -p src/node",
|
||||
"lint": "eslint --cache --ext .ts src/**",
|
||||
"format": "prettier --write --cache --parser typescript \"src/**/*.ts\""
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import type {
|
||||
ErrorPayload,
|
||||
FullReloadPayload,
|
||||
PrunePayload,
|
||||
UpdatePayload,
|
||||
} from './hmrPayload'
|
||||
|
||||
export interface CustomEventMap {
|
||||
'vite:beforeUpdate': UpdatePayload
|
||||
'vite:afterUpdate': UpdatePayload
|
||||
'vite:beforePrune': PrunePayload
|
||||
'vite:beforeFullReload': FullReloadPayload
|
||||
'vite:error': ErrorPayload
|
||||
'vite:invalidate': InvalidatePayload
|
||||
'vite:ws:connect': WebSocketConnectionPayload
|
||||
'vite:ws:disconnect': WebSocketConnectionPayload
|
||||
}
|
||||
|
||||
export interface WebSocketConnectionPayload {
|
||||
/**
|
||||
* @experimental
|
||||
* We expose this instance experimentally to see potential usage.
|
||||
* This might be removed in the future if we didn't find reasonable use cases.
|
||||
* If you find this useful, please open an issue with details so we can discuss and make it stable API.
|
||||
*/
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
webSocket: WebSocket
|
||||
}
|
||||
|
||||
export interface InvalidatePayload {
|
||||
path: string
|
||||
message: string | undefined
|
||||
firstInvalidatedBy: string
|
||||
}
|
||||
|
||||
/**
|
||||
* provides types for payloads of built-in Vite events
|
||||
*/
|
||||
export type InferCustomEventPayload<T extends string> =
|
||||
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
||||
|
||||
/**
|
||||
* provides types for names of built-in Vite events
|
||||
*/
|
||||
export type CustomEventName = keyof CustomEventMap | (string & {})
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/** @deprecated use HotPayload */
|
||||
export type HMRPayload = HotPayload
|
||||
export type HotPayload =
|
||||
| ConnectedPayload
|
||||
| PingPayload
|
||||
| UpdatePayload
|
||||
| FullReloadPayload
|
||||
| CustomPayload
|
||||
| ErrorPayload
|
||||
| PrunePayload
|
||||
|
||||
export interface ConnectedPayload {
|
||||
type: 'connected'
|
||||
}
|
||||
|
||||
export interface PingPayload {
|
||||
type: 'ping'
|
||||
}
|
||||
|
||||
export interface UpdatePayload {
|
||||
type: 'update'
|
||||
updates: Update[]
|
||||
}
|
||||
|
||||
export interface Update {
|
||||
type: 'js-update' | 'css-update'
|
||||
path: string
|
||||
acceptedPath: string
|
||||
timestamp: number
|
||||
/** @internal */
|
||||
explicitImportRequired?: boolean
|
||||
/** @internal */
|
||||
isWithinCircularImport?: boolean
|
||||
/** @internal */
|
||||
firstInvalidatedBy?: string
|
||||
/** @internal */
|
||||
invalidates?: string[]
|
||||
}
|
||||
|
||||
export interface PrunePayload {
|
||||
type: 'prune'
|
||||
paths: string[]
|
||||
}
|
||||
|
||||
export interface FullReloadPayload {
|
||||
type: 'full-reload'
|
||||
path?: string
|
||||
/** @internal */
|
||||
triggeredBy?: string
|
||||
}
|
||||
|
||||
export interface CustomPayload {
|
||||
type: 'custom'
|
||||
event: string
|
||||
data?: any
|
||||
}
|
||||
|
||||
export interface ErrorPayload {
|
||||
type: 'error'
|
||||
err: {
|
||||
[name: string]: any
|
||||
message: string
|
||||
stack: string
|
||||
id?: string
|
||||
frame?: string
|
||||
plugin?: string
|
||||
pluginCode?: string
|
||||
loc?: {
|
||||
file?: string
|
||||
line: number
|
||||
column: number
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import type { CustomEventName, InferCustomEventPayload } from './customEvent'
|
||||
|
||||
export type ModuleNamespace = Record<string, any> & {
|
||||
[Symbol.toStringTag]: 'Module'
|
||||
}
|
||||
|
||||
export interface ViteHotContext {
|
||||
readonly data: any
|
||||
|
||||
accept(): void
|
||||
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
||||
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
||||
accept(
|
||||
deps: readonly string[],
|
||||
cb: (mods: Array<ModuleNamespace | undefined>) => void,
|
||||
): void
|
||||
|
||||
acceptExports(
|
||||
exportNames: string | readonly string[],
|
||||
cb?: (mod: ModuleNamespace | undefined) => void,
|
||||
): void
|
||||
|
||||
dispose(cb: (data: any) => void): void
|
||||
prune(cb: (data: any) => void): void
|
||||
invalidate(message?: string): void
|
||||
|
||||
on<T extends CustomEventName>(
|
||||
event: T,
|
||||
cb: (payload: InferCustomEventPayload<T>) => void,
|
||||
): void
|
||||
off<T extends CustomEventName>(
|
||||
event: T,
|
||||
cb: (payload: InferCustomEventPayload<T>) => void,
|
||||
): void
|
||||
send<T extends CustomEventName>(
|
||||
event: T,
|
||||
data?: InferCustomEventPayload<T>,
|
||||
): void
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference path="./importMeta.d.ts" />
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/45096
|
||||
// TypeScript has a bug that makes <reference types="vite/types/importMeta" />
|
||||
// not possible in userland. This file provides a workaround for now.
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
export interface ImportGlobOptions<
|
||||
Eager extends boolean,
|
||||
AsType extends string,
|
||||
> {
|
||||
/**
|
||||
* Import type for the import url.
|
||||
*
|
||||
* @deprecated Use `query` instead, e.g. `as: 'url'` -> `query: '?url', import: 'default'`
|
||||
*/
|
||||
as?: AsType
|
||||
/**
|
||||
* Import as static or dynamic
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
eager?: Eager
|
||||
/**
|
||||
* Import only the specific named export. Set to `default` to import the default export.
|
||||
*/
|
||||
import?: string
|
||||
/**
|
||||
* Custom queries
|
||||
*/
|
||||
query?: string | Record<string, string | number | boolean>
|
||||
/**
|
||||
* Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
exhaustive?: boolean
|
||||
}
|
||||
|
||||
export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
|
||||
|
||||
export interface KnownAsTypeMap {
|
||||
raw: string
|
||||
url: string
|
||||
worker: Worker
|
||||
}
|
||||
|
||||
export interface ImportGlobFunction {
|
||||
/**
|
||||
* Import a list of files with a glob pattern.
|
||||
*
|
||||
* Overload 1: No generic provided, infer the type from `eager` and `as`
|
||||
*/
|
||||
<
|
||||
Eager extends boolean,
|
||||
As extends string,
|
||||
T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown,
|
||||
>(
|
||||
glob: string | string[],
|
||||
options?: ImportGlobOptions<Eager, As>,
|
||||
): (Eager extends true ? true : false) extends true
|
||||
? Record<string, T>
|
||||
: Record<string, () => Promise<T>>
|
||||
/**
|
||||
* Import a list of files with a glob pattern.
|
||||
*
|
||||
* Overload 2: Module generic provided, infer the type from `eager: false`
|
||||
*/
|
||||
<M>(
|
||||
glob: string | string[],
|
||||
options?: ImportGlobOptions<false, string>,
|
||||
): Record<string, () => Promise<M>>
|
||||
/**
|
||||
* Import a list of files with a glob pattern.
|
||||
*
|
||||
* Overload 3: Module generic provided, infer the type from `eager: true`
|
||||
*/
|
||||
<M>(
|
||||
glob: string | string[],
|
||||
options: ImportGlobOptions<true, string>,
|
||||
): Record<string, M>
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// This file is an augmentation to the built-in ImportMeta interface
|
||||
// Thus cannot contain any top-level imports
|
||||
// <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
|
||||
|
||||
// This is tested in `packages/vite/src/node/__tests_dts__/typeOptions.ts`
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- to allow extending by users
|
||||
interface ViteTypeOptions {
|
||||
// strictImportMetaEnv: unknown
|
||||
}
|
||||
|
||||
type ImportMetaEnvFallbackKey =
|
||||
'strictImportMetaEnv' extends keyof ViteTypeOptions ? never : string
|
||||
|
||||
interface ImportMetaEnv {
|
||||
[key: ImportMetaEnvFallbackKey]: any
|
||||
BASE_URL: string
|
||||
MODE: string
|
||||
DEV: boolean
|
||||
PROD: boolean
|
||||
SSR: boolean
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
url: string
|
||||
|
||||
readonly hot?: import('./hot').ViteHotContext
|
||||
|
||||
readonly env: ImportMetaEnv
|
||||
|
||||
glob: import('./importGlob').ImportGlobFunction
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
// @ts-ignore `sass` may not be installed
|
||||
import type DartSass from 'sass'
|
||||
// @ts-ignore `sass-embedded` may not be installed
|
||||
import type SassEmbedded from 'sass-embedded'
|
||||
// @ts-ignore `less` may not be installed
|
||||
import type Less from 'less'
|
||||
// @ts-ignore `stylus` may not be installed
|
||||
import type Stylus from 'stylus'
|
||||
|
||||
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
// https://github.com/type-challenges/type-challenges/issues/29285
|
||||
type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false
|
||||
|
||||
type DartSassLegacyStringOptionsAsync = DartSass.LegacyStringOptions<'async'>
|
||||
type SassEmbeddedLegacyStringOptionsAsync =
|
||||
SassEmbedded.LegacyStringOptions<'async'>
|
||||
type SassLegacyStringOptionsAsync =
|
||||
IsAny<DartSassLegacyStringOptionsAsync> extends false
|
||||
? DartSassLegacyStringOptionsAsync
|
||||
: SassEmbeddedLegacyStringOptionsAsync
|
||||
|
||||
export type SassLegacyPreprocessBaseOptions = Omit<
|
||||
SassLegacyStringOptionsAsync,
|
||||
| 'data'
|
||||
| 'file'
|
||||
| 'outFile'
|
||||
| 'sourceMap'
|
||||
| 'omitSourceMapUrl'
|
||||
| 'sourceMapEmbed'
|
||||
| 'sourceMapRoot'
|
||||
>
|
||||
|
||||
type DartSassStringOptionsAsync = DartSass.StringOptions<'async'>
|
||||
type SassEmbeddedStringOptionsAsync = SassEmbedded.StringOptions<'async'>
|
||||
type SassStringOptionsAsync =
|
||||
IsAny<DartSassStringOptionsAsync> extends false
|
||||
? DartSassStringOptionsAsync
|
||||
: SassEmbeddedStringOptionsAsync
|
||||
|
||||
export type SassModernPreprocessBaseOptions = Omit<
|
||||
SassStringOptionsAsync,
|
||||
'url' | 'sourceMap'
|
||||
>
|
||||
|
||||
export type LessPreprocessorBaseOptions = Omit<
|
||||
Less.Options,
|
||||
'sourceMap' | 'filename'
|
||||
>
|
||||
|
||||
export type StylusPreprocessorBaseOptions = Omit<
|
||||
Stylus.RenderOptions,
|
||||
'filename'
|
||||
> & { define?: Record<string, any> }
|
||||
|
||||
declare global {
|
||||
// LESS' types somewhat references this which doesn't make sense in Node,
|
||||
// so we have to shim it
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
interface HTMLLinkElement {}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
// @ts-ignore `lightningcss` may not be installed
|
||||
import type Lightningcss from 'lightningcss'
|
||||
|
||||
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
export type LightningCSSOptions = Omit<
|
||||
Lightningcss.BundleAsyncOptions<Lightningcss.CustomAtRules>,
|
||||
| 'filename'
|
||||
| 'resolver'
|
||||
| 'minify'
|
||||
| 'sourceMap'
|
||||
| 'analyzeDependencies'
|
||||
// properties not overridden by Vite, but does not make sense to set by end users
|
||||
| 'inputSourceMap'
|
||||
| 'projectRoot'
|
||||
>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
export interface ChunkMetadata {
|
||||
importedAssets: Set<string>
|
||||
importedCss: Set<string>
|
||||
}
|
||||
|
||||
export interface CustomPluginOptionsVite {
|
||||
/**
|
||||
* If this is a CSS Rollup module, you can scope to its importer's exports
|
||||
* so that if those exports are treeshaken away, the CSS module will also
|
||||
* be treeshaken.
|
||||
*
|
||||
* The "importerId" must import the CSS Rollup module statically.
|
||||
*
|
||||
* Example config if the CSS id is `/src/App.vue?vue&type=style&lang.css`:
|
||||
* ```js
|
||||
* cssScopeTo: ['/src/App.vue', 'default']
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
cssScopeTo?: readonly [importerId: string, exportName: string | undefined]
|
||||
|
||||
/** @deprecated no-op since Vite 6.1 */
|
||||
lang?: string
|
||||
}
|
||||
|
||||
declare module 'rollup' {
|
||||
export interface RenderedChunk {
|
||||
viteMetadata?: ChunkMetadata
|
||||
}
|
||||
|
||||
export interface CustomPluginOptions {
|
||||
vite?: CustomPluginOptionsVite
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"//": "this file is here to make typescript happy when moduleResolution=node16+",
|
||||
"version": "0.0.0"
|
||||
}
|
||||
Reference in New Issue
Block a user