source: node_modules/vite/dist/node/index.js@ de83113

Last change on this file since de83113 was 57e58a3, checked in by ste08 <sjovanoska@…>, 4 months ago

Initial commit

  • Property mode set to 100644
File size: 5.2 KB
Line 
1export { parseAst, parseAstAsync } from 'rollup/parseAst';
2import { i as isInNodeModules, a as arraify } from './chunks/dep-CfG9u7Cn.js';
3export { 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';
4export { 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';
5export { version as esbuildVersion } from 'esbuild';
6import 'node:fs';
7import 'node:path';
8import 'node:fs/promises';
9import 'node:url';
10import 'node:util';
11import 'node:perf_hooks';
12import 'node:module';
13import 'node:crypto';
14import 'path';
15import 'fs';
16import 'node:child_process';
17import 'node:http';
18import 'node:https';
19import 'tty';
20import 'util';
21import 'net';
22import 'events';
23import 'url';
24import 'http';
25import 'stream';
26import 'os';
27import 'child_process';
28import 'node:os';
29import 'node:dns';
30import 'vite/module-runner';
31import 'module';
32import 'node:readline';
33import 'node:process';
34import 'node:buffer';
35import 'node:events';
36import 'crypto';
37import 'node:assert';
38import 'node:v8';
39import 'node:worker_threads';
40import 'zlib';
41import 'buffer';
42import 'https';
43import 'tls';
44import 'node:net';
45import 'assert';
46import 'node:querystring';
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
153export { isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
Note: See TracBrowser for help on using the repository browser.