File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 23
23
"prepublishOnly" : " npm run test && npm run build" ,
24
24
"test" : " vitest run"
25
25
},
26
- "peerDependencies" : {
27
- "esbuild" : " *"
28
- },
29
26
"dependencies" : {
30
27
"lib-esm" : " ~0.3.0"
31
28
},
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import path from 'node:path'
3
3
import crypto from 'node:crypto'
4
4
import { createRequire , builtinModules } from 'node:module'
5
5
import type { Alias , Plugin , UserConfig } from 'vite'
6
- import esbuild from 'esbuild'
7
6
import libEsm from 'lib-esm'
8
7
import { COLOURS , node_modules } from 'vite-plugin-utils/function'
9
8
import { builtins } from './build-config'
@@ -191,12 +190,19 @@ function cjsBundling(args: {
191
190
async function esmBundling ( args : {
192
191
name : string ,
193
192
entry : string ,
194
- buildOptions ?: esbuild . BuildOptions ,
193
+ buildOptions ?: import ( ' esbuild' ) . BuildOptions ,
195
194
} ) {
196
195
const { name, entry, buildOptions } = args
197
196
const { name_cjs, destname_cjs } = dest ( name )
198
197
if ( cache . checkHash ( destname_cjs ) ) return
199
198
199
+ let esbuild : typeof import ( 'esbuild' )
200
+ try {
201
+ esbuild = await import ( 'esbuild' )
202
+ } catch {
203
+ throw new Error ( '[Pre-Bundling] dependency "esbuild". Did you install it?' )
204
+ }
205
+
200
206
return esbuild . build ( {
201
207
entryPoints : [ entry ] ,
202
208
outfile : destname_cjs ,
You can’t perform that action at this time.
0 commit comments