Skip to content

Commit

Permalink
fix sqlite3 bunlding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhxhx88 committed Feb 29, 2024
1 parent 73ad3fe commit 2bdf134
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/yjs-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dev": "nodemon src/index.ts",
"lint": "eslint src/",
"build": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack",
"bundle": "pkg --output bin/yjs-server dist/yjs-server.js"
"bundle": "pkg -c pkg.json --output bin/yjs-server dist/yjs-server.js"
},
"devDependencies": {
"@types/node": "^20.11.20",
Expand Down
3 changes: 3 additions & 0 deletions app/yjs-server/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"assets": ["node_modules/sqlite3/build/Release/node_sqlite3.node"]
}
6 changes: 6 additions & 0 deletions app/yjs-server/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const config: Configuration = {
},
],
},
externals: {
// Node native addons need to be packed specially. Also check `pkg.json`
// https://stackoverflow.com/questions/46465037/how-to-package-sqlite3-in-node-js-executable-packages
// https://github.com/TryGhost/node-sqlite3/issues/698#issuecomment-354129269
sqlite3: "commonjs sqlite3",
},
};

// eslint-disable-next-line import/no-default-export -- fine
Expand Down

0 comments on commit 2bdf134

Please sign in to comment.