@embeddable.com/sdk-core 3.2.0-next.6 → 3.2.0-next.7
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/bin/embeddable +14 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/loader/custom-esm-loader.mjs +25 -3
- package/package.json +1 -1
- package/src/entryPoint.ts +2 -2
- package/src/login.ts +1 -3
|
@@ -34,6 +34,8 @@ const NON_JS_TS_EXTENSIONS =
|
|
|
34
34
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
35
35
|
|
|
36
36
|
export const resolve = async (specifier, context, nextResolve) => {
|
|
37
|
+
const isWindows = process.platform === "win32";
|
|
38
|
+
|
|
37
39
|
if (NON_JS_TS_EXTENSIONS.test(specifier)) {
|
|
38
40
|
const mockModulePath = pathToFileURL(
|
|
39
41
|
join(currentDir, "mock-module.js"),
|
|
@@ -50,14 +52,29 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
50
52
|
|
|
51
53
|
// entrypoint
|
|
52
54
|
if (!context.parentURL) {
|
|
55
|
+
const processCwd = pathToFileURL(process.cwd()).href;
|
|
56
|
+
|
|
57
|
+
const entryPointPath = isWindows
|
|
58
|
+
? pathToFileURL(specifier.replace(`${processCwd}/file:/`, "")).href
|
|
59
|
+
: specifier;
|
|
60
|
+
|
|
53
61
|
return {
|
|
54
62
|
format: isTS ? "ts" : undefined,
|
|
55
|
-
url:
|
|
63
|
+
url: entryPointPath,
|
|
56
64
|
shortCircuit: true,
|
|
57
65
|
};
|
|
58
66
|
}
|
|
67
|
+
|
|
68
|
+
// define if this is a package import
|
|
69
|
+
const isPackageImport =
|
|
70
|
+
!specifier.startsWith(".") &&
|
|
71
|
+
!specifier.startsWith("/") &&
|
|
72
|
+
!specifier.startsWith("C:");
|
|
59
73
|
// import/require from external library
|
|
60
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
(context.parentURL.includes("/node_modules/") || isPackageImport) &&
|
|
76
|
+
!isTS
|
|
77
|
+
) {
|
|
61
78
|
return nextResolve(specifier);
|
|
62
79
|
}
|
|
63
80
|
|
|
@@ -88,7 +105,12 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
88
105
|
// - something TS couldn't resolve
|
|
89
106
|
// - external library
|
|
90
107
|
// - local project non-TS file
|
|
91
|
-
|
|
108
|
+
const specifierPathOrUrl =
|
|
109
|
+
!resolvedModule?.resolvedFileName?.includes("/node_modules/") && isWindows
|
|
110
|
+
? pathToFileURL(specifier).href
|
|
111
|
+
: specifier;
|
|
112
|
+
|
|
113
|
+
return nextResolve(specifierPathOrUrl);
|
|
92
114
|
};
|
|
93
115
|
const tsconfigForSWCNode = {
|
|
94
116
|
...tsconfig,
|
package/package.json
CHANGED
package/src/entryPoint.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
4
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
5
|
const COMMANDS_MAP = await import(path.join(__dirname, "../lib/index.js"));
|
package/src/login.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import * as os from "node:os";
|
|
3
1
|
import * as fs from "node:fs/promises";
|
|
4
2
|
import axios from "axios";
|
|
5
3
|
import provideConfig from "./provideConfig";
|
|
6
|
-
|
|
4
|
+
|
|
7
5
|
// @ts-ignore
|
|
8
6
|
import reportErrorToRollbar from "./rollbar.mjs";
|
|
9
7
|
import { CREDENTIALS_DIR, CREDENTIALS_FILE } from "./credentials";
|