esbuild と babel プラグインを使用して Web アプリケーションをバンドルしようとしています。しかし、いくつかのエラーが発生します。
esbuild 構成:
import esbuild from 'esbuild'
import babel from 'esbuild-plugin-babel'
esbuild.build({
entryPoints: ["./out/tsc/src/app.js"],
bundle: true,
outfile: "./out/esbuildmain.js",
plugins: [babel({
sourcemap: 'external'
})],
platform: 'node',
target: ["es6"]
}).catch((e) => { console.log(`Failed to compile! Reason: ${e}`) })
エラーは次のとおりです。
> node_modules/mongodb/lib/utils.js:853:36: error: [plugin: babel] project-root\node_modules\mongodb\package.json: Missing semicolon. (2:8)
1 | {
> 2 | "name": "mongodb",
| ^
3 | "version": "4.1.2",
4 | "description": "The official MongoDB driver for Node.js",
5 | "main": "lib/index.js",
853 │ const NODE_DRIVER_VERSION = require('../package.json').version;
╵ ~~~~~~~~~~~~~~~~~
node_modules/esbuild/lib/main.js:756:22: note: This error came from the "onLoad" callback registered here
756 │ let promise = setup({
╵ ^
at setup (file:///project-root/node_modules/esbuild-plugin-babel/src/index.js:36:9)
at handlePlugins (project-root\node_modules\esbuild\lib\main.js:756:23)
at Object.buildOrServe (project-root\node_modules\esbuild\lib\main.js:1044:7)
at project-root\node_modules\esbuild\lib\main.js:1886:17
at new Promise (<anonymous>)
at Object.build (project-root\node_modules\esbuild\lib\main.js:1885:14)
at Object.build (project-root\node_modules\esbuild\lib\main.js:1740:51)
at file:///project-root/esbuild.config.mjs:4:9
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
> node_modules/mongodb-connection-string-url/node_modules/whatwg-url/dist/utils.js:46:75: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
46 │ const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
╵ ~~~~~
Failed to compile! Reason: Error: Build failed with 2 errors:
node_modules/mongodb-connection-string-url/node_modules/whatwg-url/dist/utils.js:46:75: error: Transforming async generator functions to the configured target environment ("es2015") is not supported yet
node_modules/mongodb/lib/utils.js:853:36: error: [plugin: babel] project-root\node_modules\mongodb\package.json: Missing semicolon. (2:8)
1 | {
> 2 | "name": "mongodb",
| ^
3 | "version": "4.1.2",
4 | "description": "The official MongoDB driver for Node.js",
5 | "main": "lib/index.js",
mongodb には json ファイルが必要であり、バンドルできないことが指摘されています。esbuild にこのライブラリをバンドルさせるにはどうすればよいですか?