vite 6.0.0-alpha.18 → 6.0.0-alpha.19

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.
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-DXWVQosX.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-DXWVQosX.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BWEMV5Th.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BWEMV5Th.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
@@ -13,13 +13,15 @@ import 'node:module';
13
13
  import 'tty';
14
14
  import 'path';
15
15
  import 'fs';
16
- import 'events';
17
- import 'assert';
16
+ import 'node:events';
17
+ import 'node:stream';
18
+ import 'node:string_decoder';
18
19
  import 'node:child_process';
19
20
  import 'node:http';
20
21
  import 'node:https';
21
22
  import 'util';
22
23
  import 'net';
24
+ import 'events';
23
25
  import 'url';
24
26
  import 'http';
25
27
  import 'stream';
@@ -33,7 +35,6 @@ import 'module';
33
35
  import 'node:assert';
34
36
  import 'node:v8';
35
37
  import 'node:worker_threads';
36
- import 'node:events';
37
38
  import 'crypto';
38
39
  import 'querystring';
39
40
  import 'node:buffer';
@@ -42,161 +43,142 @@ import 'zlib';
42
43
  import 'buffer';
43
44
  import 'https';
44
45
  import 'tls';
46
+ import 'assert';
45
47
  import 'node:zlib';
46
48
 
47
- // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
48
- // copy from constants.ts
49
- const CSS_LANGS_RE =
50
- // eslint-disable-next-line regexp/no-unused-capturing-group
51
- /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
49
+ const CSS_LANGS_RE = (
50
+ // eslint-disable-next-line regexp/no-unused-capturing-group
51
+ /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
52
+ );
52
53
  const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
53
- // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
54
- // We don't recommend using this strategy as a general solution moving forward
55
- // splitVendorChunk is a simple index/vendor strategy that was used in Vite
56
- // until v2.8. It is exposed to let people continue to use it in case it was
57
- // working well for their setups.
58
- // The cache needs to be reset on buildStart for watch mode to work correctly
59
- // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
60
- /**
61
- * @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
62
- */
63
54
  class SplitVendorChunkCache {
64
- cache;
65
- constructor() {
66
- this.cache = new Map();
67
- }
68
- reset() {
69
- this.cache = new Map();
70
- }
55
+ cache;
56
+ constructor() {
57
+ this.cache = /* @__PURE__ */ new Map();
58
+ }
59
+ reset() {
60
+ this.cache = /* @__PURE__ */ new Map();
61
+ }
71
62
  }
72
- /**
73
- * @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
74
- */
75
63
  function splitVendorChunk(options = {}) {
76
- const cache = options.cache ?? new SplitVendorChunkCache();
77
- return (id, { getModuleInfo }) => {
78
- if (isInNodeModules(id) &&
79
- !isCSSRequest(id) &&
80
- staticImportedByEntry(id, getModuleInfo, cache.cache)) {
81
- return 'vendor';
82
- }
83
- };
64
+ const cache = options.cache ?? new SplitVendorChunkCache();
65
+ return (id, { getModuleInfo }) => {
66
+ if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
67
+ return "vendor";
68
+ }
69
+ };
84
70
  }
85
71
  function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
86
- if (cache.has(id)) {
87
- return cache.get(id);
88
- }
89
- if (importStack.includes(id)) {
90
- // circular deps!
91
- cache.set(id, false);
92
- return false;
93
- }
94
- const mod = getModuleInfo(id);
95
- if (!mod) {
96
- cache.set(id, false);
97
- return false;
98
- }
99
- if (mod.isEntry) {
100
- cache.set(id, true);
101
- return true;
102
- }
103
- const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
104
- cache.set(id, someImporterIs);
105
- return someImporterIs;
72
+ if (cache.has(id)) {
73
+ return cache.get(id);
74
+ }
75
+ if (importStack.includes(id)) {
76
+ cache.set(id, false);
77
+ return false;
78
+ }
79
+ const mod = getModuleInfo(id);
80
+ if (!mod) {
81
+ cache.set(id, false);
82
+ return false;
83
+ }
84
+ if (mod.isEntry) {
85
+ cache.set(id, true);
86
+ return true;
87
+ }
88
+ const someImporterIs = mod.importers.some(
89
+ (importer) => staticImportedByEntry(
90
+ importer,
91
+ getModuleInfo,
92
+ cache,
93
+ importStack.concat(id)
94
+ )
95
+ );
96
+ cache.set(id, someImporterIs);
97
+ return someImporterIs;
106
98
  }
