@utoo/pack 1.4.18-alpha.0 → 1.4.18-alpha.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.
package/cjs/binding.d.ts CHANGED
@@ -27,7 +27,7 @@ export interface NapiTaskMessage {
27
27
  data: Buffer
28
28
  }
29
29
  export declare function recvTaskMessageInWorker(workerId: number): Promise<NapiTaskMessage>
30
- export declare function sendTaskMessage(message: NapiTaskMessage): Promise<void>
30
+ export declare function sendTaskMessage(message: NapiTaskMessage): void
31
31
  export declare function lockfileTryAcquireSync(path: string, content?: string | undefined | null): { __napiType: "Lockfile" } | null
32
32
  export declare function lockfileTryAcquire(path: string, content?: string | undefined | null): Promise<{ __napiType: "Lockfile" } | null>
33
33
  export declare function lockfileUnlockSync(lockfile: { __napiType: "Lockfile" }): void
@@ -127,6 +127,8 @@ export interface NapiTurboEngineOptions {
127
127
  isShortSession?: boolean
128
128
  /** Turbopack memory eviction mode for the persistent cache. */
129
129
  turbopackMemoryEviction?: MemoryEvictionMode
130
+ /** Avoid large backend preallocations to reduce startup memory. */
131
+ smallPreallocation?: boolean
130
132
  }
131
133
  /** Turbopack's memory eviction strategy for the persistent cache. */
