Commit bca68b0d authored by Aral Balkan's avatar Aral Balkan
Browse files

JSDB database tables are now saved with .cjs extensions

parent ac383f2f
......@@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [16.5.1] - 2021-04-23
## [16.6.0] - 2021-04-23
### Added
### Changed
- JSDB databases now store their tables with the `.cjs` extension instead of the `.js` extension for better compatibility when used in mixed CommonJS/ESM projects.
- Support for `routes.cjs` file in addition to `routes.js` file for advanced routing.
## [16.5.0] - 2021-04-23
......
......@@ -1356,6 +1356,8 @@ Similarly, if you wanted just the first message that contained the word `kitten`
db.messages.where('text').includes('kitten').getFirst()
```
__As of version 16.6.0__, Site.js stores its JSDB tables with the `.cjs` extension instead of `.js` for better compatibility when used in mixed CommonJS/ESM projects.
You can learn more about JSDB in the [JSDB documentation](https://github.com/small-tech/jsdb/blob/master/README.md).
### Advanced routing (routes.js file)
......
......@@ -1000,7 +1000,7 @@ class Site {
// instead of possibly accessing the accessor defined in the other branch of this conditional, thereby
// triggering it to be created when all we want to do is perform housekeeping.
this.log(' 💾 ❨site.js❩ Opening database.')
globalThis._db = JSDB.open(this.databasePath)
globalThis._db = JSDB.open(this.databasePath, { cjs: true })
globalThis.db = globalThis._db
this.log(' 💾 ❨site.js❩ Database ready.')
} else {
......@@ -1010,7 +1010,7 @@ class Site {
get: (function () {
if (!globalThis._db) {
this.log(' 💾 ❨site.js❩ Lazily creating database.')
globalThis._db = JSDB.open(this.databasePath)
globalThis._db = JSDB.open(this.databasePath, { cjs: true })
this.log(' 💾 ❨site.js❩ Database ready.')
}
return globalThis._db
......
......@@ -477,9 +477,9 @@
}
},
"@small-tech/jsdb": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/@small-tech/jsdb/-/jsdb-1.1.5.tgz",
"integrity": "sha512-TI7gQZlVgbqoFeDogRQdEQwOnWL0Wht3N3kzPYoxkcCKYDFsbfAq3IcdX6dCNnh5adWd7qYQX6upbYDNfWYtIQ==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@small-tech/jsdb/-/jsdb-1.2.0.tgz",
"integrity": "sha512-8UeU3Ei4pywbMhFb1VZEliHg27lKtESNt1+WIC2tKjGeWgymK+W/V99kS70sePwzEzJv5VPmYG6/BmBddXVWmg==",
"requires": {
"@jcbuisson/readlinesync": "^1.0.0",
"decache": "^4.6.0",
......@@ -495,34 +495,34 @@
}
},
"fs-extra": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz",
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==",
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
"requires": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^1.0.0"
"universalify": "^2.0.0"
}
},
"graceful-fs": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ=="
},
"jsonfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz",
"integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^1.0.0"
"universalify": "^2.0.0"
}
},
"universalify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug=="
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
}
}
},
......
{
"name": "@small-tech/site.js",
"version": "16.5.0",
"version": "16.6.0",
"description": "Small Web construction set.",
"keywords": [
"web server",
......@@ -56,7 +56,7 @@
"@small-tech/express-ws": "^1.0.0",
"@small-tech/https": "^2.1.2",
"@small-tech/instant": "^1.1.2",
"@small-tech/jsdb": "^1.1.5",
"@small-tech/jsdb": "^1.2.0",
"@small-tech/node-hugo": "^2.0.0",
"@small-tech/portable-rsync-with-ssh-for-windows": "^1.0.0",
"@small-tech/rsync-with-portable-cygwin-path-support-on-windows": "^1.0.0",
......
......@@ -432,7 +432,7 @@ test('[site.js] database', async t => {
// On start-up, the database and a table called test should have been created.
const tablePath = path.join(databasePath, 'test.js')
const tablePath = path.join(databasePath, 'test.cjs')
t.ok(fs.existsSync(databasePath), 'database is created')
t.ok(fs.existsSync(tablePath), 'table is created')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment