TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.23k stars 817 forks source link

I can't bundle project with this library #1741

Closed ariran5 closed 11 months ago

ariran5 commented 11 months ago

Issue Summary

I use esbuld for bundle my typescript nodejs project to single file for docker container, and sqlite3 has many bad dependencies. see here npm graph

My command for bundle

esbuild src/index.ts --bundle --platform=node --target=node21 --outdir=dist --format=esm --banner:js="import {createRequire} from 'node:module'; const require = createRequire(import.meta.url)"

use this command for testing basic typescript project + esbuild

================

sqlite3 has dependency "@mapbox/node-pre-gyp" and i see, this package has bad imports without filename

node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:86:21:
      86 │       return require('./' + command)(self, argvx, callback);

and aws imports without this dependencies

node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
      43 │     const AWSMock = require('mock-aws-s3');

node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:22:
      76 │   const AWS = require('aws-sdk');

node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
      112 │   const nock = require('nock');

I Cant bundle this

Steps to Reproduce

  1. instasll esbuild, sqlite3 and typescript
  2. bundle project with command
    esbuild src/index.ts --bundle --platform=node --target=node21 --outdir=dist --format=esm --banner:js="import {createRequire} from 'node:module'; const require = createRequire(import.meta.url)"

Version

5.1.6

Node.js Version

21

How did you install the library?

windows 11 x86

daniellockyer commented 11 months ago

This was fixed in https://github.com/TryGhost/node-sqlite3/commit/605c7f981abbcf980cb44f54abba285de9a69a23, there should be a RC release soon, and then full release after 🙂