132
134
  export const enum MemoryEvictionMode {
@@ -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,7 +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;
42
- const turbopackMemoryEviction = (bundleOptions.config.turbopackMemoryEviction === false ? "off" : "full");
43
+ const turbopackMemoryEviction = (0, env_1.normalizeTurbopackMemoryEviction)(bundleOptions.config.turbopackMemoryEviction);
44
+ const smallPreallocation = (0, env_1.isTruthyEnv)(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
43
45
  const shouldCreateWebpackStats = Boolean(process.env.ANALYZE) || Boolean(bundleOptions.config.stats);
44
46
  (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
45
47
  (0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
@@ -67,6 +69,7 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
67
69
  }, {
68
70
  persistentCaching,
69
71
  turbopackMemoryEviction,
72
+ smallPreallocation,
70
73
  // Build mode is a short-lived, one-shot compilation, so avoid paying
71
74
  // dependency graph bookkeeping cost unless the persistent cache needs it.
72
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,7 +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;
66
- const turbopackMemoryEviction = (bundleOptions.config.turbopackMemoryEviction === false ? "off" : "full");
67
+ const turbopackMemoryEviction = (0, env_1.normalizeTurbopackMemoryEviction)(bundleOptions.config.turbopackMemoryEviction);
68
+ const smallPreallocation = (0, env_1.isTruthyEnv)(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
67
69
  const persistentCacheLock = await (0, lockfile_1.acquirePersistentCacheLock)(resolvedProjectPath, "utoo pack dev", persistentCaching);
68
70
  const htmlConfigs = [
69
71
  ...(Array.isArray(bundleOptions.config.html)
@@ -104,6 +106,7 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
104
106
  }, {
105
107
  persistentCaching,
106
108
  turbopackMemoryEviction,
109
+ smallPreallocation,
107
110
  });
108
111
  }
109
112
  catch (error) {
@@ -0,0 +1,2 @@
1
+ export declare function isTruthyEnv(value: string | undefined): boolean;
2
+ export declare function normalizeTurbopackMemoryEviction(value: false | "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 === "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
+ }
package/esm/binding.d.ts CHANGED
@@ -27,7 +27,7 @@ export interface NapiTaskMessage {
27
27
  data: Buffer
28
28
  }
29
29
  export declare function recvTaskMessageInWorker(workerId: number): Promise<NapiTaskMessage>
30
- export declare function sendTaskMessage(message: NapiTaskMessage): Promise<void>
30
+ export declare function sendTaskMessage(message: NapiTaskMessage): void
31
31
  export declare function lockfileTryAcquireSync(path: string, content?: string | undefined | null): { __napiType: "Lockfile" } | null
32
32
  export declare function lockfileTryAcquire(path: string, content?: string | undefined | null): Promise<{ __napiType: "Lockfile" } | null>
33
33
  export declare function lockfileUnlockSync(lockfile: { __napiType: "Lockfile" }): void
@@ -127,6 +127,8 @@ export interface NapiTurboEngineOptions {
127
127
  isShortSession?: boolean
128
128
  /** Turbopack memory eviction mode for the persistent cache. */
129
129
  turbopackMemoryEviction?: MemoryEvictionMode
130
+ /** Avoid large backend preallocations to reduce startup memory. */
131
+ smallPreallocation?: boolean
130
132
  }
131
133
  /** Turbopack's memory eviction strategy for the persistent cache. */
132
134
  export const enum MemoryEvictionMode {
@@ -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,7 +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;
36
- const turbopackMemoryEviction = (bundleOptions.config.turbopackMemoryEviction === false ? "off" : "full");
37
+ const turbopackMemoryEviction = normalizeTurbopackMemoryEviction(bundleOptions.config.turbopackMemoryEviction);
38
+ const smallPreallocation = isTruthyEnv(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
37
39
  const shouldCreateWebpackStats = Boolean(process.env.ANALYZE) || Boolean(bundleOptions.config.stats);
38
40
  processHtmlEntry(bundleOptions.config, resolvedProjectPath);
39
41
  validateEntryPaths(bundleOptions.config, resolvedProjectPath);
@@ -61,6 +63,7 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
61
63
  }, {
62
64
  persistentCaching,
63
65
  turbopackMemoryEviction,
66
+ smallPreallocation,
64
67
  // Build mode is a short-lived, one-shot compilation, so avoid paying
65
68
  // dependency graph bookkeeping cost unless the persistent cache needs it.
66
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,7 +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;
61
- const turbopackMemoryEviction = (bundleOptions.config.turbopackMemoryEviction === false ? "off" : "full");
62
+ const turbopackMemoryEviction = normalizeTurbopackMemoryEviction(bundleOptions.config.turbopackMemoryEviction);
63
+ const smallPreallocation = isTruthyEnv(process.env.UTOO_TURBOPACK_SMALL_PREALLOCATION);
62
64
  const persistentCacheLock = await acquirePersistentCacheLock(resolvedProjectPath, "utoo pack dev", persistentCaching);
63
65
  const htmlConfigs = [
64
66
  ...(Array.isArray(bundleOptions.config.html)
@@ -99,6 +101,7 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
99
101
  }, {
100
102
  persistentCaching,
101
103
  turbopackMemoryEviction,
104
+ smallPreallocation,
102
105
  });
103
106
  }
104
107
  catch (error) {
@@ -0,0 +1,2 @@
1
+ export declare function isTruthyEnv(value: string | undefined): boolean;
2
+ export declare function normalizeTurbopackMemoryEviction(value: false | "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 === "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.0",
3
+ "version": "1.4.18-alpha.2",
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.0",
44
+ "@utoo/pack-shared": "1.4.18-alpha.2",
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.0",
100
- "@utoo/pack-darwin-x64": "1.4.18-alpha.0",
101
- "@utoo/pack-linux-arm64-gnu": "1.4.18-alpha.0",
102
- "@utoo/pack-linux-arm64-musl": "1.4.18-alpha.0",
103
- "@utoo/pack-linux-x64-gnu": "1.4.18-alpha.0",
104
- "@utoo/pack-linux-x64-musl": "1.4.18-alpha.0",
105
- "@utoo/pack-win32-x64-msvc": "1.4.18-alpha.0"
99
+ "@utoo/pack-darwin-arm64": "1.4.18-alpha.2",
100
+ "@utoo/pack-darwin-x64": "1.4.18-alpha.2",
101
+ "@utoo/pack-linux-arm64-gnu": "1.4.18-alpha.2",
102
+ "@utoo/pack-linux-arm64-musl": "1.4.18-alpha.2",
103
+ "@utoo/pack-linux-x64-gnu": "1.4.18-alpha.2",
104
+ "@utoo/pack-linux-x64-musl": "1.4.18-alpha.2",
105
+ "@utoo/pack-win32-x64-msvc": "1.4.18-alpha.2"
106
106
  }
107
107
  }