File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import path from "node:path";
33import { writeFileSync , mkdirSync } from "node:fs" ;
44import { normalizeModulePath } from "../lib/normalizeModulePath.mjs" ;
55import { runEsbuildScan } from "./runEsbuildScan.mjs" ;
6+ import { getViteEsbuild } from "./getViteEsbuild.mjs" ;
67
78export const VIRTUAL_CLIENT_BARREL_ID = "virtual:rwsdk:client-module-barrel" ;
89export const VIRTUAL_SERVER_BARREL_ID = "virtual:rwsdk:server-module-barrel" ;
Original file line number Diff line number Diff line change 1+ import path from "node:path" ;
2+ import { createRequire } from "node:module" ;
3+
4+ const require = createRequire ( import . meta. url ) ;
5+
6+ export async function getViteEsbuild ( projectRootDir : string ) : Promise < any > {
7+ const vitePath = require . resolve ( "vite/package.json" , {
8+ paths : [ projectRootDir ] ,
9+ } ) ;
10+ const viteDir = path . dirname ( vitePath ) ;
11+
12+ const esbuildPath = require . resolve ( "esbuild" , { paths : [ viteDir ] } ) ;
13+
14+ const esbuildModule = await import ( esbuildPath ) ;
15+ return esbuildModule . default || esbuildModule ;
16+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { hasDirective } from "./hasDirective.mjs";
1313import path from "node:path" ;
1414import debug from "debug" ;
1515import { ensureAliasArray } from "./ensureAliasArray.mjs" ;
16+ import { getViteEsbuild } from "./getViteEsbuild.mjs" ;
1617
1718const log = debug ( "rwsdk:vite:esbuild-scan" ) ;
1819
@@ -96,6 +97,7 @@ export async function runEsbuildScan({
9697 clientFiles : Set < string > ;
9798 serverFiles : Set < string > ;
9899} ) {
100+ const esbuild = await getViteEsbuild ( rootConfig . root ) ;
99101 const env = rootConfig . environments [ envName ] ;
100102 const input = env . build . rollupOptions ?. input ;
101103 let entries : string [ ] ;
You can’t perform that action at this time.
0 commit comments