1 | export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
---|
2 | import { i as isInNodeModules, a as arraify } from './chunks/dep-CfG9u7Cn.js';
|
---|
3 | export { B as BuildEnvironment, D as DevEnvironment, 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-CfG9u7Cn.js';
|
---|
4 | 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';
|
---|
5 | export { version as esbuildVersion } from 'esbuild';
|
---|
6 | import 'node:fs';
|
---|
7 | import 'node:path';
|
---|
8 | import 'node:fs/promises';
|
---|
9 | import 'node:url';
|
---|
10 | import 'node:util';
|
---|
11 | import 'node:perf_hooks';
|
---|
12 | import 'node:module';
|
---|
13 | import 'node:crypto';
|
---|
14 | import 'path';
|
---|
15 | import 'fs';
|
---|
16 | import 'node:child_process';
|
---|
17 | import 'node:http';
|
---|
18 | import 'node:https';
|
---|
19 | import 'tty';
|
---|
20 | import 'util';
|
---|
21 | import 'net';
|
---|
22 | import 'events';
|
---|
23 | import 'url';
|
---|
24 | import 'http';
|
---|
25 | import 'stream';
|
---|
26 | import 'os';
|
---|
27 | import 'child_process';
|
---|
28 | import 'node:os';
|
---|
29 | import 'node:dns';
|
---|
30 | import 'vite/module-runner';
|
---|
31 | import 'module';
|
---|
32 | import 'node:readline';
|
---|
33 | import 'node:process';
|
---|
34 | import 'node:buffer';
|
---|
35 | import 'node:events';
|
---|
36 | import 'crypto';
|
---|
37 | import 'node:assert';
|
---|
38 | import 'node:v8';
|
---|
39 | import 'node:worker_threads';
|
---|
40 | import 'zlib';
|
---|
41 | import 'buffer';
|
---|
42 | import 'https';
|
---|
43 | import 'tls';
|
---|
44 | import 'node:net';
|
---|
45 | import 'assert';
|
---|
46 | import 'node:querystring';
|
---|
47 | import 'node:zlib';
|
---|
48 |
|
---|
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 | );
|
---|
53 | const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
---|
54 | class SplitVendorChunkCache {
|
---|
55 | cache;
|
---|
56 | constructor() {
|
---|
57 | this.cache = /* @__PURE__ */ new Map();
|
---|
58 | }
|
---|
59 | reset() {
|
---|
60 | this.cache = /* @__PURE__ */ new Map();
|
---|
61 | }
|
---|
62 | }
|
---|
63 | function 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 | }
|
---|
71 | function 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 | }
|
---|
99 | function 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 |
|
---|
153 | export { isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
---|