[PR #56] [MERGED] Fix Bundling Issues #59

Closed
opened 2026-05-23 08:39:42 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/appy-one/acebase-server/pull/56
Author: @Azarattum
Created: 11/27/2022
Status: Merged
Merged: 12/5/2022
Merged by: @appy-one

Base: masterHead: imports


📝 Commits (4)

📊 Changes

3 files changed (+8 additions, -16 deletions)

View changed files

📝 src/routes/meta-info.ts (+3 -10)
📝 src/server.ts (+3 -5)
📝 tsconfig.json (+2 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/appy-one/acebase-server/pull/56 **Author:** [@Azarattum](https://github.com/Azarattum) **Created:** 11/27/2022 **Status:** ✅ Merged **Merged:** 12/5/2022 **Merged by:** [@appy-one](https://github.com/appy-one) **Base:** `master` ← **Head:** `imports` --- ### 📝 Commits (4) - [`3e0764b`](https://github.com/appy-one/acebase-server/commit/3e0764bbb5a3a9eacbbfbec0c3417d42cd82ac68) fix imports for bundling - [`e7db944`](https://github.com/appy-one/acebase-server/commit/e7db94412c9794d93085c302f801bfe687e9a009) fix esm json import - [`6cdb009`](https://github.com/appy-one/acebase-server/commit/6cdb0094386ad9e3cc1924510ffbb8597906a290) fix environment detection - [`97cd904`](https://github.com/appy-one/acebase-server/commit/97cd90421c039198bfb8389bb5b5ba1a48d0a296) trim without optional chaining ### 📊 Changes **3 files changed** (+8 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `src/routes/meta-info.ts` (+3 -10) 📝 `src/server.ts` (+3 -5) 📝 `tsconfig.json` (+2 -1) </details> ### 📄 Description I use [vite](https://github.com/vitejs/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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-23 08:39:42 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-server#59
No description provided.