4 ms·
I've really wanted to use Esbuild in my projects but I haven't figured out a great way to get the desired functionality I want: I'd like to be able to transpil
by lefrenchy 6y ago
I've really wanted to use Esbuild in my projects but I haven't figured out a great way to get the desired functionality I want:
I'd like to be able to transpile my code but keep the same directory structure in the output. For example, I have an index.js file that exports all my components and I'd like to just create a "build" folder output with the same exact file structure, but with all the files exported from index.js having been transpiled.
Does anyone know if that is supported?
- joshum97 6y agoEsbuild does have a JS transform API, so you could write a command line tool that walks the file system (Babel, ESLint, Prettier, etc. all do this so you have examples), transforms each file, and writes the code back out. Snowpack's build command also does this.
- keb_ 6y agoHey, I was trying to do this same thing for a TypeScript project I was bootstrapping. Digging around the issue tracker, I recall the maintainer stating that this is currently not in the scope of esbuild, and that swc[0] might be better suited for this. Personally, I wrote a crude JS script using the esbuild transform API + node-watch to compile .ts files and copy files/folders during development. This is all very recent, so I can't ensure that it's bulletproof quite yet. [0] https://swc.rs/ https://swc.rs/