@utoo/pack 1.3.9-alpha.2 → 1.3.9-alpha.4
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/project.d.ts +2 -0
- package/cjs/core/project.js +27 -4
- package/config_schema.json +59 -4
- package/esm/core/project.d.ts +2 -0
- package/esm/core/project.js +26 -4
- package/package.json +9 -9
package/cjs/core/project.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HmrIdentifiers, NapiUpdateMessage, NapiWrittenEndpoint, StackFrame, TurbopackInternalErrorOpts } from "../binding";
|
|
2
2
|
import * as binding from "../binding";
|
|
3
|
+
import { ConfigComplete } from "../config/types";
|
|
3
4
|
import { ProjectOptions, RawEntrypoints, Update } from "./types";
|
|
4
5
|
/**
|
|
5
6
|
* An error caused by a bug in Turbopack, and not the user's code (e.g. a Rust panic). These should
|
|
@@ -12,6 +13,7 @@ export declare class TurbopackInternalError extends Error {
|
|
|
12
13
|
location: string | undefined;
|
|
13
14
|
constructor({ message, anonymizedLocation }: TurbopackInternalErrorOpts);
|
|
14
15
|
}
|
|
16
|
+
export declare function serializeConfig(config: ConfigComplete, isDev: boolean): Promise<string>;
|
|
15
17
|
export declare function projectFactory(): (options: Required<ProjectOptions>, turboEngineOptions: binding.NapiTurboEngineOptions) => Promise<{
|
|
16
18
|
readonly _nativeProject: {
|
|
17
19
|
__napiType: "Project";
|
package/cjs/core/project.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.TurbopackInternalError = void 0;
|
|
37
|
+
exports.serializeConfig = serializeConfig;
|
|
37
38
|
exports.projectFactory = projectFactory;
|
|
38
39
|
const path_1 = require("path");
|
|
39
40
|
const util_1 = require("util");
|
|
@@ -75,8 +76,30 @@ async function withErrorCause(fn) {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
function normalizeEmotionConfig(emotion, isDev) {
|
|
80
|
+
if (emotion === undefined) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const defaults = {
|
|
84
|
+
sourcemap: isDev,
|
|
85
|
+
autoLabel: isDev ? "always" : "never",
|
|
86
|
+
};
|
|
87
|
+
return emotion === true ? defaults : { ...defaults, ...emotion };
|
|
88
|
+
}
|
|
89
|
+
function normalizeStyles(styles, isDev) {
|
|
90
|
+
if (!styles) {
|
|
91
|
+
return styles;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
...styles,
|
|
95
|
+
emotion: normalizeEmotionConfig(styles.emotion, isDev),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function serializeConfig(config, isDev) {
|
|
99
|
+
const configSerializable = {
|
|
100
|
+
...config,
|
|
101
|
+
styles: normalizeStyles(config.styles, isDev),
|
|
102
|
+
};
|
|
80
103
|
if (configSerializable.entry) {
|
|
81
104
|
configSerializable.entry = configSerializable.entry.map((entry) => {
|
|
82
105
|
const { html, ...rest } = entry;
|
|
@@ -210,7 +233,7 @@ async function rustifyPartialProjectOptions(options) {
|
|
|
210
233
|
rootPath: normalizePathOption(options.rootPath),
|
|
211
234
|
projectPath: normalizePathOption(options.projectPath),
|
|
212
235
|
packPath: normalizePathOption(options.packPath),
|
|
213
|
-
config: options.config && (await serializeConfig(options.config)),
|
|
236
|
+
config: options.config && (await serializeConfig(options.config, !!options.dev)),
|
|
214
237
|
processEnv: options.processEnv && (0, common_1.rustifyEnv)(options.processEnv),
|
|
215
238
|
};
|
|
216
239
|
}
|
|
@@ -226,7 +249,7 @@ async function rustifyProjectOptions(options) {
|
|
|
226
249
|
rootPath: (0, normalize_path_1.normalizePath)(options.rootPath),
|
|
227
250
|
projectPath: (0, normalize_path_1.normalizePath)(options.projectPath),
|
|
228
251
|
packPath: (0, normalize_path_1.normalizePath)(options.packPath),
|
|
229
|
-
config: await serializeConfig(options.config),
|
|
252
|
+
config: await serializeConfig(options.config, options.dev),
|
|
230
253
|
processEnv: (0, common_1.rustifyEnv)((_a = options.processEnv) !== null && _a !== void 0 ? _a : {}),
|
|
231
254
|
};
|
|
232
255
|
}
|
package/config_schema.json
CHANGED
|
@@ -532,6 +532,57 @@
|
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
},
|
|
535
|
+
"SchemaEmotionConfig": {
|
|
536
|
+
"type": "object",
|
|
537
|
+
"properties": {
|
|
538
|
+
"autoLabel": {
|
|
539
|
+
"description": "Emotion auto label strategy",
|
|
540
|
+
"anyOf": [
|
|
541
|
+
{
|
|
542
|
+
"$ref": "#/definitions/SchemaEmotionLabelKind"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"type": "null"
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
},
|
|
549
|
+
"importMap": {
|
|
550
|
+
"description": "Emotion import map configuration"
|
|
551
|
+
},
|
|
552
|
+
"labelFormat": {
|
|
553
|
+
"description": "Emotion label format",
|
|
554
|
+
"type": [
|
|
555
|
+
"string",
|
|
556
|
+
"null"
|
|
557
|
+
]
|
|
558
|
+
},
|
|
559
|
+
"sourcemap": {
|
|
560
|
+
"description": "Enable source maps in Emotion transform",
|
|
561
|
+
"type": [
|
|
562
|
+
"boolean",
|
|
563
|
+
"null"
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
"SchemaEmotionConfigOrBoolean": {
|
|
569
|
+
"anyOf": [
|
|
570
|
+
{
|
|
571
|
+
"type": "boolean"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"$ref": "#/definitions/SchemaEmotionConfig"
|
|
575
|
+
}
|
|
576
|
+
]
|
|
577
|
+
},
|
|
578
|
+
"SchemaEmotionLabelKind": {
|
|
579
|
+
"type": "string",
|
|
580
|
+
"enum": [
|
|
581
|
+
"dev-only",
|
|
582
|
+
"always",
|
|
583
|
+
"never"
|
|
584
|
+
]
|
|
585
|
+
},
|
|
535
586
|
"SchemaEntryOptions": {
|
|
536
587
|
"description": "Entry point configuration",
|
|
537
588
|
"type": "object",
|
|
@@ -1403,10 +1454,14 @@
|
|
|
1403
1454
|
]
|
|
1404
1455
|
},
|
|
1405
1456
|
"emotion": {
|
|
1406
|
-
"description": "Enable @emotion/react transform support",
|
|
1407
|
-
"
|
|
1408
|
-
|
|
1409
|
-
|
|
1457
|
+
"description": "Enable @emotion/react transform support with boolean or options",
|
|
1458
|
+
"anyOf": [
|
|
1459
|
+
{
|
|
1460
|
+
"$ref": "#/definitions/SchemaEmotionConfigOrBoolean"
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
"type": "null"
|
|
1464
|
+
}
|
|
1410
1465
|
]
|
|
1411
1466
|
},
|
|
1412
1467
|
"inlineCss": {
|
package/esm/core/project.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HmrIdentifiers, NapiUpdateMessage, NapiWrittenEndpoint, StackFrame, TurbopackInternalErrorOpts } from "../binding";
|
|
2
2
|
import * as binding from "../binding";
|
|
3
|
+
import { ConfigComplete } from "../config/types";
|
|
3
4
|
import { ProjectOptions, RawEntrypoints, Update } from "./types";
|
|
4
5
|
/**
|
|
5
6
|
* An error caused by a bug in Turbopack, and not the user's code (e.g. a Rust panic). These should
|
|
@@ -12,6 +13,7 @@ export declare class TurbopackInternalError extends Error {
|
|
|
12
13
|
location: string | undefined;
|
|
13
14
|
constructor({ message, anonymizedLocation }: TurbopackInternalErrorOpts);
|
|
14
15
|
}
|
|
16
|
+
export declare function serializeConfig(config: ConfigComplete, isDev: boolean): Promise<string>;
|
|
15
17
|
export declare function projectFactory(): (options: Required<ProjectOptions>, turboEngineOptions: binding.NapiTurboEngineOptions) => Promise<{
|
|
16
18
|
readonly _nativeProject: {
|
|
17
19
|
__napiType: "Project";
|
package/esm/core/project.js
CHANGED
|
@@ -37,8 +37,30 @@ async function withErrorCause(fn) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
function normalizeEmotionConfig(emotion, isDev) {
|
|
41
|
+
if (emotion === undefined) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const defaults = {
|
|
45
|
+
sourcemap: isDev,
|
|
46
|
+
autoLabel: isDev ? "always" : "never",
|
|
47
|
+
};
|
|
48
|
+
return emotion === true ? defaults : { ...defaults, ...emotion };
|
|
49
|
+
}
|
|
50
|
+
function normalizeStyles(styles, isDev) {
|
|
51
|
+
if (!styles) {
|
|
52
|
+
return styles;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...styles,
|
|
56
|
+
emotion: normalizeEmotionConfig(styles.emotion, isDev),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export async function serializeConfig(config, isDev) {
|
|
60
|
+
const configSerializable = {
|
|
61
|
+
...config,
|
|
62
|
+
styles: normalizeStyles(config.styles, isDev),
|
|
63
|
+
};
|
|
42
64
|
if (configSerializable.entry) {
|
|
43
65
|
configSerializable.entry = configSerializable.entry.map((entry) => {
|
|
44
66
|
const { html, ...rest } = entry;
|
|
@@ -172,7 +194,7 @@ async function rustifyPartialProjectOptions(options) {
|
|
|
172
194
|
rootPath: normalizePathOption(options.rootPath),
|
|
173
195
|
projectPath: normalizePathOption(options.projectPath),
|
|
174
196
|
packPath: normalizePathOption(options.packPath),
|
|
175
|
-
config: options.config && (await serializeConfig(options.config)),
|
|
197
|
+
config: options.config && (await serializeConfig(options.config, !!options.dev)),
|
|
176
198
|
processEnv: options.processEnv && rustifyEnv(options.processEnv),
|
|
177
199
|
};
|
|
178
200
|
}
|
|
@@ -188,7 +210,7 @@ async function rustifyProjectOptions(options) {
|
|
|
188
210
|
rootPath: normalizePath(options.rootPath),
|
|
189
211
|
projectPath: normalizePath(options.projectPath),
|
|
190
212
|
packPath: normalizePath(options.packPath),
|
|
191
|
-
config: await serializeConfig(options.config),
|
|
213
|
+
config: await serializeConfig(options.config, options.dev),
|
|
192
214
|
processEnv: rustifyEnv((_a = options.processEnv) !== null && _a !== void 0 ? _a : {}),
|
|
193
215
|
};
|
|
194
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "1.3.9-alpha.
|
|
3
|
+
"version": "1.3.9-alpha.4",
|
|
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.3.9-alpha.
|
|
44
|
+
"@utoo/pack-shared": "1.3.9-alpha.4",
|
|
45
45
|
"domparser-rs": "^0.0.7",
|
|
46
46
|
"find-up": "4.1.0",
|
|
47
47
|
"get-port": "^7.1.0",
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
},
|
|
93
93
|
"repository": "git@github.com:utooland/utoo.git",
|
|
94
94
|
"optionalDependencies": {
|
|
95
|
-
"@utoo/pack-darwin-arm64": "1.3.9-alpha.
|
|
96
|
-
"@utoo/pack-darwin-x64": "1.3.9-alpha.
|
|
97
|
-
"@utoo/pack-linux-arm64-gnu": "1.3.9-alpha.
|
|
98
|
-
"@utoo/pack-linux-arm64-musl": "1.3.9-alpha.
|
|
99
|
-
"@utoo/pack-linux-x64-gnu": "1.3.9-alpha.
|
|
100
|
-
"@utoo/pack-linux-x64-musl": "1.3.9-alpha.
|
|
101
|
-
"@utoo/pack-win32-x64-msvc": "1.3.9-alpha.
|
|
95
|
+
"@utoo/pack-darwin-arm64": "1.3.9-alpha.4",
|
|
96
|
+
"@utoo/pack-darwin-x64": "1.3.9-alpha.4",
|
|
97
|
+
"@utoo/pack-linux-arm64-gnu": "1.3.9-alpha.4",
|
|
98
|
+
"@utoo/pack-linux-arm64-musl": "1.3.9-alpha.4",
|
|
99
|
+
"@utoo/pack-linux-x64-gnu": "1.3.9-alpha.4",
|
|
100
|
+
"@utoo/pack-linux-x64-musl": "1.3.9-alpha.4",
|
|
101
|
+
"@utoo/pack-win32-x64-msvc": "1.3.9-alpha.4"
|
|
102
102
|
}
|
|
103
103
|
}
|