A fast, low memory, transactional, index & query enabled NoSQL database server for node.js that easily syncs with browser and node.js clients and servers
I use vite to bundle my project into a single file when building for production. acebase-server is currently not suitable for such builds.
After some investigation, I found out that swagger completely breaks in single-file builds. I thought it shouldn't be used in production mode. However, it's still gets bundled increasing file size by a factor for TWO! To solve this problem, I've changed docs imports to dynamic ones and simplified environment condition to be recognized by bundler. (I still needed to do replace({"process.env.NODE_ENV": '"production"'}) with @rollup/plugin-node-resolve though...)
The second problem was dynamically loaded package.json file which is obviously not present when acebase-server module is embedded into an application. To solve this we can use JSON imports from Typescript. This way during bundling the JSON data will be inlined properly. Btw, I did a little hack with @ts-ignore there because TypeScript got mad at the file not being at the source root (./src). It is still miles better that trying to load package.json from the filesystem, and crashing if it's not present.
I use vite to bundle my project into a single file when building for production.
acebase-server
is currently not suitable for such builds.After some investigation, I found out that
swagger
completely breaks in single-file builds. I thought it shouldn't be used in production mode. However, it's still gets bundled increasing file size by a factor for TWO! To solve this problem, I've changed docs imports to dynamic ones and simplified environment condition to be recognized by bundler. (I still needed to doreplace({"process.env.NODE_ENV": '"production"'})
with@rollup/plugin-node-resolve
though...)The second problem was dynamically loaded
package.json
file which is obviously not present whenacebase-server
module is embedded into an application. To solve this we can use JSON imports from Typescript. This way during bundling the JSON data will be inlined properly. Btw, I did a little hack with@ts-ignore
there because TypeScript got mad at the file not being at the source root (./src
). It is still miles better that trying to loadpackage.json
from the filesystem, and crashing if it's not present.