@utoo/pack 1.4.18-alpha.1 → 1.4.18

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.
package/cjs/binding.d.ts CHANGED
@@ -125,6 +125,20 @@ export interface NapiTurboEngineOptions {
125
125
  dependencyTracking?: boolean
126
126
  /** Hint that this turbo-tasks instance is for a short-lived one-shot session. */
127
127
  isShortSession?: boolean
128
+ /** Turbopack memory eviction mode for the persistent cache. */
129
+ turbopackMemoryEviction?: MemoryEvictionMode
130
+ /** Avoid large backend preallocations to reduce startup memory. */
131
+ smallPreallocation?: boolean
132
+ }
133
+ /** Turbopack's memory eviction strategy for the persistent cache. */
134
+ export const enum MemoryEvictionMode {
135
+ /** Never evict. */
136
+ Off = "off",
137
+ /**
138
+ * After every snapshot, evict all evictable tasks from memory, reloading
139
+ * them from disk on demand.
140
+ */
141
+ Full = "full"
128
142
  }
129
143
  export declare function projectNew(options: NapiProjectOptions, turboEngineOptions: NapiTurboEngineOptions, napiCallbacks: NapiTurbopackCallbacksJsObject): Promise<{ __napiType: "Project" }>
130
144
  export declare function projectUpdate(project: { __napiType: "Project" }, options: NapiPartialProjectOptions): Promise<void>
@@ -14,6 +14,7 @@ const project_1 = require("../core/project");
14
14
  const HtmlPlugin_1 = require("../plugins/HtmlPlugin");
15
15
  const cleanOutput_1 = require("../utils/cleanOutput");
16
16
  const common_1 = require("../utils/common");
17
+ const env_1 = require("../utils/env");
17
18
  const findRoot_1 = require("../utils/findRoot");
18
19
  const getInitialAssets_1 = require("../utils/getInitialAssets");
19
20
  const htmlEntry_1 = require("../utils/htmlEntry");
@@ -39,6 +40,8 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
39
40
  const resolvedProjectPath = projectPath || process.cwd();
40
41
  const resolvedRootPath = rootPath || projectPath || process.cwd();
41
42
  const persistentCaching = (_a = bundleOptions.config.persistentCaching) !== null && _a !== void 0 ? _a : true;
43
+ const turbopackMemoryEviction = (0, env_1.normalizeTurbopackMemoryEviction)(bundleOptions.config.turbopackMemoryEviction);
44
+ const smallPreallocation = (0, env_1.isTruthyEnv)(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
42
45
  const shouldCreateWebpackStats = Boolean(process.env.ANALYZE) || Boolean(bundleOptions.config.stats);
43
46
  (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
44
47
  (0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
@@ -65,6 +68,8 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
65
68
  packPath: (0, common_1.getPackPath)(),
66
69
  }, {
67
70
  persistentCaching,
71
+ turbopackMemoryEviction,
72
+ smallPreallocation,
68
73
  // Build mode is a short-lived, one-shot compilation, so avoid paying
69
74
  // dependency graph bookkeeping cost unless the persistent cache needs it.
70
75
  dependencyTracking: persistentCaching,
package/cjs/core/hmr.js CHANGED
@@ -8,6 +8,7 @@ const ws_1 = require("ws");
8
8
  const HtmlPlugin_1 = require("../plugins/HtmlPlugin");
9
9
  const cleanOutput_1 = require("../utils/cleanOutput");
10
10
  const common_1 = require("../utils/common");
11
+ const env_1 = require("../utils/env");
11
12
  const getInitialAssets_1 = require("../utils/getInitialAssets");
12
13
  const htmlEntry_1 = require("../utils/htmlEntry");
13
14
  const lockfile_1 = require("../utils/lockfile");
@@ -63,6 +64,8 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
63
64
  await (0, cleanOutput_1.cleanOutput)(bundleOptions.config, resolvedProjectPath);
64
65
  const createProject = (0, project_1.projectFactory)();
65
66
  const persistentCaching = (_a = bundleOptions.config.persistentCaching) !== null && _a !== void 0 ? _a : true;
67
+ const turbopackMemoryEviction = (0, env_1.normalizeTurbopackMemoryEviction)(bundleOptions.config.turbopackMemoryEviction);
68
+ const smallPreallocation = (0, env_1.isTruthyEnv)(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
66
69
  const persistentCacheLock = await (0, lockfile_1.acquirePersistentCacheLock)(resolvedProjectPath, "utoo pack dev", persistentCaching);
67
70
  const htmlConfigs = [
68
71
  ...(Array.isArray(bundleOptions.config.html)
@@ -102,6 +105,8 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
102
105
  packPath: (0, common_1.getPackPath)(),
103
106
  }, {
104
107
  persistentCaching,
108
+ turbopackMemoryEviction,
109
+ smallPreallocation,
105
110
  });
106
111
  }
107
112
  catch (error) {
@@ -0,0 +1,2 @@
1
+ export declare function isTruthyEnv(value: string | undefined): boolean;
2
+ export declare function normalizeTurbopackMemoryEviction(value: boolean | "full" | undefined): "off" | "full";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTruthyEnv = isTruthyEnv;
4
+ exports.normalizeTurbopackMemoryEviction = normalizeTurbopackMemoryEviction;
5
+ function isTruthyEnv(value) {
6
+ return value === "1" || value === "true";
7
+ }
8
+ function normalizeTurbopackMemoryEviction(value) {
9
+ if (value === false) {
10
+ return "off";
11
+ }
12
+ if (value === true || value === "full") {
13
+ return "full";
14
+ }
15
+ const rawEnv = process.env.TURBO_ENGINE_EVICT_AFTER_SNAPSHOT;
16
+ return rawEnv == null || rawEnv === "1" || rawEnv === "true" ? "full" : "off";
17
+ }
@@ -222,6 +222,17 @@
222
222
  "string",
223
223
  "null"
224
224
  ]
225
+ },
226
+ "turbopackMemoryEviction": {
227
+ "description": "Turbopack memory eviction mode for the persistent cache",
228
+ "anyOf": [
229
+ {
230
+ "$ref": "#/definitions/SchemaTurbopackMemoryEviction"
231
+ },
232
+ {
233
+ "type": "null"
234
+ }
235
+ ]
225
236
  }
226
237
  },
227
238
  "definitions": {
@@ -1751,6 +1762,23 @@
1751
1762
  }
1752
1763
  ]
