@protobase/cli 0.39.1 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ //#region src/build/shell-chunks.ts
2
+ /**
3
+ * The npm package a module id belongs to, as the last `node_modules` segment of its path names it, since Bun's store
4
+ * nests packages as `node_modules/.bun/<package>@<version>/node_modules/<package>`; none for a module outside one.
5
+ */
6
+ const npmPackage = (id) => /.*node_modules[\\/]((?:@[^\\/]+[\\/])?[^\\/]+)/.exec(id)?.[1]?.replace("\\", "/");
7
+ const reactPackages = /* @__PURE__ */ new Set([
8
+ "react",
9
+ "react-dom",
10
+ "scheduler"
11
+ ]);
12
+ /** Whether a module goes in the `react` chunk. */
13
+ const isReactModule = (id) => reactPackages.has(npmPackage(id) ?? "");
14
+ /**
15
+ * Whether a module goes in the `vendor` chunk: a third-party one but React's and the icons'. The icons stay in `app`,
16
+ * since the app picks up a new one on many releases, which would change `vendor` and every lazy chunk that imports it.
17
+ */
18
+ const isVendorModule = (id) => {
19
+ const name = npmPackage(id);
20
+ return name !== void 0 && !reactPackages.has(name) && name !== "lucide-react";
21
+ };
22
+ /**
23
+ * The shell build's `output.codeSplitting`. `react` comes first: without it, `vendor` would take React in as a
24
+ * dependency of the libraries it holds, and lazy chunks would import it from there.
25
+ */
26
+ const shellCodeSplitting = { groups: [{
27
+ name: "react",
28
+ test: isReactModule,
29
+ priority: 2
30
+ }, {
31
+ name: "vendor",
32
+ test: isVendorModule,
33
+ tags: ["$initial"],
34
+ priority: 1
35
+ }] };
36
+ //#endregion
37
+ export { isReactModule, isVendorModule, npmPackage, shellCodeSplitting };
@@ -7,6 +7,7 @@ import { themeLink } from "../project/theme-link.js";
7
7
  import { serviceWorkerFile } from "./service-worker-code.js";
8
8
  import { serviceWorker } from "../project/service-worker.js";
9
9
  import { moveSourceMaps } from "./source-maps.js";
10
+ import { shellCodeSplitting } from "./shell-chunks.js";
10
11
  import { existsSync } from "node:fs";
11
12
  import path from "node:path";
12
13
  import { build } from "vite";
@@ -45,7 +46,8 @@ const shellIdentity = async () => {
45
46
  * any deep link. It calls /api on its own origin and loads the project's UI, like every plugin, from what `/meta`
46
47
  * names, and links the project's theme at /protobase.theme.css and its favicon at /protobase.favicon.svg, and registers its service worker. The modules plugins share with it have entries of
47
48
  * their own, which index.html's import map names. With `sourceMapsDir`, each script ends with a `//# debugId=` comment
48
- * and names no map, and its source map, carrying the same debug id, goes to the same place under `sourceMapsDir`.
49
+ * and names no map, and its source map, carrying the same debug id, goes to the same place under `sourceMapsDir`. The
50
+ * scripts split into react, vendor and app chunks (./shell-chunks), so an update mostly downloads only the app's.
49
51
  */
50
52
  const buildShell = async (outDir, sourceMapsDir) => {
51
53
  const sourceMaps = sourceMapsDir !== void 0;
@@ -73,7 +75,10 @@ const buildShell = async (outDir, sourceMapsDir) => {
73
75
  emptyOutDir: true,
74
76
  chunkSizeWarningLimit: 4096,
75
77
  sourcemap: sourceMaps && "hidden",
76
- rolldownOptions: { output: { sourcemapDebugIds: sourceMaps } }
78
+ rolldownOptions: { output: {
79
+ sourcemapDebugIds: sourceMaps,
80
+ codeSplitting: shellCodeSplitting
81
+ } }
77
82
  }
78
83
  }).finally(() => {
79
84
  if (nodeEnv === void 0) delete process.env.NODE_ENV;
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.39.1";
2
+ var version = "0.39.2";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.39.1",
3
+ "version": "0.39.2",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "@better-auth/core": "^1.7.12",
37
37
  "@hono/node-server": "^2.1.3",
38
38
  "@hono/vite-dev-server": "^0.26.1",
39
- "@protobase/layout": "0.39.1",
40
- "@protobase/query": "0.39.1",
41
- "@protobase/schema": "0.39.1",
42
- "@protobase/server": "0.39.1",
43
- "@protobase/ui": "0.39.1",
39
+ "@protobase/layout": "0.39.2",
40
+ "@protobase/query": "0.39.2",
41
+ "@protobase/schema": "0.39.2",
42
+ "@protobase/server": "0.39.2",
43
+ "@protobase/ui": "0.39.2",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",