- A Webpack loader to run esbuild's build command on given path.
- This loader is useful for embedding partial TypeScript codes into your another code as bundled string.
npm i -D @syumai/esbuild-loader
import { BuildOptions } from "esbuild";
const config = {
...
module: {
rules: [
{
test: /\.ts$/,
resourceQuery: /source/,
type: "asset/source",
use: [
{
loader: "@syumai/esbuild-loader",
options: {
build: {
minify: false,
platform: "neutral",
} satisfies BuildOptions, // `build` key accepts esbuild's BuildOptions.
},
},
],
},
...
- bar.ts
export const bar = "bar";
- foo.ts
import { bar } from "./bar";
export const fooBar = "foo" + bar;
- index.ts
import fooCode from "./foo?source";
/* result:
// src/bar.ts
var bar = "bar";
// src/foo.ts
var fooBar = "foo" + bar;
export {
fooBar
};
*/
MIT
syumai