esbuild
https://gyazo.com/5c924f09f223d11c4a90e45fe602ed5b
TypeScriptTypeScript.icon では型檢査をサボる等、transpile & bundle 以外の働きをしない esbuild-loaderesbuild.iconwebpack.icon
core.js を入れる爲に bebel-loaderBabel.iconwebpack.icon と協働する事に成るであらう。さうすると @babel/preset-env が使へる
.optimizer.minimizer も持つ
code:webpack.config.js
const { ESBuildMinifyPlugin } = require('esbuild-loader');
{
optimization: {
minimizer: [
new ESBuildMinifyPlugin({}),
],
},
}
esbuild-jestesbuild.iconJest.icon
babel-jestBabel.iconJest.icon と協働する必要がある
target と extends は tsconfig.json を見れくれる
型定義 file は別途 tsc で生成する
$ tsc --build tsconfig.d.json
code:tsconfig.d.json
{
"extends": "tsconfig.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true
},
}
glob は展開できないので node-glob を使ふ
code:esbuild.mjs
import { build } from "esbuild";
import glob from "glob";
import path from "path";
import process from "process";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
function aglob(pattern) {
return new Promise(function (resolve, reject) {
glob(pattern, function (err, files) {
if (err !== null) {
return reject(err);
}
resolve(files);
});
});
}
const entryPoints = await aglob(path.join(__dirname, "../src/**/*.{ts,tsx}"));
const isWatch = process.argv.includes("--watch");
build({
entryPoints: entryPoints,
format: "cjs",
logLevel: "warning",
outdir: path.join(__dirname, "../dist"),
watch: isWatch,
});