@basemachina/esbuild-loader
v1.0.0
Published
esbuild loader which runs esbuild's build command on given path.
Downloads
718
Keywords
Readme
esbuild-loader
- 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.
Installation
npm i -D @basemachina/esbuild-loader
Usage
webpack.config.ts
import { BuildOptions } from "esbuild";
const config = {
...
module: {
rules: [
{
test: /\.ts$/,
resourceQuery: /source/,
type: "asset/source",
use: [
{
loader: "@basemachina/esbuild-loader",
options: {
build: {
minify: false,
platform: "neutral",
} satisfies BuildOptions, // `build` key accepts esbuild's BuildOptions.
},
},
],
},
...
Code
- 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
};
*/
License
MIT