LoginSignup
0
0

More than 1 year has passed since last update.

TypeScript esbuildでKnexの入ったプロジェクトをビルドしようとするとエラーが出るときの対処法

Posted at
[ERROR] Could not resolve "better-sqlite3"

など、様々なDBのdriverが解決できないよ、というエラーが出る。
bundle時にknex内の依存を解決しようとしてエラーが出ているんだろう。

対処法はexternalにknexを追加すること。

build.mjs
await esbuild.build({
  entryPoints: ["./src/main.js"],
  platform: "node",
  outfile: "./dist/main.js",
  tsconfig: "tsconfig.build.json",
  packages: "external",
  bundle: true,
  minify: true,
  external: ["knex"], //←これ
});

cliでやるなら

--external:knex

とかでいけると思う(未確認)。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0