@utoo/pack 1.1.8 → 1.1.9

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,40 @@ 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
+ const cfgDevServer = ((_a = options.config) === null || _a === void 0 ? void 0 : _a.devServer) || {};
44
+ const serverOpts = {
45
+ hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || cfgDevServer.host || "localhost",
46
+ port: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) !== "undefined"
47
+ ? serverOptions.port
48
+ : cfgDevServer.port || 3000,
49
+ https: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https) !== "undefined"
50
+ ? serverOptions.https
51
+ : cfgDevServer.https,
46
52
  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
- }, {
53
+ selfSignedCertificate: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.selfSignedCertificate,
54
+ };
55
+ // If HTTPS is requested and no certificate provided, attempt to generate one.
56
+ if (serverOpts.https && !serverOpts.selfSignedCertificate) {
57
+ try {
58
+ // createSelfSignedCertificate may return undefined on failure
59
+ const cert = await (0, mkcert_1.createSelfSignedCertificate)(serverOpts.hostname);
60
+ if (cert)
61
+ serverOpts.selfSignedCertificate = cert;
62
+ }
63
+ catch (e) {
64
+ // ignore and fall back to http if certificate generation fails
65
+ }
66
+ }
67
+ await startServer(serverOpts, {
51
68
  ...options,
52
69
  config: {
53
70
  ...options.config,
54
- devServer: { hot: true },
71
+ devServer: { ...(options.config.devServer || {}), hot: true },
55
72
  },
56
73
  packPath: (0, common_1.getPackPath)(),
57
74
  }, projectPath || process.cwd(), rootPath);
@@ -21,23 +21,40 @@ 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
+ const cfgDevServer = ((_a = options.config) === null || _a === void 0 ? void 0 : _a.devServer) || {};
30
+ const serverOpts = {
31
+ hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || cfgDevServer.host || "localhost",
32
+ port: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) !== "undefined"
33
+ ? serverOptions.port
34
+ : cfgDevServer.port || 3000,
35
+ https: typeof (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https) !== "undefined"
36
+ ? serverOptions.https
37
+ : cfgDevServer.https,
32
38
  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
- }, {
39
+ selfSignedCertificate: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.selfSignedCertificate,
40
+ };
41
+ // If HTTPS is requested and no certificate provided, attempt to generate one.
42
+ if (serverOpts.https && !serverOpts.selfSignedCertificate) {
43
+ try {
44
+ // createSelfSignedCertificate may return undefined on failure
45
+ const cert = await createSelfSignedCertificate(serverOpts.hostname);
46
+ if (cert)
47
+ serverOpts.selfSignedCertificate = cert;
48
+ }
49
+ catch (e) {
50
+ // ignore and fall back to http if certificate generation fails
51
+ }
52
+ }
53
+ await startServer(serverOpts, {
37
54
  ...options,
38
55
  config: {
39
56
  ...options.config,
40
- devServer: { hot: true },
57
+ devServer: { ...(options.config.devServer || {}), hot: true },
41
58
  },
42
59
  packPath: getPackPath(),
43
60
  }, 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.9",
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.9",
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.9",
92
+ "@utoo/pack-darwin-x64": "1.1.9",
93
+ "@utoo/pack-linux-arm64-gnu": "1.1.9",
94
+ "@utoo/pack-linux-arm64-musl": "1.1.9",
95
+ "@utoo/pack-linux-x64-gnu": "1.1.9",
96
+ "@utoo/pack-linux-x64-musl": "1.1.9",
97
+ "@utoo/pack-win32-x64-msvc": "1.1.9"
98
98
  }
99
99
  }