@utoo/pack 1.2.9 → 1.2.10-alpha.1
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/core/hmr.js +2 -2
- package/cjs/core/project.js +104 -1
- package/cjs/utils/common.d.ts +5 -0
- package/cjs/utils/common.js +5 -0
- package/cjs/utils/mkcert.js +2 -2
- package/esm/commands/build.js +10 -10
- package/esm/commands/dev.js +7 -7
- package/esm/config/webpackCompat.js +2 -2
- package/esm/core/hmr.js +9 -9
- package/esm/core/project.js +107 -4
- package/esm/index.js +6 -6
- package/esm/utils/common.d.ts +5 -0
- package/esm/utils/common.js +7 -0
- package/esm/utils/mkcert.js +1 -1
- package/package.json +10 -10
package/cjs/core/hmr.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.createHotReloader = createHotReloader;
|
|
|
8
8
|
const pack_shared_1 = require("@utoo/pack-shared");
|
|
9
9
|
const nanoid_1 = require("nanoid");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const ws_1 =
|
|
11
|
+
const ws_1 = require("ws");
|
|
12
12
|
const HtmlPlugin_1 = require("../plugins/HtmlPlugin");
|
|
13
13
|
const common_1 = require("../utils/common");
|
|
14
14
|
const getInitialAssets_1 = require("../utils/getInitialAssets");
|
|
@@ -16,7 +16,7 @@ const htmlEntry_1 = require("../utils/htmlEntry");
|
|
|
16
16
|
const normalize_path_1 = require("../utils/normalize-path");
|
|
17
17
|
const validateEntry_1 = require("../utils/validateEntry");
|
|
18
18
|
const project_1 = require("./project");
|
|
19
|
-
const wsServer = new ws_1.
|
|
19
|
+
const wsServer = new ws_1.WebSocketServer({ noServer: true });
|
|
20
20
|
const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
|
|
21
21
|
// Re-export HMR types from pack-shared for backward compatibility
|
|
22
22
|
var pack_shared_2 = require("@utoo/pack-shared");
|
package/cjs/core/project.js
CHANGED
|
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.TurbopackInternalError = void 0;
|
|
37
37
|
exports.projectFactory = projectFactory;
|
|
38
|
+
const path_1 = require("path");
|
|
39
|
+
const util_1 = require("util");
|
|
38
40
|
const binding = __importStar(require("../binding"));
|
|
39
41
|
const common_1 = require("../utils/common");
|
|
40
42
|
const loaderWorkerPool_1 = require("./loaderWorkerPool");
|
|
@@ -80,8 +82,109 @@ async function serializeConfig(config) {
|
|
|
80
82
|
]));
|
|
81
83
|
}
|
|
82
84
|
}
|
|
85
|
+
if (configSerializable.module && configSerializable.module.rules) {
|
|
86
|
+
configSerializable.module.rules = serializeModuleRules(configSerializable.module.rules);
|
|
87
|
+
}
|
|
83
88
|
return JSON.stringify(configSerializable, null, 2);
|
|
84
89
|
}
|
|
90
|
+
// converts regexes to a `RegexComponents` object so that it can be JSON-serialized when passed to
|
|
91
|
+
// Turbopack
|
|
92
|
+
function serializeRuleCondition(cond) {
|
|
93
|
+
function regexComponents(regex) {
|
|
94
|
+
return {
|
|
95
|
+
source: regex.source,
|
|
96
|
+
flags: regex.flags,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (typeof cond === "string") {
|
|
100
|
+
return cond;
|
|
101
|
+
}
|
|
102
|
+
else if ("all" in cond) {
|
|
103
|
+
return { ...cond, all: cond.all.map(serializeRuleCondition) };
|
|
104
|
+
}
|
|
105
|
+
else if ("any" in cond) {
|
|
106
|
+
return { ...cond, any: cond.any.map(serializeRuleCondition) };
|
|
107
|
+
}
|
|
108
|
+
else if ("not" in cond) {
|
|
109
|
+
return { ...cond, not: serializeRuleCondition(cond.not) };
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return {
|
|
113
|
+
...cond,
|
|
114
|
+
path: cond.path == null
|
|
115
|
+
? undefined
|
|
116
|
+
: cond.path instanceof RegExp
|
|
117
|
+
? {
|
|
118
|
+
type: "regex",
|
|
119
|
+
value: regexComponents(cond.path),
|
|
120
|
+
}
|
|
121
|
+
: { type: "glob", value: cond.path },
|
|
122
|
+
content: cond.content && regexComponents(cond.content),
|
|
123
|
+
query: cond.query == null
|
|
124
|
+
? undefined
|
|
125
|
+
: cond.query instanceof RegExp
|
|
126
|
+
? {
|
|
127
|
+
type: "regex",
|
|
128
|
+
value: regexComponents(cond.query),
|
|
129
|
+
}
|
|
130
|
+
: { type: "constant", value: cond.query },
|
|
131
|
+
contentType: cond.contentType == null
|
|
132
|
+
? undefined
|
|
133
|
+
: cond.contentType instanceof RegExp
|
|
134
|
+
? {
|
|
135
|
+
type: "regex",
|
|
136
|
+
value: regexComponents(cond.contentType),
|
|
137
|
+
}
|
|
138
|
+
: { type: "glob", value: cond.contentType },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Note: Returns an updated `turbopackRules` with serialized conditions. Does not mutate in-place.
|
|
143
|
+
function serializeModuleRules(turbopackRules) {
|
|
144
|
+
const serializedRules = {};
|
|
145
|
+
for (const [glob, rule] of Object.entries(turbopackRules)) {
|
|
146
|
+
if (Array.isArray(rule)) {
|
|
147
|
+
serializedRules[glob] = rule.map((item) => {
|
|
148
|
+
if (typeof item !== "string" &&
|
|
149
|
+
("loaders" in item || "type" in item || "condition" in item)) {
|
|
150
|
+
return serializeConfigItem(item, glob);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
checkLoaderItem(item, glob);
|
|
154
|
+
return item;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
serializedRules[glob] = serializeConfigItem(rule, glob);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return serializedRules;
|
|
163
|
+
function serializeConfigItem(rule, glob) {
|
|
164
|
+
if (!rule)
|
|
165
|
+
return rule;
|
|
166
|
+
if (rule.loaders) {
|
|
167
|
+
for (const item of rule.loaders) {
|
|
168
|
+
checkLoaderItem(item, glob);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
let serializedRule = rule;
|
|
172
|
+
if (rule.condition != null) {
|
|
173
|
+
serializedRule = {
|
|
174
|
+
...rule,
|
|
175
|
+
condition: serializeRuleCondition(rule.condition),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return serializedRule;
|
|
179
|
+
}
|
|
180
|
+
function checkLoaderItem(loaderItem, glob) {
|
|
181
|
+
if (typeof loaderItem !== "string" &&
|
|
182
|
+
!(0, util_1.isDeepStrictEqual)(loaderItem, JSON.parse(JSON.stringify(loaderItem)))) {
|
|
183
|
+
throw new Error(`loader ${loaderItem.loader} for match "${glob}" does not have serializable options. ` +
|
|
184
|
+
"Ensure that options passed are plain JavaScript objects and values.");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
85
188
|
async function rustifyPartialProjectOptions(options) {
|
|
86
189
|
return {
|
|
87
190
|
...options,
|
|
@@ -173,7 +276,7 @@ function projectFactory() {
|
|
|
173
276
|
constructor(nativeProject) {
|
|
174
277
|
this._nativeProject = nativeProject;
|
|
175
278
|
if (typeof binding.registerWorkerScheduler === "function") {
|
|
176
|
-
(0, loaderWorkerPool_1.runLoaderWorkerPool)(binding,
|
|
279
|
+
(0, loaderWorkerPool_1.runLoaderWorkerPool)(binding, (0, path_1.resolve)((0, common_1.getPackPath)(), "./binding.js"));
|
|
177
280
|
}
|
|
178
281
|
}
|
|
179
282
|
async update(options) {
|
package/cjs/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { createDefineEnv, debounce, isWellKnownError, ModuleBuildError, processIssues, rustifyEnv, } from "@utoo/pack-shared";
|
|
2
2
|
export declare function blockStdout(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Pack 根目录(pack 包所在目录)。
|
|
5
|
+
* - CJS:使用 __dirname。
|
|
6
|
+
* - ESM:在构建后由脚本注入 __dirname(基于 import.meta.url),此处仅用 __dirname 以保持 CJS 产物不含 import.meta,避免 Node 将 .js 判为 ESM。
|
|
7
|
+
*/
|
|
3
8
|
export declare function getPackPath(): string;
|
package/cjs/utils/common.js
CHANGED
|
@@ -27,6 +27,11 @@ function blockStdout() {
|
|
|
27
27
|
process.stderr._handle.setBlocking(true);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Pack 根目录(pack 包所在目录)。
|
|
32
|
+
* - CJS:使用 __dirname。
|
|
33
|
+
* - ESM:在构建后由脚本注入 __dirname(基于 import.meta.url),此处仅用 __dirname 以保持 CJS 产物不含 import.meta,避免 Node 将 .js 判为 ESM。
|
|
34
|
+
*/
|
|
30
35
|
function getPackPath() {
|
|
31
36
|
return path_1.default.resolve(__dirname, "..");
|
|
32
37
|
}
|
package/cjs/utils/mkcert.js
CHANGED
|
@@ -9,8 +9,8 @@ const node_child_process_1 = require("node:child_process");
|
|
|
9
9
|
const node_crypto_1 = require("node:crypto");
|
|
10
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const web_1 = require("node:stream/web");
|
|
12
13
|
const os_1 = __importDefault(require("os"));
|
|
13
|
-
const { WritableStream } = require("node:stream/web");
|
|
14
14
|
const MKCERT_VERSION = "v1.4.4";
|
|
15
15
|
function getBinaryName() {
|
|
16
16
|
const platform = process.platform;
|
|
@@ -43,7 +43,7 @@ async function downloadBinary() {
|
|
|
43
43
|
}
|
|
44
44
|
console.log(`Download response was successful, writing to disk`);
|
|
45
45
|
const binaryWriteStream = node_fs_1.default.createWriteStream(binaryPath);
|
|
46
|
-
await response.body.pipeTo(new WritableStream({
|
|
46
|
+
await response.body.pipeTo(new web_1.WritableStream({
|
|
47
47
|
write(chunk) {
|
|
48
48
|
return new Promise((resolve, reject) => {
|
|
49
49
|
binaryWriteStream.write(chunk, (error) => {
|
package/esm/commands/build.js
CHANGED
|
@@ -3,16 +3,16 @@ import { spawn } from "child_process";
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import { resolveBundleOptions } from "../config/webpackCompat";
|
|
7
|
-
import { projectFactory } from "../core/project";
|
|
8
|
-
import { HtmlPlugin } from "../plugins/HtmlPlugin";
|
|
9
|
-
import { blockStdout, createDefineEnv, getPackPath } from "../utils/common";
|
|
10
|
-
import { findRootDir } from "../utils/findRoot";
|
|
11
|
-
import { getInitialAssetsFromStats } from "../utils/getInitialAssets";
|
|
12
|
-
import { processHtmlEntry } from "../utils/htmlEntry";
|
|
13
|
-
import { normalizePath } from "../utils/normalize-path";
|
|
14
|
-
import { validateEntryPaths } from "../utils/validateEntry";
|
|
15
|
-
import { xcodeProfilingReady } from "../utils/xcodeProfile";
|
|
6
|
+
import { resolveBundleOptions } from "../config/webpackCompat.js";
|
|
7
|
+
import { projectFactory } from "../core/project.js";
|
|
8
|
+
import { HtmlPlugin } from "../plugins/HtmlPlugin.js";
|
|
9
|
+
import { blockStdout, createDefineEnv, getPackPath } from "../utils/common.js";
|
|
10
|
+
import { findRootDir } from "../utils/findRoot.js";
|
|
11
|
+
import { getInitialAssetsFromStats } from "../utils/getInitialAssets.js";
|
|
12
|
+
import { processHtmlEntry } from "../utils/htmlEntry.js";
|
|
13
|
+
import { normalizePath } from "../utils/normalize-path.js";
|
|
14
|
+
import { validateEntryPaths } from "../utils/validateEntry.js";
|
|
15
|
+
import { xcodeProfilingReady } from "../utils/xcodeProfile.js";
|
|
16
16
|
export function build(options, projectPath, rootPath) {
|
|
17
17
|
const bundleOptions = resolveBundleOptions(options, projectPath, rootPath);
|
|
18
18
|
if (!rootPath) {
|
package/esm/commands/dev.js
CHANGED
|
@@ -5,13 +5,13 @@ import { isIPv6 } from "net";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import send from "send";
|
|
7
7
|
import url from "url";
|
|
8
|
-
import { resolveBundleOptions } from "../config/webpackCompat";
|
|
9
|
-
import { createHotReloader } from "../core/hmr";
|
|
10
|
-
import { blockStdout, getPackPath } from "../utils/common";
|
|
11
|
-
import { findRootDir } from "../utils/findRoot";
|
|
12
|
-
import { createSelfSignedCertificate } from "../utils/mkcert";
|
|
13
|
-
import { printServerInfo } from "../utils/printServerInfo";
|
|
14
|
-
import { xcodeProfilingReady } from "../utils/xcodeProfile";
|
|
8
|
+
import { resolveBundleOptions } from "../config/webpackCompat.js";
|
|
9
|
+
import { createHotReloader } from "../core/hmr.js";
|
|
10
|
+
import { blockStdout, getPackPath } from "../utils/common.js";
|
|
11
|
+
import { findRootDir } from "../utils/findRoot.js";
|
|
12
|
+
import { createSelfSignedCertificate } from "../utils/mkcert.js";
|
|
13
|
+
import { printServerInfo } from "../utils/printServerInfo.js";
|
|
14
|
+
import { xcodeProfilingReady } from "../utils/xcodeProfile.js";
|
|
15
15
|
function parsePath(pathStr) {
|
|
16
16
|
const hashIndex = pathStr.indexOf("#");
|
|
17
17
|
const queryIndex = pathStr.indexOf("?");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compatOptionsFromWebpack, } from "@utoo/pack-shared";
|
|
2
|
-
import { readWebpackConfig } from "./readWebpackConfig";
|
|
2
|
+
import { readWebpackConfig } from "./readWebpackConfig.js";
|
|
3
3
|
export { compatOptionsFromWebpack, } from "@utoo/pack-shared";
|
|
4
|
-
export { readWebpackConfig } from "./readWebpackConfig";
|
|
4
|
+
export { readWebpackConfig } from "./readWebpackConfig.js";
|
|
5
5
|
export function resolveBundleOptions(options, projectPath, rootPath) {
|
|
6
6
|
if (options.webpackMode) {
|
|
7
7
|
let webpackConfig = options;
|
package/esm/core/hmr.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { HMR_ACTIONS_SENT_TO_BROWSER, } from "@utoo/pack-shared";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import
|
|
5
|
-
import { HtmlPlugin } from "../plugins/HtmlPlugin";
|
|
6
|
-
import { createDefineEnv, debounce, getPackPath, processIssues, } from "../utils/common";
|
|
7
|
-
import { getInitialAssetsFromStats } from "../utils/getInitialAssets";
|
|
8
|
-
import { processHtmlEntry } from "../utils/htmlEntry";
|
|
9
|
-
import { normalizePath } from "../utils/normalize-path";
|
|
10
|
-
import { validateEntryPaths } from "../utils/validateEntry";
|
|
11
|
-
import { projectFactory } from "./project";
|
|
12
|
-
const wsServer = new
|
|
4
|
+
import { WebSocketServer } from "ws";
|
|
5
|
+
import { HtmlPlugin } from "../plugins/HtmlPlugin.js";
|
|
6
|
+
import { createDefineEnv, debounce, getPackPath, processIssues, } from "../utils/common.js";
|
|
7
|
+
import { getInitialAssetsFromStats } from "../utils/getInitialAssets.js";
|
|
8
|
+
import { processHtmlEntry } from "../utils/htmlEntry.js";
|
|
9
|
+
import { normalizePath } from "../utils/normalize-path.js";
|
|
10
|
+
import { validateEntryPaths } from "../utils/validateEntry.js";
|
|
11
|
+
import { projectFactory } from "./project.js";
|
|
12
|
+
const wsServer = new WebSocketServer({ noServer: true });
|
|
13
13
|
const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
|
|
14
14
|
// Re-export HMR types from pack-shared for backward compatibility
|
|
15
15
|
export { HMR_ACTIONS_SENT_TO_BROWSER, } from "@utoo/pack-shared";
|
package/esm/core/project.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { isDeepStrictEqual } from "util";
|
|
3
|
+
import * as binding from "../binding.js";
|
|
4
|
+
import { getPackPath, rustifyEnv } from "../utils/common.js";
|
|
5
|
+
import { runLoaderWorkerPool } from "./loaderWorkerPool.js";
|
|
4
6
|
export class TurbopackInternalError extends Error {
|
|
5
7
|
constructor(cause) {
|
|
6
8
|
super(cause.message);
|
|
@@ -42,8 +44,109 @@ async function serializeConfig(config) {
|
|
|
42
44
|
]));
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
if (configSerializable.module && configSerializable.module.rules) {
|
|
48
|
+
configSerializable.module.rules = serializeModuleRules(configSerializable.module.rules);
|
|
49
|
+
}
|
|
45
50
|
return JSON.stringify(configSerializable, null, 2);
|
|
46
51
|
}
|
|
52
|
+
// converts regexes to a `RegexComponents` object so that it can be JSON-serialized when passed to
|
|
53
|
+
// Turbopack
|
|
54
|
+
function serializeRuleCondition(cond) {
|
|
55
|
+
function regexComponents(regex) {
|
|
56
|
+
return {
|
|
57
|
+
source: regex.source,
|
|
58
|
+
flags: regex.flags,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (typeof cond === "string") {
|
|
62
|
+
return cond;
|
|
63
|
+
}
|
|
64
|
+
else if ("all" in cond) {
|
|
65
|
+
return { ...cond, all: cond.all.map(serializeRuleCondition) };
|
|
66
|
+
}
|
|
67
|
+
else if ("any" in cond) {
|
|
68
|
+
return { ...cond, any: cond.any.map(serializeRuleCondition) };
|
|
69
|
+
}
|
|
70
|
+
else if ("not" in cond) {
|
|
71
|
+
return { ...cond, not: serializeRuleCondition(cond.not) };
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return {
|
|
75
|
+
...cond,
|
|
76
|
+
path: cond.path == null
|
|
77
|
+
? undefined
|
|
78
|
+
: cond.path instanceof RegExp
|
|
79
|
+
? {
|
|
80
|
+
type: "regex",
|
|
81
|
+
value: regexComponents(cond.path),
|
|
82
|
+
}
|
|
83
|
+
: { type: "glob", value: cond.path },
|
|
84
|
+
content: cond.content && regexComponents(cond.content),
|
|
85
|
+
query: cond.query == null
|
|
86
|
+
? undefined
|
|
87
|
+
: cond.query instanceof RegExp
|
|
88
|
+
? {
|
|
89
|
+
type: "regex",
|
|
90
|
+
value: regexComponents(cond.query),
|
|
91
|
+
}
|
|
92
|
+
: { type: "constant", value: cond.query },
|
|
93
|
+
contentType: cond.contentType == null
|
|
94
|
+
? undefined
|
|
95
|
+
: cond.contentType instanceof RegExp
|
|
96
|
+
? {
|
|
97
|
+
type: "regex",
|
|
98
|
+
value: regexComponents(cond.contentType),
|
|
99
|
+
}
|
|
100
|
+
: { type: "glob", value: cond.contentType },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Note: Returns an updated `turbopackRules` with serialized conditions. Does not mutate in-place.
|
|
105
|
+
function serializeModuleRules(turbopackRules) {
|
|
106
|
+
const serializedRules = {};
|
|
107
|
+
for (const [glob, rule] of Object.entries(turbopackRules)) {
|
|
108
|
+
if (Array.isArray(rule)) {
|
|
109
|
+
serializedRules[glob] = rule.map((item) => {
|
|
110
|
+
if (typeof item !== "string" &&
|
|
111
|
+
("loaders" in item || "type" in item || "condition" in item)) {
|
|
112
|
+
return serializeConfigItem(item, glob);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
checkLoaderItem(item, glob);
|
|
116
|
+
return item;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
serializedRules[glob] = serializeConfigItem(rule, glob);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return serializedRules;
|
|
125
|
+
function serializeConfigItem(rule, glob) {
|
|
126
|
+
if (!rule)
|
|
127
|
+
return rule;
|
|
128
|
+
if (rule.loaders) {
|
|
129
|
+
for (const item of rule.loaders) {
|
|
130
|
+
checkLoaderItem(item, glob);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
let serializedRule = rule;
|
|
134
|
+
if (rule.condition != null) {
|
|
135
|
+
serializedRule = {
|
|
136
|
+
...rule,
|
|
137
|
+
condition: serializeRuleCondition(rule.condition),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return serializedRule;
|
|
141
|
+
}
|
|
142
|
+
function checkLoaderItem(loaderItem, glob) {
|
|
143
|
+
if (typeof loaderItem !== "string" &&
|
|
144
|
+
!isDeepStrictEqual(loaderItem, JSON.parse(JSON.stringify(loaderItem)))) {
|
|
145
|
+
throw new Error(`loader ${loaderItem.loader} for match "${glob}" does not have serializable options. ` +
|
|
146
|
+
"Ensure that options passed are plain JavaScript objects and values.");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
47
150
|
async function rustifyPartialProjectOptions(options) {
|
|
48
151
|
return {
|
|
49
152
|
...options,
|
|
@@ -135,7 +238,7 @@ export function projectFactory() {
|
|
|
135
238
|
constructor(nativeProject) {
|
|
136
239
|
this._nativeProject = nativeProject;
|
|
137
240
|
if (typeof binding.registerWorkerScheduler === "function") {
|
|
138
|
-
runLoaderWorkerPool(binding,
|
|
241
|
+
runLoaderWorkerPool(binding, resolve(getPackPath(), "./binding.js"));
|
|
139
242
|
}
|
|
140
243
|
}
|
|
141
244
|
async update(options) {
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { build } from "./commands/build";
|
|
2
|
-
import { serve } from "./commands/dev";
|
|
1
|
+
import { build } from "./commands/build.js";
|
|
2
|
+
import { serve } from "./commands/dev.js";
|
|
3
3
|
export { build };
|
|
4
4
|
export { serve };
|
|
5
5
|
const utoopack = { build, serve };
|
|
6
6
|
export default utoopack;
|
|
7
|
-
export * from "./config/types";
|
|
8
|
-
export * from "./config/webpackCompat";
|
|
9
|
-
export * from "./core/types";
|
|
10
|
-
export * from "./utils/findRoot";
|
|
7
|
+
export * from "./config/types.js";
|
|
8
|
+
export * from "./config/webpackCompat.js";
|
|
9
|
+
export * from "./core/types.js";
|
|
10
|
+
export * from "./utils/findRoot.js";
|
package/esm/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { createDefineEnv, debounce, isWellKnownError, ModuleBuildError, processIssues, rustifyEnv, } from "@utoo/pack-shared";
|
|
2
2
|
export declare function blockStdout(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Pack 根目录(pack 包所在目录)。
|
|
5
|
+
* - CJS:使用 __dirname。
|
|
6
|
+
* - ESM:在构建后由脚本注入 __dirname(基于 import.meta.url),此处仅用 __dirname 以保持 CJS 产物不含 import.meta,避免 Node 将 .js 判为 ESM。
|
|
7
|
+
*/
|
|
3
8
|
export declare function getPackPath(): string;
|
package/esm/utils/common.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
2
4
|
export { createDefineEnv, debounce, isWellKnownError, ModuleBuildError, processIssues, rustifyEnv, } from "@utoo/pack-shared";
|
|
3
5
|
// ref:
|
|
4
6
|
// https://github.com/vercel/next.js/pull/51883
|
|
@@ -13,6 +15,11 @@ export function blockStdout() {
|
|
|
13
15
|
process.stderr._handle.setBlocking(true);
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Pack 根目录(pack 包所在目录)。
|
|
20
|
+
* - CJS:使用 __dirname。
|
|
21
|
+
* - ESM:在构建后由脚本注入 __dirname(基于 import.meta.url),此处仅用 __dirname 以保持 CJS 产物不含 import.meta,避免 Node 将 .js 判为 ESM。
|
|
22
|
+
*/
|
|
16
23
|
export function getPackPath() {
|
|
17
24
|
return path.resolve(__dirname, "..");
|
|
18
25
|
}
|
package/esm/utils/mkcert.js
CHANGED
|
@@ -2,8 +2,8 @@ import { execSync } from "node:child_process";
|
|
|
2
2
|
import { createPrivateKey, X509Certificate } from "node:crypto";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { WritableStream } from "node:stream/web";
|
|
5
6
|
import os from "os";
|
|
6
|
-
const { WritableStream } = require("node:stream/web");
|
|
7
7
|
const MKCERT_VERSION = "v1.4.4";
|
|
8
8
|
function getBinaryName() {
|
|
9
9
|
const platform = process.platform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10-alpha.1",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "esm/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/code-frame": "7.22.5",
|
|
41
41
|
"@swc/helpers": "0.5.15",
|
|
42
|
-
"@utoo/pack-shared": "1.2.
|
|
42
|
+
"@utoo/pack-shared": "1.2.10-alpha.1",
|
|
43
43
|
"@utoo/style-loader": "^1.0.0",
|
|
44
44
|
"domparser-rs": "^0.0.7",
|
|
45
45
|
"find-up": "4.1.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"build": "npm run build:binding && npm run build:cjs && npm run build:esm",
|
|
75
75
|
"build:js": "npm run build:cjs && npm run build:esm",
|
|
76
76
|
"build:cjs": "rm -rf cjs && tsc -p ./tsconfig.json --module commonjs --outDir cjs && cp src/*.d.ts cjs/",
|
|
77
|
-
"build:esm": "rm -rf esm && tsc -p ./tsconfig.json --module esnext --outDir esm && cp src/*.d.ts esm/",
|
|
77
|
+
"build:esm": "rm -rf esm && tsc -p ./tsconfig.json --module esnext --outDir esm && cp src/*.d.ts esm/ && node ../../scripts/add-esm-extensions.cjs && node scripts/inject-esm-dirname.cjs",
|
|
78
78
|
"build:local": "npm run build:binding:local && npx turbo run build --filter=@utoo/pack-shared && npm run build:cjs && npm run build:esm && cp src/*.node cjs/ && cp src/*.node esm/",
|
|
79
79
|
"artifacts": "napi artifacts --dir ./src --dist npm",
|
|
80
80
|
"build:binding": "napi build src --platform --release -p pack-napi --cargo-cwd ../../ --cargo-name pack_napi --features plugin --js binding.js --dts binding.d.ts",
|
|
@@ -86,12 +86,12 @@
|
|
|
86
86
|
},
|
|
87
87
|
"repository": "git@github.com:utooland/utoo.git",
|
|
88
88
|
"optionalDependencies": {
|
|
89
|
-
"@utoo/pack-darwin-arm64": "1.2.
|
|
90
|
-
"@utoo/pack-darwin-x64": "1.2.
|
|
91
|
-
"@utoo/pack-linux-arm64-gnu": "1.2.
|
|
92
|
-
"@utoo/pack-linux-arm64-musl": "1.2.
|
|
93
|
-
"@utoo/pack-linux-x64-gnu": "1.2.
|
|
94
|
-
"@utoo/pack-linux-x64-musl": "1.2.
|
|
95
|
-
"@utoo/pack-win32-x64-msvc": "1.2.
|
|
89
|
+
"@utoo/pack-darwin-arm64": "1.2.10-alpha.1",
|
|
90
|
+
"@utoo/pack-darwin-x64": "1.2.10-alpha.1",
|
|
91
|
+
"@utoo/pack-linux-arm64-gnu": "1.2.10-alpha.1",
|
|
92
|
+
"@utoo/pack-linux-arm64-musl": "1.2.10-alpha.1",
|
|
93
|
+
"@utoo/pack-linux-x64-gnu": "1.2.10-alpha.1",
|
|
94
|
+
"@utoo/pack-linux-x64-musl": "1.2.10-alpha.1",
|
|
95
|
+
"@utoo/pack-win32-x64-msvc": "1.2.10-alpha.1"
|
|
96
96
|
}
|
|
97
97
|
}
|