MCPcopy
hub / github.com/vitejs/vite / setup

Function setup

packages/vite/src/node/optimizer/pluginConverter.ts:41–111  ·  view source on GitHub ↗
(
    plugins: RolldownPluginOption[],
    platform: 'browser' | 'node' | 'neutral',
  )

Source from the content-addressed store, hash-verified

39
40 let isSetupDone = false
41 const setup = async (
42 plugins: RolldownPluginOption[],
43 platform: 'browser' | 'node' | 'neutral',
44 ) => {
45 const onResolveCallbacks: Array<
46 [options: esbuild.OnResolveOptions, callback: EsbuildOnResolveCallback]
47 > = []
48 const onLoadCallbacks: Array<
49 [options: esbuild.OnLoadOptions, callback: EsbuildOnLoadCallback]
50 > = []
51
52 const pluginBuild: esbuild.PluginBuild = {
53 initialOptions: new Proxy(
54 {
55 platform,
56 plugins:
57 plugins?.flatMap((p) =>
58 p && 'name' in p
59 ? [
60 {
61 name: p.name,
62 // eslint-disable-next-line @typescript-eslint/no-empty-function
63 setup() {},
64 },
65 ]
66 : [],
67 ) ?? [],
68 },
69 {
70 get(target, p, _receiver) {
71 if (p in target) return (target as any)[p]
72 throw new Error('Not implemented')
73 },
74 },
75 ) as esbuild.BuildOptions,
76 resolve() {
77 throw new Error('Not implemented')
78 },
79 onStart(callback) {
80 onStartCallbacks.push(callback)
81 },
82 onEnd(callback) {
83 onEndCallbacks.push(callback)
84 },
85 onResolve(options, callback) {
86 onResolveCallbacks.push([options, callback])
87 },
88 onLoad(options, callback) {
89 onLoadCallbacks.push([options, callback])
90 },
91 onDispose(callback) {
92 onDisposeCallbacks.push(callback)
93 },
94 get esbuild(): esbuild.PluginBuild['esbuild'] {
95 throw new Error('Not implemented')
96 },
97 set esbuild(_: unknown) {
98 throw new Error('Not implemented')

Callers 2

optionsFunction · 0.70
buildStartFunction · 0.70

Calls 2

createResolveIdHandlerFunction · 0.85
createLoadHandlerFunction · 0.85

Tested by

no test coverage detected