@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.
@@ -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: specifier,
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 (context.parentURL.includes("/node_modules/") && !isTS) {
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
- return nextResolve(specifier);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.2.0-next.6",
3
+ "version": "3.2.0-next.7",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
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
- import { jwtDecode } from "jwt-decode";
4
+
7
5
  // @ts-ignore
8
6
  import reportErrorToRollbar from "./rollbar.mjs";
9
7
  import { CREDENTIALS_DIR, CREDENTIALS_FILE } from "./credentials";