@utoo/pack 1.3.9-alpha.1 → 1.3.9-alpha.3

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.
@@ -75,8 +75,30 @@ async function withErrorCause(fn) {
75
75
  });
76
76
  }
77
77
  }
78
- async function serializeConfig(config) {
79
- const configSerializable = { ...config };
78
+ function normalizeEmotionConfig(emotion, isDev) {
79
+ if (emotion === undefined) {
80
+ return undefined;
81
+ }
82
+ const defaults = {
83
+ sourcemap: isDev,
84
+ autoLabel: isDev ? "always" : "never",
85
+ };
86
+ return emotion === true ? defaults : { ...defaults, ...emotion };
87
+ }
88
+ function normalizeStyles(styles, isDev) {
89
+ if (!styles) {
90
+ return styles;
91
+ }
92
+ return {
93
+ ...styles,
94
+ emotion: normalizeEmotionConfig(styles.emotion, isDev),
95
+ };
96
+ }
97
+ async function serializeConfig(config, isDev) {
98
+ const configSerializable = {
99
+ ...config,
100
+ ...normalizeStyles(config.styles, isDev),
101
+ };
80
102
  if (configSerializable.entry) {
81
103
  configSerializable.entry = configSerializable.entry.map((entry) => {
82
104
  const { html, ...rest } = entry;
@@ -210,7 +232,7 @@ async function rustifyPartialProjectOptions(options) {
210
232
  rootPath: normalizePathOption(options.rootPath),
211
233
  projectPath: normalizePathOption(options.projectPath),
212
234
  packPath: normalizePathOption(options.packPath),
213
- config: options.config && (await serializeConfig(options.config)),
235
+ config: options.config && (await serializeConfig(options.config, !!options.dev)),
214
236
  processEnv: options.processEnv && (0, common_1.rustifyEnv)(options.processEnv),
215
237
  };
216
238
  }
@@ -226,7 +248,7 @@ async function rustifyProjectOptions(options) {
226
248
  rootPath: (0, normalize_path_1.normalizePath)(options.rootPath),
227
249
  projectPath: (0, normalize_path_1.normalizePath)(options.projectPath),
228
250
  packPath: (0, normalize_path_1.normalizePath)(options.packPath),
229
- config: await serializeConfig(options.config),
251
+ config: await serializeConfig(options.config, options.dev),
230
252
  processEnv: (0, common_1.rustifyEnv)((_a = options.processEnv) !== null && _a !== void 0 ? _a : {}),
231
253
  };
232
254
  }
@@ -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
- "type": [
1408
- "boolean",
1409
- "null"
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": {
@@ -37,8 +37,30 @@ async function withErrorCause(fn) {
37
37
  });
38
38
  }
39
39
  }
40
- async function serializeConfig(config) {
41
- const configSerializable = { ...config };
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
+ async function serializeConfig(config, isDev) {
60
+ const configSerializable = {
61
+ ...config,
62
+ ...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.1",
3
+ "version": "1.3.9-alpha.3",
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.1",
44
+ "@utoo/pack-shared": "1.3.9-alpha.3",
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.1",
96
- "@utoo/pack-darwin-x64": "1.3.9-alpha.1",
97
- "@utoo/pack-linux-arm64-gnu": "1.3.9-alpha.1",
98
- "@utoo/pack-linux-arm64-musl": "1.3.9-alpha.1",
99
- "@utoo/pack-linux-x64-gnu": "1.3.9-alpha.1",
100
- "@utoo/pack-linux-x64-musl": "1.3.9-alpha.1",
101
- "@utoo/pack-win32-x64-msvc": "1.3.9-alpha.1"
95
+ "@utoo/pack-darwin-arm64": "1.3.9-alpha.3",
96
+ "@utoo/pack-darwin-x64": "1.3.9-alpha.3",
97
+ "@utoo/pack-linux-arm64-gnu": "1.3.9-alpha.3",
98
+ "@utoo/pack-linux-arm64-musl": "1.3.9-alpha.3",
99
+ "@utoo/pack-linux-x64-gnu": "1.3.9-alpha.3",
100
+ "@utoo/pack-linux-x64-musl": "1.3.9-alpha.3",
101
+ "@utoo/pack-win32-x64-msvc": "1.3.9-alpha.3"
102
102
  }
103
103
  }