source: imaps-frontend/node_modules/vite/dist/node/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 7.3 KB
Line 
1export { parseAst, parseAstAsync } from 'rollup/parseAst';
2import { i as isInNodeModules, a as arraify } from './chunks/dep-mCdpKltl.js';
3export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-mCdpKltl.js';
4export { VERSION as version } from './constants.js';
5export { version as esbuildVersion } from 'esbuild';
6import { existsSync, readFileSync } from 'node:fs';
7import { ViteRuntime, ESModulesRunner } from 'vite/runtime';
8import 'node:fs/promises';
9import 'node:path';
10import 'node:url';
11import 'node:util';
12import 'node:perf_hooks';
13import 'node:module';
14import 'tty';
15import 'path';
16import 'fs';
17import 'node:events';
18import 'node:stream';
19import 'node:string_decoder';
20import 'node:child_process';
21import 'node:http';
22import 'node:https';
23import 'util';
24import 'net';
25import 'events';
26import 'url';
27import 'http';
28import 'stream';
29import 'os';
30import 'child_process';
31import 'node:os';
32import 'node:crypto';
33import 'node:dns';
34import 'crypto';
35import 'module';
36import 'node:assert';
37import 'node:v8';
38import 'node:worker_threads';
39import 'node:buffer';
40import 'querystring';
41import 'node:readline';
42import 'zlib';
43import 'buffer';
44import 'https';
45import 'tls';
46import 'assert';
47import 'node:zlib';
48
49const CSS_LANGS_RE = (
50 // eslint-disable-next-line regexp/no-unused-capturing-group
51 /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
52);
53const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
54class SplitVendorChunkCache {
55 cache;
56 constructor() {
57 this.cache = /* @__PURE__ */ new Map();
58 }
59 reset() {
60 this.cache = /* @__PURE__ */ new Map();
61 }
62}
63function splitVendorChunk(options = {}) {
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 };
70}
71function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
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;
98}
99function splitVendorChunkPlugin() {
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 });
108 }
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);
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 }
142 }
143 }
144 };
145 }
146 },
147 buildStart() {
148 caches.forEach((cache) => cache.reset());
149 }
150 };
151}
152
153class ServerHMRBroadcasterClient {
154 constructor(hmrChannel) {
155 this.hmrChannel = hmrChannel;
156 }
157 send(...args) {
158 let payload;
159 if (typeof args[0] === "string") {
160 payload = {
161 type: "custom",
162 event: args[0],
163 data: args[1]
164 };
165 } else {
166 payload = args[0];
167 }
168 if (payload.type !== "custom") {
169 throw new Error(
170 "Cannot send non-custom events from the client to the server."
171 );
172 }
173 this.hmrChannel.send(payload);
174 }
175}
176class ServerHMRConnector {
177 handlers = [];
178 hmrChannel;
179 hmrClient;
180 connected = false;
181 constructor(server) {
182 const hmrChannel = server.hot?.channels.find(
183 (c) => c.name === "ssr"
184 );
185 if (!hmrChannel) {
186 throw new Error(
187 "Your version of Vite doesn't support HMR during SSR. Please, use Vite 5.1 or higher."
188 );
189 }
190 this.hmrClient = new ServerHMRBroadcasterClient(hmrChannel);
191 hmrChannel.api.outsideEmitter.on("send", (payload) => {
192 this.handlers.forEach((listener) => listener(payload));
193 });
194 this.hmrChannel = hmrChannel;
195 }
196 isReady() {
197 return this.connected;
198 }
199 send(message) {
200 const payload = JSON.parse(message);
201 this.hmrChannel.api.innerEmitter.emit(
202 payload.event,
203 payload.data,
204 this.hmrClient
205 );
206 }
207 onUpdate(handler) {
208 this.handlers.push(handler);
209 handler({ type: "connected" });
210 this.connected = true;
211 }
212}
213
214function createHMROptions(server, options) {
215 if (server.config.server.hmr === false || options.hmr === false) {
216 return false;
217 }
218 const connection = new ServerHMRConnector(server);
219 return {
220 connection,
221 logger: options.hmr?.logger
222 };
223}
224const prepareStackTrace = {
225 retrieveFile(id) {
226 if (existsSync(id)) {
227 return readFileSync(id, "utf-8");
228 }
229 }
230};
231function resolveSourceMapOptions(options) {
232 if (options.sourcemapInterceptor != null) {
233 if (options.sourcemapInterceptor === "prepareStackTrace") {
234 return prepareStackTrace;
235 }
236 if (typeof options.sourcemapInterceptor === "object") {
237 return { ...prepareStackTrace, ...options.sourcemapInterceptor };
238 }
239 return options.sourcemapInterceptor;
240 }
241 if (typeof process !== "undefined" && "setSourceMapsEnabled" in process) {
242 return "node";
243 }
244 return prepareStackTrace;
245}
246async function createViteRuntime(server, options = {}) {
247 const hmr = createHMROptions(server, options);
248 return new ViteRuntime(
249 {
250 ...options,
251 root: server.config.root,
252 fetchModule: server.ssrFetchModule,
253 hmr,
254 sourcemapInterceptor: resolveSourceMapOptions(options)
255 },
256 options.runner || new ESModulesRunner()
257 );
258}
259
260export { ServerHMRConnector, createViteRuntime, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
Note: See TracBrowser for help on using the repository browser.