107
- /**
108
- * @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
109
- */
110
99
  function splitVendorChunkPlugin() {
111
- const caches = [];
112
- function createSplitVendorChunk(output, config) {
113
- const cache = new SplitVendorChunkCache();
114
- caches.push(cache);
115
- const build = config.build ?? {};
116
- const format = output?.format;
117
- if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
118
- return splitVendorChunk({ cache });
119
- }
100
+ const caches = [];
101
+ function createSplitVendorChunk(output, config) {
102
+ const cache = new SplitVendorChunkCache();
103
+ caches.push(cache);
104
+ const build = config.build ?? {};
105
+ const format = output?.format;
106
+ if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
107
+ return splitVendorChunk({ cache });
120
108
  }
121
- return {
122
- name: 'vite:split-vendor-chunk',
123
- config(config) {
124
- let outputs = config?.build?.rollupOptions?.output;
125
- if (outputs) {
126
- outputs = arraify(outputs);
127
- for (const output of outputs) {
128
- const viteManualChunks = createSplitVendorChunk(output, config);
129
- if (viteManualChunks) {
130
- if (output.manualChunks) {
131
- if (typeof output.manualChunks === 'function') {
132
- const userManualChunks = output.manualChunks;
133
- output.manualChunks = (id, api) => {
134
- return userManualChunks(id, api) ?? viteManualChunks(id, api);
135
- };
136
- }
137
- else {
138
- // else, leave the object form of manualChunks untouched, as
139
- // we can't safely replicate rollup handling.
140
- // eslint-disable-next-line no-console
141
- 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.");
142
- }
143
- }
144
- else {
145
- output.manualChunks = viteManualChunks;
146
- }
147
- }
148
- }
149
- }
150
- else {
151
- return {
152
- build: {
153
- rollupOptions: {
154
- output: {
155
- manualChunks: createSplitVendorChunk({}, config),
156
- },
157
- },
158
- },
109
+ }
110
+ return {
111
+ name: "vite:split-vendor-chunk",
112
+ config(config) {
113
+ let outputs = config?.build?.rollupOptions?.output;
114
+ if (outputs) {
115
+ outputs = arraify(outputs);
116
+ for (const output of outputs) {
117
+ const viteManualChunks = createSplitVendorChunk(output, config);
118
+ if (viteManualChunks) {
119
+ if (output.manualChunks) {
120
+ if (typeof output.manualChunks === "function") {
121
+ const userManualChunks = output.manualChunks;
122
+ output.manualChunks = (id, api) => {
123
+ return userManualChunks(id, api) ?? viteManualChunks(id, api);
159
124
  };
125
+ } else {
126
+ console.warn(
127
+ "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
128
+ );
129
+ }
130
+ } else {
131
+ output.manualChunks = viteManualChunks;
132
+ }
133
+ }
134
+ }
135
+ } else {
136
+ return {
137
+ build: {
138
+ rollupOptions: {
139
+ output: {
140
+ manualChunks: createSplitVendorChunk({}, config)
141
+ }
160
142
  }
161
- },
162
- buildStart() {
163
- caches.forEach((cache) => cache.reset());
164
- },
165
- };
143
+ }
144
+ };
145
+ }
146
+ },
147
+ buildStart() {
148
+ caches.forEach((cache) => cache.reset());
149
+ }
150
+ };
166
151
  }
167
152
 
168
153
  class RemoteEnvironmentTransport {
169
- options;
170
- constructor(options) {
171
- this.options = options;
172
- }
173
- register(environment) {
174
- this.options.onMessage(async (data) => {
175
- if (typeof data !== 'object' || !data || !data.__v)
176
- return;
177
- const method = data.m;
178
- const parameters = data.a;
179
- try {
180
- const result = await environment[method](...parameters);
181
- this.options.send({
182
- __v: true,
183
- r: result,
184
- i: data.i,
185
- });
186
- }
187
- catch (error) {
188
- this.options.send({
189
- __v: true,
190
- e: {
191
- name: error.name,
192
- message: error.message,
193
- stack: error.stack,
194
- },
195
- i: data.i,
196
- });
197
- }
154
+ constructor(options) {
155
+ this.options = options;
156
+ }
157
+ register(environment) {
158
+ this.options.onMessage(async (data) => {
159
+ if (typeof data !== "object" || !data || !data.__v) return;
160
+ const method = data.m;
161
+ const parameters = data.a;
162
+ try {
163
+ const result = await environment[method](...parameters);
164
+ this.options.send({
165
+ __v: true,
166
+ r: result,
167
+ i: data.i
198
168
  });
199
- }
169
+ } catch (error) {
170
+ this.options.send({
171
+ __v: true,
172
+ e: {
173
+ name: error.name,
174
+ message: error.message,
175
+ stack: error.stack
176
+ },
177
+ i: data.i
178
+ });
179
+ }
180
+ });
181
+ }
200
182
  }
201
183
 
202
184
  export { RemoteEnvironmentTransport, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
@@ -122,6 +122,7 @@ declare class ModuleRunner {
122
122
  private readonly envProxy;
123
123
  private readonly transport;
124
124
  private readonly resetSourceMapSupport?;
125
+ private readonly root;
125
126
  private destroyed;
126
127
  constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
127
128
  /**
@@ -143,6 +144,8 @@ declare class ModuleRunner {
143
144
  isDestroyed(): boolean;
144
145
  private normalizeEntryUrl;
145
146
  private processImport;
147
+ private isCircularModule;
148
+ private isCircularImport;
146
149
  private cachedRequest;
147
150
  private cachedModule;
148
151
  protected directRequest(id: string, mod: ModuleCache, _callstack: string[]): Promise<any>;