@embeddable.com/sdk-core 3.1.2 → 3.1.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.
- package/bin/embeddable +15 -3
- package/configs/tsconfig.json +4 -11
- package/lib/defineConfig.d.ts +6 -6
- package/lib/index.esm.js +14 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +15 -8
- package/lib/index.js.map +1 -1
- package/loader/custom-esm-loader.mjs +33 -5
- package/package.json +1 -1
- package/src/defineConfig.ts +3 -3
- package/src/entryPoint.js +12 -0
- package/src/generate.ts +3 -0
- package/src/login.ts +1 -3
- package/src/provideConfig.ts +13 -4
- package/lib/entryPoint.d.ts +0 -1
- package/src/entryPoint.ts +0 -16
|
@@ -33,6 +33,8 @@ const NON_JS_TS_EXTENSIONS =
|
|
|
33
33
|
|
|
34
34
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
35
35
|
|
|
36
|
+
const isWindows = process.platform === "win32";
|
|
37
|
+
|
|
36
38
|
export const resolve = async (specifier, context, nextResolve) => {
|
|
37
39
|
if (NON_JS_TS_EXTENSIONS.test(specifier)) {
|
|
38
40
|
const mockModulePath = pathToFileURL(
|
|
@@ -50,19 +52,37 @@ 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
|
+
!/^[A-Z]:/.test(specifier); // windows path
|
|
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
|
}
|
|
80
|
+
|
|
81
|
+
const isFileUrl = specifier.startsWith("file://");
|
|
82
|
+
const isParentFileUrl = context.parentURL.startsWith("file://");
|
|
63
83
|
const { resolvedModule } = ts.resolveModuleName(
|
|
64
|
-
specifier,
|
|
65
|
-
fileURLToPath(context.parentURL),
|
|
84
|
+
isFileUrl ? fileURLToPath(specifier) : specifier,
|
|
85
|
+
isParentFileUrl ? fileURLToPath(context.parentURL) : context.parentURL,
|
|
66
86
|
tsconfig,
|
|
67
87
|
host,
|
|
68
88
|
moduleResolutionCache,
|
|
@@ -85,7 +105,12 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
85
105
|
// - something TS couldn't resolve
|
|
86
106
|
// - external library
|
|
87
107
|
// - local project non-TS file
|
|
88
|
-
|
|
108
|
+
const specifierPathOrUrl =
|
|
109
|
+
!resolvedModule?.resolvedFileName?.includes("/node_modules/") && isWindows
|
|
110
|
+
? pathToFileURL(specifier).href
|
|
111
|
+
: specifier;
|
|
112
|
+
|
|
113
|
+
return nextResolve(specifierPathOrUrl);
|
|
89
114
|
};
|
|
90
115
|
const tsconfigForSWCNode = {
|
|
91
116
|
...tsconfig,
|
|
@@ -110,6 +135,9 @@ export const load = async (url, context, nextLoad) => {
|
|
|
110
135
|
shortCircuit: true,
|
|
111
136
|
};
|
|
112
137
|
} else {
|
|
138
|
+
if (isWindows && !url.startsWith("file://") && url.includes("node_modules")) {
|
|
139
|
+
return nextLoad(pathToFileURL(url).href, context);
|
|
140
|
+
}
|
|
113
141
|
return nextLoad(url, context);
|
|
114
142
|
}
|
|
115
143
|
};
|
package/package.json
CHANGED
package/src/defineConfig.ts
CHANGED
|
@@ -3,9 +3,9 @@ import * as path from "node:path";
|
|
|
3
3
|
export type EmbeddableConfig = {
|
|
4
4
|
plugins: (() => {
|
|
5
5
|
pluginName: string;
|
|
6
|
-
build: (config: EmbeddableConfig) => Promise<
|
|
7
|
-
cleanup: (config: EmbeddableConfig) => Promise<
|
|
8
|
-
validate: (config: EmbeddableConfig) => Promise<
|
|
6
|
+
build: (config: EmbeddableConfig) => Promise<unknown>;
|
|
7
|
+
cleanup: (config: EmbeddableConfig) => Promise<unknown>;
|
|
8
|
+
validate: (config: EmbeddableConfig) => Promise<unknown>;
|
|
9
9
|
})[];
|
|
10
10
|
pushBaseUrl?: string;
|
|
11
11
|
audienceUrl?: string;
|
package/src/generate.ts
CHANGED
|
@@ -63,12 +63,15 @@ async function runStencil(ctx: any) {
|
|
|
63
63
|
const sys = ctx.dev?.sys || createNodeSys({ process });
|
|
64
64
|
const devMode = !!ctx.dev;
|
|
65
65
|
|
|
66
|
+
const isWindows = process.platform === "win32";
|
|
67
|
+
|
|
66
68
|
const validated = await loadConfig({
|
|
67
69
|
initTsConfig: true,
|
|
68
70
|
logger,
|
|
69
71
|
sys,
|
|
70
72
|
config: {
|
|
71
73
|
devMode,
|
|
74
|
+
maxConcurrentWorkers: isWindows ? 0 : 8, // workers break on windows
|
|
72
75
|
rootDir: ctx.client.buildDir,
|
|
73
76
|
configPath: path.resolve(ctx.client.buildDir, "stencil.config.ts"),
|
|
74
77
|
tsconfig: path.resolve(ctx.client.buildDir, "tsconfig.json"),
|
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";
|
package/src/provideConfig.ts
CHANGED
|
@@ -3,12 +3,21 @@ import * as url from "node:url";
|
|
|
3
3
|
|
|
4
4
|
export default async () => {
|
|
5
5
|
const configFilePath = `${process.cwd()}/embeddable.config.js`;
|
|
6
|
+
const tsConfigFilePath = `${process.cwd()}/embeddable.config.ts`;
|
|
6
7
|
|
|
7
|
-
if (!fs.existsSync(configFilePath)) {
|
|
8
|
-
console.log(
|
|
8
|
+
if (!fs.existsSync(configFilePath) && !fs.existsSync(tsConfigFilePath)) {
|
|
9
|
+
console.log(
|
|
10
|
+
"Please create a proper `embeddable.config.js` or `embeddable.config.ts` file in the root of your project.",
|
|
11
|
+
);
|
|
9
12
|
process.exit(1);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
const
|
|
13
|
-
|
|
15
|
+
const isWindows = process.platform === "win32";
|
|
16
|
+
const configPath = fs.existsSync(tsConfigFilePath)
|
|
17
|
+
? tsConfigFilePath
|
|
18
|
+
: configFilePath;
|
|
19
|
+
|
|
20
|
+
const pathOrUrl = isWindows ? url.pathToFileURL(configPath).href : configPath;
|
|
21
|
+
|
|
22
|
+
return (await import(pathOrUrl)).default;
|
|
14
23
|
};
|
package/lib/entryPoint.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/entryPoint.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
|
-
|
|
4
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
const COMMANDS_MAP = await import(path.join(__dirname, "../lib/index.js"));
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
const command = process.argv[2];
|
|
9
|
-
const runScript = COMMANDS_MAP[command];
|
|
10
|
-
|
|
11
|
-
if (!runScript) process.exit(1);
|
|
12
|
-
|
|
13
|
-
await runScript();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
main();
|