owebjs 1.3.3 → 1.3.4
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.
|
@@ -10,6 +10,9 @@ import { pathToFileURL } from "node:url";
|
|
|
10
10
|
import { writeFile, unlink } from "node:fs/promises";
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { error } from './logger.js';
|
|
15
|
+
const require2 = createRequire(import.meta.url);
|
|
13
16
|
async function generateFunctionFromTypescript(tsCode, filePath) {
|
|
14
17
|
const result = babel.transformSync(tsCode, {
|
|
15
18
|
presets: [
|
|
@@ -34,6 +37,18 @@ async function generateFunctionFromTypescript(tsCode, filePath) {
|
|
|
34
37
|
const absoluteDepPath = path.resolve(originalFileDir, resolvedPath);
|
|
35
38
|
const absoluteDepUrl = pathToFileURL(absoluteDepPath).href;
|
|
36
39
|
importSourceNode.value = absoluteDepUrl;
|
|
40
|
+
} else {
|
|
41
|
+
try {
|
|
42
|
+
const resolvedPath = require2.resolve(relativePath, {
|
|
43
|
+
paths: [
|
|
44
|
+
path.dirname(filePath)
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
const resolvedUrl = pathToFileURL(resolvedPath).href;
|
|
48
|
+
importSourceNode.value = resolvedUrl;
|
|
49
|
+
} catch (_) {
|
|
50
|
+
error(`Could not resolve module "${relativePath}". Please ensure it is installed.`, "HMR");
|
|
51
|
+
}
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
});
|