File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @bomb.sh/tools " : patch
3+ ---
4+
5+ Fixes externalized dependency bundling and properly handles rewriting for local ` .ts ` modules
Original file line number Diff line number Diff line change 11import { rm } from "node:fs/promises" ;
2- import { build as esbuild } from "esbuild" ;
2+ import { type Plugin , build as esbuild } from "esbuild" ;
33import type { CommandContext } from "../context.ts" ;
44import { getPackageJSON } from "../utils.ts" ;
55
@@ -8,6 +8,7 @@ export async function build(ctx: CommandContext) {
88 await rm ( "dist" , { recursive : true , force : true } ) ;
99 await esbuild ( {
1010 entryPoints : [ "src/*" , "src/**/*" ] ,
11+ plugins : [ ts ( ) ] ,
1112 outdir : "dist" ,
1213 platform : "node" ,
1314 format : "esm" ,
@@ -21,3 +22,15 @@ export async function build(ctx: CommandContext) {
2122 process . exit ( 1 ) ;
2223 } ) ;
2324}
25+
26+ function ts ( ) : Plugin {
27+ return {
28+ name : 'ts' ,
29+ setup ( build ) {
30+ build . onResolve ( { filter : / \. t s x ? $ / } , args => {
31+ return { path : args . path . replace ( / \. t s x ? $ / , '.js' ) , external : true }
32+ } )
33+ } ,
34+ }
35+ }
36+
Original file line number Diff line number Diff line change 1+ import { cwd } from "node:process" ;
12import { fileURLToPath , pathToFileURL } from "node:url" ;
23import escalade from "escalade" ;
34
@@ -8,7 +9,7 @@ export function local(file: string) {
89}
910
1011export async function getPackageJSON ( ) {
11- const pkg = await escalade ( fileURLToPath ( import . meta . url ) , ( dir , files ) => {
12+ const pkg = await escalade ( cwd ( ) , ( dir , files ) => {
1213 return files . find ( ( file ) => file === "package.json" ) ;
1314 } ) ;
1415 if ( ! pkg ) {
You can’t perform that action at this time.
0 commit comments