socket-function 0.97.0 → 0.98.0
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/package.json +1 -1
- package/require/RequireController.ts +14 -2
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import zlib from "zlib";
|
|
|
8
8
|
import { cacheLimited, lazy } from "../src/caching";
|
|
9
9
|
import { formatNumber } from "../src/formatting/format";
|
|
10
10
|
import { requireMain } from "./require";
|
|
11
|
+
import path from "path";
|
|
11
12
|
|
|
12
13
|
const COMPRESS_CACHE_SIZE = 1024 * 1024 * 128;
|
|
13
14
|
|
|
@@ -136,6 +137,11 @@ class RequireControllerBase {
|
|
|
136
137
|
requireCalls?: string[];
|
|
137
138
|
cacheTime?: number;
|
|
138
139
|
}) {
|
|
140
|
+
if (!this.rootResolvePath) {
|
|
141
|
+
let dir = path.resolve(".");
|
|
142
|
+
dir = dir.replaceAll("\\", "/");
|
|
143
|
+
this.rootResolvePath = dir;
|
|
144
|
+
}
|
|
139
145
|
let { requireCalls, cacheTime } = config || {};
|
|
140
146
|
let result = resolvedHTMLFile();
|
|
141
147
|
if (beforeEntryText.length > 0) {
|
|
@@ -405,8 +411,14 @@ declare global {
|
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
let baseController = new RequireControllerBase();
|
|
408
|
-
|
|
409
|
-
|
|
414
|
+
/** Sets the root directory that imports should be resolved from. Defaults to "." */
|
|
415
|
+
export function setRequireBootRequire(dir: string) {
|
|
416
|
+
dir = path.resolve(dir);
|
|
417
|
+
dir = dir.replaceAll("\\", "/");
|
|
418
|
+
if (!dir.endsWith("/")) {
|
|
419
|
+
dir += "/";
|
|
420
|
+
}
|
|
421
|
+
baseController.rootResolvePath = dir;
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
export const RequireController = SocketFunction.register(
|