@jsenv/core 41.0.1 → 41.0.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.
@@ -32,7 +32,7 @@ import "node:url";
32
32
  */
33
33
  const startBuildServer = async ({
34
34
  buildDirectoryUrl,
35
- buildMainFilePath = "index.html",
35
+ buildDirectoryMainFileRelativeUrl = "index.html",
36
36
  port = 9779,
37
37
  routes,
38
38
  serverPlugins = [],
@@ -62,26 +62,35 @@ const startBuildServer = async ({
62
62
  "buildDirectoryUrl",
63
63
  );
64
64
 
65
- if (buildMainFilePath) {
66
- if (typeof buildMainFilePath !== "string") {
65
+ if (buildDirectoryMainFileRelativeUrl) {
66
+ if (typeof buildDirectoryMainFileRelativeUrl !== "string") {
67
67
  throw new TypeError(
68
- `buildMainFilePath must be a string, got ${buildMainFilePath}`,
68
+ `buildDirectoryMainFileRelativeUrl must be a string, got ${buildDirectoryMainFileRelativeUrl}`,
69
69
  );
70
70
  }
71
- if (buildMainFilePath[0] === "/") {
72
- buildMainFilePath = buildMainFilePath.slice(1);
71
+ if (buildDirectoryMainFileRelativeUrl[0] === "/") {
72
+ buildDirectoryMainFileRelativeUrl =
73
+ buildDirectoryMainFileRelativeUrl.slice(1);
73
74
  } else {
74
- const buildMainFileUrl = new URL(buildMainFilePath, buildDirectoryUrl)
75
- .href;
75
+ const buildMainFileUrl = new URL(
76
+ buildDirectoryMainFileRelativeUrl,
77
+ buildDirectoryUrl,
78
+ ).href;
76
79
  if (!buildMainFileUrl.startsWith(buildDirectoryUrl)) {
77
80
  throw new Error(
78
- `buildMainFilePath must be relative, got ${buildMainFilePath}`,
81
+ `buildDirectoryMainFileRelativeUrl must be relative, got ${buildDirectoryMainFileRelativeUrl}`,
79
82
  );
80
83
  }
81
- buildMainFilePath = buildMainFileUrl.slice(buildDirectoryUrl.length);
84
+ buildDirectoryMainFileRelativeUrl = buildMainFileUrl.slice(
85
+ buildDirectoryUrl.length,
86
+ );
82
87
  }
83
- if (!existsSync(new URL(buildMainFilePath, buildDirectoryUrl))) {
84
- buildMainFilePath = null;
88
+ if (
89
+ !existsSync(
90
+ new URL(buildDirectoryMainFileRelativeUrl, buildDirectoryUrl),
91
+ )
92
+ ) {
93
+ buildDirectoryMainFileRelativeUrl = null;
85
94
  }
86
95
  }
87
96
  }
@@ -130,8 +139,9 @@ const startBuildServer = async ({
130
139
  }),
131
140
  ...serverPlugins,
132
141
  serverPluginStaticFiles({
142
+ serverRelativeUrl: "/",
133
143
  directoryUrl: buildDirectoryUrl,
134
- mainFilePath: buildMainFilePath,
144
+ directoryMainFileRelativeUrl: buildDirectoryMainFileRelativeUrl,
135
145
  }),
136
146
  serverPluginErrorHandler({
137
147
  sendErrorDetails: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "41.0.1",
3
+ "version": "41.0.2",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -81,7 +81,7 @@
81
81
  "@jsenv/plugin-minification": "1.7.3",
82
82
  "@jsenv/plugin-supervisor": "1.7.15",
83
83
  "@jsenv/plugin-transpilation": "1.5.70",
84
- "@jsenv/server": "17.0.0",
84
+ "@jsenv/server": "17.0.1",
85
85
  "@jsenv/sourcemap": "1.3.17",
86
86
  "react-table": "7.8.0"
87
87
  },
@@ -33,7 +33,7 @@ import { existsSync } from "node:fs";
33
33
  */
34
34
  export const startBuildServer = async ({
35
35
  buildDirectoryUrl,
36
- buildMainFilePath = "index.html",
36
+ buildDirectoryMainFileRelativeUrl = "index.html",
37
37
  port = 9779,
38
38
  routes,
39
39
  serverPlugins = [],
@@ -63,26 +63,35 @@ export const startBuildServer = async ({
63
63
  "buildDirectoryUrl",
64
64
  );
65
65
 
66
- if (buildMainFilePath) {
67
- if (typeof buildMainFilePath !== "string") {
66
+ if (buildDirectoryMainFileRelativeUrl) {
67
+ if (typeof buildDirectoryMainFileRelativeUrl !== "string") {
68
68
  throw new TypeError(
69
- `buildMainFilePath must be a string, got ${buildMainFilePath}`,
69
+ `buildDirectoryMainFileRelativeUrl must be a string, got ${buildDirectoryMainFileRelativeUrl}`,
70
70
  );
71
71
  }
72
- if (buildMainFilePath[0] === "/") {
73
- buildMainFilePath = buildMainFilePath.slice(1);
72
+ if (buildDirectoryMainFileRelativeUrl[0] === "/") {
73
+ buildDirectoryMainFileRelativeUrl =
74
+ buildDirectoryMainFileRelativeUrl.slice(1);
74
75
  } else {
75
- const buildMainFileUrl = new URL(buildMainFilePath, buildDirectoryUrl)
76
- .href;
76
+ const buildMainFileUrl = new URL(
77
+ buildDirectoryMainFileRelativeUrl,
78
+ buildDirectoryUrl,
79
+ ).href;
77
80
  if (!buildMainFileUrl.startsWith(buildDirectoryUrl)) {
78
81
  throw new Error(
79
- `buildMainFilePath must be relative, got ${buildMainFilePath}`,
82
+ `buildDirectoryMainFileRelativeUrl must be relative, got ${buildDirectoryMainFileRelativeUrl}`,
80
83
  );
81
84
  }
82
- buildMainFilePath = buildMainFileUrl.slice(buildDirectoryUrl.length);
85
+ buildDirectoryMainFileRelativeUrl = buildMainFileUrl.slice(
86
+ buildDirectoryUrl.length,
87
+ );
83
88
  }
84
- if (!existsSync(new URL(buildMainFilePath, buildDirectoryUrl))) {
85
- buildMainFilePath = null;
89
+ if (
90
+ !existsSync(
91
+ new URL(buildDirectoryMainFileRelativeUrl, buildDirectoryUrl),
92
+ )
93
+ ) {
94
+ buildDirectoryMainFileRelativeUrl = null;
86
95
  }
87
96
  }
88
97
  }
@@ -132,8 +141,9 @@ export const startBuildServer = async ({
132
141
  }),
133
142
  ...serverPlugins,
134
143
  serverPluginStaticFiles({
144
+ serverRelativeUrl: "/",
135
145
  directoryUrl: buildDirectoryUrl,
136
- mainFilePath: buildMainFilePath,
146
+ directoryMainFileRelativeUrl: buildDirectoryMainFileRelativeUrl,
137
147
  }),
138
148
  serverPluginErrorHandler({
139
149
  sendErrorDetails: false,