1 | export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-1889fec9.js';
|
2 | export { VERSION as version } from './constants.js';
|
3 | export { version as esbuildVersion } from 'esbuild';
|
4 | export { VERSION as rollupVersion } from 'rollup';
|
5 | import 'node:fs';
|
6 | import 'node:path';
|
7 | import 'node:url';
|
8 | import 'node:perf_hooks';
|
9 | import 'node:module';
|
10 | import 'tty';
|
11 | import 'path';
|
12 | import 'fs';
|
13 | import 'events';
|
14 | import 'assert';
|
15 | import 'util';
|
16 | import 'net';
|
17 | import 'url';
|
18 | import 'http';
|
19 | import 'stream';
|
20 | import 'os';
|
21 | import 'child_process';
|
22 | import 'node:os';
|
23 | import 'node:crypto';
|
24 | import 'node:util';
|
25 | import 'node:dns';
|
26 | import 'resolve';
|
27 | import 'crypto';
|
28 | import 'node:buffer';
|
29 | import 'module';
|
30 | import 'worker_threads';
|
31 | import 'zlib';
|
32 | import 'https';
|
33 | import 'tls';
|
34 | import 'node:http';
|
35 | import 'node:https';
|
36 | import 'querystring';
|
37 | import 'node:readline';
|
38 | import 'node:child_process';
|
39 | import 'node:zlib';
|
40 |
|
41 |
|
42 | const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
43 | const cssLangRE = new RegExp(cssLangs);
|
44 | const isCSSRequest = (request) => cssLangRE.test(request);
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | class SplitVendorChunkCache {
|
53 | constructor() {
|
54 | this.cache = new Map();
|
55 | }
|
56 | reset() {
|
57 | this.cache = new Map();
|
58 | }
|
59 | }
|
60 | function splitVendorChunk(options = {}) {
|
61 | const cache = options.cache ?? new SplitVendorChunkCache();
|
62 | return (id, { getModuleInfo }) => {
|
63 | if (id.includes('node_modules') &&
|
64 | !isCSSRequest(id) &&
|
65 | staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
66 | return 'vendor';
|
67 | }
|
68 | };
|
69 | }
|
70 | function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
71 | if (cache.has(id)) {
|
72 | return cache.get(id);
|
73 | }
|
74 | if (importStack.includes(id)) {
|
75 |
|
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((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
|
89 | cache.set(id, someImporterIs);
|
90 | return someImporterIs;
|
91 | }
|
92 | function splitVendorChunkPlugin() {
|
93 | const caches = [];
|
94 | function createSplitVendorChunk(output, config) {
|
95 | const cache = new SplitVendorChunkCache();
|
96 | caches.push(cache);
|
97 | const build = config.build ?? {};
|
98 | const format = output?.format;
|
99 | if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
|
100 | return splitVendorChunk({ cache });
|
101 | }
|
102 | }
|
103 | return {
|
104 | name: 'vite:split-vendor-chunk',
|
105 | config(config) {
|
106 | let outputs = config?.build?.rollupOptions?.output;
|
107 | if (outputs) {
|
108 | outputs = Array.isArray(outputs) ? outputs : [outputs];
|
109 | for (const output of outputs) {
|
110 | const viteManualChunks = createSplitVendorChunk(output, config);
|
111 | if (viteManualChunks) {
|
112 | if (output.manualChunks) {
|
113 | if (typeof output.manualChunks === 'function') {
|
114 | const userManualChunks = output.manualChunks;
|
115 | output.manualChunks = (id, api) => {
|
116 | return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
117 | };
|
118 | }
|
119 |
|
120 |
|
121 | }
|
122 | else {
|
123 | output.manualChunks = viteManualChunks;
|
124 | }
|
125 | }
|
126 | }
|
127 | }
|
128 | else {
|
129 | return {
|
130 | build: {
|
131 | rollupOptions: {
|
132 | output: {
|
133 | manualChunks: createSplitVendorChunk({}, config)
|
134 | }
|
135 | }
|
136 | }
|
137 | };
|
138 | }
|
139 | },
|
140 | buildStart() {
|
141 | caches.forEach((cache) => cache.reset());
|
142 | }
|
143 | };
|
144 | }
|
145 |
|
146 | export { splitVendorChunk, splitVendorChunkPlugin };
|