1753
1764
  },
1765
+ "SchemaTurbopackMemoryEviction": {
1766
+ "description": "Turbopack memory eviction mode.",
1767
+ "anyOf": [
1768
+ {
1769
+ "type": "boolean"
1770
+ },
1771
+ {
1772
+ "$ref": "#/definitions/SchemaTurbopackMemoryEvictionMode"
1773
+ }
1774
+ ]
1775
+ },
1776
+ "SchemaTurbopackMemoryEvictionMode": {
1777
+ "type": "string",
1778
+ "enum": [
1779
+ "full"
1780
+ ]
1781
+ },
1754
1782
  "SchemaTurbopackModuleType": {
1755
1783
  "description": "Module type for a module rule (`type` / `moduleType` field).\n\nValues must match pack-core / Turbopack's `ConfiguredModuleType::parse()`.",
1756
1784
  "type": "string",
package/esm/binding.d.ts CHANGED
@@ -125,6 +125,20 @@ export interface NapiTurboEngineOptions {
125
125
  dependencyTracking?: boolean
126
126
  /** Hint that this turbo-tasks instance is for a short-lived one-shot session. */
127
127
  isShortSession?: boolean
128
+ /** Turbopack memory eviction mode for the persistent cache. */
129
+ turbopackMemoryEviction?: MemoryEvictionMode
130
+ /** Avoid large backend preallocations to reduce startup memory. */
131
+ smallPreallocation?: boolean
132
+ }
133
+ /** Turbopack's memory eviction strategy for the persistent cache. */
134
+ export const enum MemoryEvictionMode {
135
+ /** Never evict. */
136
+ Off = "off",
137
+ /**
138
+ * After every snapshot, evict all evictable tasks from memory, reloading
139
+ * them from disk on demand.
140
+ */
141
+ Full = "full"
128
142
  }
129
143
  export declare function projectNew(options: NapiProjectOptions, turboEngineOptions: NapiTurboEngineOptions, napiCallbacks: NapiTurbopackCallbacksJsObject): Promise<{ __napiType: "Project" }>
130
144
  export declare function projectUpdate(project: { __napiType: "Project" }, options: NapiPartialProjectOptions): Promise<void>
@@ -8,6 +8,7 @@ import { projectFactory } from "../core/project.js";
8
8
  import { HtmlPlugin } from "../plugins/HtmlPlugin.js";
9
9
  import { cleanOutput, getOutputPath } from "../utils/cleanOutput.js";
10
10
  import { blockStdout, getPackPath } from "../utils/common.js";
11
+ import { isTruthyEnv, normalizeTurbopackMemoryEviction } from "../utils/env.js";
11
12
  import { findRootDir } from "../utils/findRoot.js";
12
13
  import { getInitialAssetsFromEndpointPaths } from "../utils/getInitialAssets.js";
13
14
  import { processHtmlEntry } from "../utils/htmlEntry.js";
@@ -33,6 +34,8 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
33
34
  const resolvedProjectPath = projectPath || process.cwd();
34
35
  const resolvedRootPath = rootPath || projectPath || process.cwd();
35
36
  const persistentCaching = (_a = bundleOptions.config.persistentCaching) !== null && _a !== void 0 ? _a : true;
37
+ const turbopackMemoryEviction = normalizeTurbopackMemoryEviction(bundleOptions.config.turbopackMemoryEviction);
38
+ const smallPreallocation = isTruthyEnv(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
36
39
  const shouldCreateWebpackStats = Boolean(process.env.ANALYZE) || Boolean(bundleOptions.config.stats);
37
40
  processHtmlEntry(bundleOptions.config, resolvedProjectPath);
38
41
  validateEntryPaths(bundleOptions.config, resolvedProjectPath);
@@ -59,6 +62,8 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
59
62
  packPath: getPackPath(),
60
63
  }, {
61
64
  persistentCaching,
65
+ turbopackMemoryEviction,
66
+ smallPreallocation,
62
67
  // Build mode is a short-lived, one-shot compilation, so avoid paying
63
68
  // dependency graph bookkeeping cost unless the persistent cache needs it.
64
69
  dependencyTracking: persistentCaching,
package/esm/core/hmr.js CHANGED
@@ -4,6 +4,7 @@ import { WebSocketServer } from "ws";
4
4
  import { HtmlPlugin } from "../plugins/HtmlPlugin.js";
5
5
  import { cleanOutput, getOutputPath } from "../utils/cleanOutput.js";
6
6
  import { debounce, getPackPath, processIssues } from "../utils/common.js";
7
+ import { isTruthyEnv, normalizeTurbopackMemoryEviction } from "../utils/env.js";
7
8
  import { getInitialAssetsFromEndpointPaths } from "../utils/getInitialAssets.js";
8
9
  import { processHtmlEntry } from "../utils/htmlEntry.js";
9
10
  import { acquirePersistentCacheLock } from "../utils/lockfile.js";
@@ -58,6 +59,8 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
58
59
  await cleanOutput(bundleOptions.config, resolvedProjectPath);
59
60
  const createProject = projectFactory();
60
61
  const persistentCaching = (_a = bundleOptions.config.persistentCaching) !== null && _a !== void 0 ? _a : true;
62
+ const turbopackMemoryEviction = normalizeTurbopackMemoryEviction(bundleOptions.config.turbopackMemoryEviction);
63
+ const smallPreallocation = isTruthyEnv(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
61
64
  const persistentCacheLock = await acquirePersistentCacheLock(resolvedProjectPath, "utoo pack dev", persistentCaching);
62
65
  const htmlConfigs = [
63
66
  ...(Array.isArray(bundleOptions.config.html)
@@ -97,6 +100,8 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
97
100
  packPath: getPackPath(),
98
101
  }, {
99
102
  persistentCaching,
103
+ turbopackMemoryEviction,
104
+ smallPreallocation,
100
105
  });
101
106
  }
102
107
  catch (error) {
@@ -0,0 +1,2 @@
1
+ export declare function isTruthyEnv(value: string | undefined): boolean;
2
+ export declare function normalizeTurbopackMemoryEviction(value: boolean | "full" | undefined): "off" | "full";
@@ -0,0 +1,13 @@
1
+ export function isTruthyEnv(value) {
2
+ return value === "1" || value === "true";
3
+ }
4
+ export function normalizeTurbopackMemoryEviction(value) {
5
+ if (value === false) {
6
+ return "off";
7
+ }
8
+ if (value === true || value === "full") {
9
+ return "full";
10
+ }
11
+ const rawEnv = process.env.TURBO_ENGINE_EVICT_AFTER_SNAPSHOT;
12
+ return rawEnv == null || rawEnv === "1" || rawEnv === "true" ? "full" : "off";
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "1.4.18-alpha.1",
3
+ "version": "1.4.18",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "@hono/node-server": "^1.19.11",
42
42
  "@hono/node-ws": "^1.3.0",
43
43
  "@swc/helpers": "0.5.15",
44
- "@utoo/pack-shared": "1.4.18-alpha.1",
44
+ "@utoo/pack-shared": "1.4.18",
45
45
  "domparser-rs": "^0.0.7",
46
46
  "find-up": "4.1.0",
47
47
  "get-port": "5.1.1",
@@ -96,12 +96,12 @@
96
96
  "directory": "packages/pack"
97
97
  },
98
98
  "optionalDependencies": {
99
- "@utoo/pack-darwin-arm64": "1.4.18-alpha.1",
100
- "@utoo/pack-darwin-x64": "1.4.18-alpha.1",
101
- "@utoo/pack-linux-arm64-gnu": "1.4.18-alpha.1",
102
- "@utoo/pack-linux-arm64-musl": "1.4.18-alpha.1",
103
- "@utoo/pack-linux-x64-gnu": "1.4.18-alpha.1",
104
- "@utoo/pack-linux-x64-musl": "1.4.18-alpha.1",
105
- "@utoo/pack-win32-x64-msvc": "1.4.18-alpha.1"
99
+ "@utoo/pack-darwin-arm64": "1.4.18",
100
+ "@utoo/pack-darwin-x64": "1.4.18",
101
+ "@utoo/pack-linux-arm64-gnu": "1.4.18",
102
+ "@utoo/pack-linux-arm64-musl": "1.4.18",
103
+ "@utoo/pack-linux-x64-gnu": "1.4.18",
104
+ "@utoo/pack-linux-x64-musl": "1.4.18",
105
+ "@utoo/pack-win32-x64-msvc": "1.4.18"
106
106
  }
107
107
  }