-1

I am trying to compile a very simple typescript code with esbuild.

However esbuild is compiling only the entry file.

This is my setup:

//index.ts
import * as mod1 from './mod1';
mod1.my_method();
//mod1.ts
export function my_method(){
  console.log('debug');
}

I run:

esbuild index.ts --outdir=./dist --platform=node

the compilation is done with no error and if I now check the dist I get only

dist
- index.js
// dist/indes.js
import * as mod1 from './mod1';
mod1.my_method();

but there is no trace of dist/mod1.js. So of course the code cannot run and give an error.

Why esbuild is not compiling all the other files like mod1.ts?

I can't use --bundle in my project.

47ndr
  • 583
  • 5
  • 23
  • Well --bundle option it is what you have to do in order to compile also imported modules. "I can't use --bundle in my project." it is like you would say "I want to bundle but I cannot". https://esbuild.github.io/api/#bundle . – Konrad Grzyb Jan 14 '23 at 10:41

1 Answers1

-2

esbuild index.ts --outdir=./dist --platform=node ^^^

you only specify the index.ts file in the commandline

i never actually worked with esbuild, but there is probably a function for folders, like esbuild . --outdir=./dist --platform=node

Pyxel Codes
  • 162
  • 2