Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amilajack/erb-sqlite-example
An example of erb with native dependencies (sqlite3 in this case)
https://github.com/amilajack/erb-sqlite-example
Last synced: 12 days ago
JSON representation
An example of erb with native dependencies (sqlite3 in this case)
- Host: GitHub
- URL: https://github.com/amilajack/erb-sqlite-example
- Owner: amilajack
- License: mit
- Created: 2017-04-23T21:44:15.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T03:06:05.000Z (over 2 years ago)
- Last Synced: 2024-04-14T21:47:59.499Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 12 MB
- Stars: 45
- Watchers: 3
- Forks: 23
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# erb-sqlite-example
[![Test](https://github.com/amilajack/erb-sqlite-example/actions/workflows/test.yml/badge.svg)](https://github.com/amilajack/erb-sqlite-example/actions/workflows/test.yml)
**An example of erb with native dependencies (sqlite3 in this case)**
## Setup
```bash
git clone https://github.com/amilajack/erb-sqlite-example.git
cd erb-sqlite-example
npm i
npm start
```## How it works
`sqlite3` is a native dependency that needs to be compiled before it is used (therefore it is consiered 'native dependency'). `sqlite3` and any other depencencies in `./build/app/package.json` are imported as an [externals](https://webpack.js.org/configuration/externals/), which means that webpack doesn't process them. The dependency will be imported with normal `require()` calls.
Some native dependencies have issues with how webpack bundles code. One solution to these kinds of issues is to add those native dependencies to your `./build/app/package.json`. These dependencies are automatically rebuilt against electron's node version after installing (see the postinstall script in `./build/app/package.json`). [electron-builder](https://github.com/electron-userland/electron-builder) will also rebuild dependencies just before packaging your app.
You **must** install the dependencies as `dependencies` **and not** `devDepencencies`. Make sure to install like so for npm: `npm install my-cool-depencency` and like so for npm: `npm i my-cool-dependency`.
## Notes
**These changes that were made to ERB:**
```bash
cd build/app
npm i sqlite3
```