@utoo/pack 1.1.8 → 1.1.10-rc.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/README.md CHANGED
@@ -77,7 +77,7 @@ async function startDev() {
77
77
  ### Usage via CLI
78
78
 
79
79
  ```bash
80
- utoopack build --webpack
80
+ up build --webpack
81
81
  ```
82
82
 
83
83
  ### Programmatic Usage
@@ -35,23 +35,41 @@ function serve(options, projectPath, rootPath, serverOptions) {
35
35
  return serveInternal(bundleOptions, projectPath, rootPath, serverOptions);
36
36
  }
37
37
  async function serveInternal(options, projectPath, rootPath, serverOptions) {
38
+ var _a;
38
39
  (0, common_1.blockStdout)();
39
40
  if (process.env.XCODE_PROFILE) {
40
41
  await (0, xcodeProfile_1.xcodeProfilingReady)();
41
42
  }
42
- await startServer({
43
- hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost",
44
- port: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) || 3000,
45
- https: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https,
43
+ // FIXME: fix any type
44
+ const cfgDevServer = (((_a = options.config) === null || _a === void 0 ? void 0 : _a.devServer) || {});
45
+ const serverOpts = {
46
+ hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || cfgDevServer.host || "localhost",
47
+ port: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) !== "undefined"
48
+ ? serverOptions.port
49
+ : cfgDevServer.port || 3000,
50
+ https: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https) !== "undefined"
51
+ ? serverOptions.https
52
+ : cfgDevServer.https,
46
53
  logServerInfo: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.logServerInfo,
47
- selfSignedCertificate: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https)
48
- ? await (0, mkcert_1.createSelfSignedCertificate)((serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost")
49
- : undefined,
50
- }, {
54
+ selfSignedCertificate: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.selfSignedCertificate,
55
+ };
56
+ // If HTTPS is requested and no certificate provided, attempt to generate one.
57
+ if (serverOpts.https && !serverOpts.selfSignedCertificate) {
58
+ try {
59
+ // createSelfSignedCertificate may return undefined on failure
60
+ const cert = await (0, mkcert_1.createSelfSignedCertificate)(serverOpts.hostname);
61
+ if (cert)
62
+ serverOpts.selfSignedCertificate = cert;
63
+ }
64
+ catch (e) {
65
+ // ignore and fall back to http if certificate generation fails
66
+ }
67
+ }
68
+ await startServer(serverOpts, {
51
69
  ...options,
52
70
  config: {
53
71
  ...options.config,
54
- devServer: { hot: true },
72
+ devServer: { ...(options.config.devServer || {}), hot: true },
55
73
  },
56
74
  packPath: (0, common_1.getPackPath)(),
57
75
  }, projectPath || process.cwd(), rootPath);
@@ -21,23 +21,41 @@ export function serve(options, projectPath, rootPath, serverOptions) {
21
21
  return serveInternal(bundleOptions, projectPath, rootPath, serverOptions);
22
22
  }
23
23
  async function serveInternal(options, projectPath, rootPath, serverOptions) {
24
+ var _a;
24
25
  blockStdout();
25
26
  if (process.env.XCODE_PROFILE) {
26
27
  await xcodeProfilingReady();
27
28
  }
28
- await startServer({
29
- hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost",
30
- port: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) || 3000,
31
- https: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https,
29
+ // FIXME: fix any type
30
+ const cfgDevServer = (((_a = options.config) === null || _a === void 0 ? void 0 : _a.devServer) || {});
31
+ const serverOpts = {
32
+ hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || cfgDevServer.host || "localhost",
33
+ port: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) !== "undefined"
34
+ ? serverOptions.port
35
+ : cfgDevServer.port || 3000,
36
+ https: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https) !== "undefined"
37
+ ? serverOptions.https
38
+ : cfgDevServer.https,
32
39
  logServerInfo: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.logServerInfo,
33
- selfSignedCertificate: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https)
34
- ? await createSelfSignedCertificate((serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost")
35
- : undefined,
36
- }, {
40
+ selfSignedCertificate: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.selfSignedCertificate,
41
+ };
42
+ // If HTTPS is requested and no certificate provided, attempt to generate one.
43
+ if (serverOpts.https && !serverOpts.selfSignedCertificate) {
44
+ try {
45
+ // createSelfSignedCertificate may return undefined on failure
46
+ const cert = await createSelfSignedCertificate(serverOpts.hostname);
47
+ if (cert)
48
+ serverOpts.selfSignedCertificate = cert;
49
+ }
50
+ catch (e) {
51
+ // ignore and fall back to http if certificate generation fails
52
+ }
53
+ }
54
+ await startServer(serverOpts, {
37
55
  ...options,
38
56
  config: {
39
57
  ...options.config,
40
- devServer: { hot: true },
58
+ devServer: { ...(options.config.devServer || {}), hot: true },
41
59
  },
42
60
  packPath: getPackPath(),
43
61
  }, projectPath || process.cwd(), rootPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "1.1.8",
3
+ "version": "1.1.10-rc.2",
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.1.8",
42
+ "@utoo/pack-shared": "1.1.10-rc.2",
43
43
  "@utoo/style-loader": "^1.0.0",
44
44
  "domparser-rs": "^0.0.5",
45
45
  "find-up": "4.1.0",
@@ -88,12 +88,12 @@
88
88
  },
89
89
  "repository": "git@github.com:utooland/utoo.git",
90
90
  "optionalDependencies": {
91
- "@utoo/pack-darwin-arm64": "1.1.8",
92
- "@utoo/pack-darwin-x64": "1.1.8",
93
- "@utoo/pack-linux-arm64-gnu": "1.1.8",
94
- "@utoo/pack-linux-arm64-musl": "1.1.8",
95
- "@utoo/pack-linux-x64-gnu": "1.1.8",
96
- "@utoo/pack-linux-x64-musl": "1.1.8",
97
- "@utoo/pack-win32-x64-msvc": "1.1.8"
91
+ "@utoo/pack-darwin-arm64": "1.1.10-rc.2",
92
+ "@utoo/pack-darwin-x64": "1.1.10-rc.2",
93
+ "@utoo/pack-linux-arm64-gnu": "1.1.10-rc.2",
94
+ "@utoo/pack-linux-arm64-musl": "1.1.10-rc.2",
95
+ "@utoo/pack-linux-x64-gnu": "1.1.10-rc.2",
96
+ "@utoo/pack-linux-x64-musl": "1.1.10-rc.2",
97
+ "@utoo/pack-win32-x64-msvc": "1.1.10-rc.2"
98
98
  }
99
99
  }