vite 6.0.11 → 6.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ import { HotPayload } from '../../types/hmrPayload.js';
2
+
3
+ interface FetchFunctionOptions {
4
+ cached?: boolean;
5
+ startOffset?: number;
6
+ }
7
+ type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
8
+ interface CachedFetchResult {
9
+ /**
10
+ * If module cached in the runner, we can just confirm
11
+ * it wasn't invalidated on the server side.
12
+ */
13
+ cache: true;
14
+ }
15
+ interface ExternalFetchResult {
16
+ /**
17
+ * The path to the externalized module starting with file://,
18
+ * by default this will be imported via a dynamic "import"
19
+ * instead of being transformed by vite and loaded with vite runner
20
+ */
21
+ externalize: string;
22
+ /**
23
+ * Type of the module. Will be used to determine if import statement is correct.
24
+ * For example, if Vite needs to throw an error if variable is not actually exported
25
+ */
26
+ type: 'module' | 'commonjs' | 'builtin' | 'network';
27
+ }
28
+ interface ViteFetchResult {
29
+ /**
30
+ * Code that will be evaluated by vite runner
31
+ * by default this will be wrapped in an async function
32
+ */
33
+ code: string;
34
+ /**
35
+ * File path of the module on disk.
36
+ * This will be resolved as import.meta.url/filename
37
+ * Will be equal to `null` for virtual modules
38
+ */
39
+ file: string | null;
40
+ /**
41
+ * Module ID in the server module graph.
42
+ */
43
+ id: string;
44
+ /**
45
+ * Module URL used in the import.
46
+ */
47
+ url: string;
48
+ /**
49
+ * Invalidate module on the client side.
50
+ */
51
+ invalidate: boolean;
52
+ }
53
+ type InvokeMethods = {
54
+ fetchModule: (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
55
+ };
56
+
57
+ type ModuleRunnerTransportHandlers = {
58
+ onMessage: (data: HotPayload) => void;
59
+ onDisconnection: () => void;
60
+ };
61
+ /**
62
+ * "send and connect" or "invoke" must be implemented
63
+ */
64
+ interface ModuleRunnerTransport {
65
+ connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void;
66
+ disconnect?(): Promise<void> | void;
67
+ send?(data: HotPayload): Promise<void> | void;
68
+ invoke?(data: HotPayload): Promise<{
69
+ result: any;
70
+ } | {
71
+ error: any;
72
+ }>;
73
+ timeout?: number;
74
+ }
75
+ interface NormalizedModuleRunnerTransport {
76
+ connect?(onMessage?: (data: HotPayload) => void): Promise<void> | void;
77
+ disconnect?(): Promise<void> | void;
78
+ send(data: HotPayload): Promise<void>;
79
+ invoke<T extends keyof InvokeMethods>(name: T, data: Parameters<InvokeMethods[T]>): Promise<ReturnType<Awaited<InvokeMethods[T]>>>;
80
+ }
81
+ declare const createWebSocketModuleRunnerTransport: (options: {
82
+ createConnection: () => WebSocket;
83
+ pingInterval?: number;
84
+ }) => Required<Pick<ModuleRunnerTransport, "connect" | "disconnect" | "send">>;
85
+
86
+ export { type ExternalFetchResult as E, type FetchFunctionOptions as F, type ModuleRunnerTransport as M, type NormalizedModuleRunnerTransport as N, type ViteFetchResult as V, type FetchResult as a, type ModuleRunnerTransportHandlers as b, createWebSocketModuleRunnerTransport as c };
@@ -47,6 +47,7 @@ const VITE_PACKAGE_DIR = path$1.resolve(
47
47
  const CLIENT_ENTRY = path$1.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
48
48
  path$1.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
49
49
  path$1.dirname(CLIENT_ENTRY);
50
+ const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
50
51
 
51
52
  const comma = ','.charCodeAt(0);
52
53
  const semicolon = ';'.charCodeAt(0);
@@ -6408,6 +6409,7 @@ function resolveEnvPrefix({
6408
6409
  exports.esbuildVersion = esbuild.version;
6409
6410
  exports.createFilter = createFilter;
6410
6411
  exports.createLogger = createLogger;
6412
+ exports.defaultAllowedOrigins = defaultAllowedOrigins;
6411
6413
  exports.defaultClientConditions = DEFAULT_CLIENT_CONDITIONS;
6412
6414
  exports.defaultClientMainFields = DEFAULT_CLIENT_MAIN_FIELDS;
6413
6415
  exports.defaultServerConditions = DEFAULT_SERVER_CONDITIONS;
package/index.cjs CHANGED
@@ -21,6 +21,7 @@ const asyncFunctions = [
21
21
  'loadConfigFromFile',
22
22
  'preprocessCSS',
23
23
  'createBuilder',
24
+ 'runnerImport',
24
25
  ]
25
26
  asyncFunctions.forEach((name) => {
26
27
  module.exports[name] = (...args) =>
@@ -45,6 +46,7 @@ const disallowedVariables = [
45
46
  // can be exposed, but doesn't make sense as it's Environment API related
46
47
  'createServerHotChannel',
47
48
  'createServerModuleRunner',
49
+ 'createServerModuleRunnerTransport',
48
50
  'isRunnableDevEnvironment',
49
51
  ]
50
52
  disallowedVariables.forEach((name) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.11",
3
+ "version": "6.1.0-beta.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,15 +73,15 @@
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
75
  "esbuild": "^0.24.2",
76
- "postcss": "^8.4.49",
77
- "rollup": "^4.23.0"
76
+ "postcss": "^8.5.1",
77
+ "rollup": "^4.30.1"
78
78
  },
79
79
  "optionalDependencies": {
80
80
  "fsevents": "~2.3.3"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.26.3",
84
+ "@babel/parser": "^7.26.5",
85
85
  "@jridgewell/trace-mapping": "^0.3.25",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
87
  "@rollup/plugin-alias": "^5.1.1",
@@ -109,14 +109,14 @@
109
109
  "etag": "^1.8.1",
110
110
  "http-proxy": "^1.18.1",
111
111
  "launch-editor-middleware": "^2.9.1",
112
- "lightningcss": "^1.28.2",
112
+ "lightningcss": "^1.29.1",
113
113
  "magic-string": "^0.30.17",
114
- "mlly": "^1.7.3",
114
+ "mlly": "^1.7.4",
115
115
  "mrmime": "^2.0.0",
116
116
  "nanoid": "^5.0.9",
117
117
  "open": "^10.1.0",
118
118
  "parse5": "^7.2.1",
119
- "pathe": "^2.0.0",
119
+ "pathe": "^2.0.1",
120
120
  "periscopic": "^4.0.2",
121
121
  "picocolors": "^1.1.1",
122
122
  "picomatch": "^4.0.2",
@@ -127,11 +127,11 @@
127
127
  "rollup-plugin-dts": "^6.1.1",
128
128
  "rollup-plugin-esbuild": "^6.1.1",
129
129
  "rollup-plugin-license": "^3.5.3",
130
- "sass": "^1.83.1",
131
- "sass-embedded": "^1.83.1",
130
+ "sass": "^1.83.4",
131
+ "sass-embedded": "^1.83.4",
132
132
  "sirv": "^3.0.0",
133
133
  "source-map-support": "^0.5.21",
134
- "strip-literal": "^2.1.1",
134
+ "strip-literal": "^3.0.0",
135
135
  "terser": "^5.37.0",
136
136
  "tinyglobby": "^0.2.10",
137
137
  "tsconfck": "^3.1.4",