@syumai/esbuild-loader
v1.0.1
Published
esbuild loader which runs esbuild's build command on given path.
Downloads
2
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 @syumai/esbuild-loader
Usage
webpack.config.ts
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.
},
},
],
},
...
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
Author
syumai