@embeddable.com/sdk-core 3.2.0-next.0 → 3.2.0-next.2
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/lib/index.esm.js +10 -8
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +11 -10
- package/lib/index.js.map +1 -1
- package/loader/custom-esm-loader.mjs +11 -3
- package/package.json +1 -1
- package/src/provideConfig.ts +10 -4
|
@@ -28,7 +28,8 @@ const host = {
|
|
|
28
28
|
readFile: ts.sys.readFile,
|
|
29
29
|
};
|
|
30
30
|
const EXTENSIONS = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts];
|
|
31
|
-
const NON_JS_TS_EXTENSIONS =
|
|
31
|
+
const NON_JS_TS_EXTENSIONS =
|
|
32
|
+
/\.(css|scss|less|sass|styl|json|svg|woff|woff2|png|jpg|jpeg|gif|webp|md|yml|yaml)$/;
|
|
32
33
|
|
|
33
34
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
34
35
|
|
|
@@ -44,7 +45,9 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
44
45
|
shortCircuit: true,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
|
|
47
49
|
const isTS = EXTENSIONS.some((ext) => specifier.endsWith(ext));
|
|
50
|
+
|
|
48
51
|
// entrypoint
|
|
49
52
|
if (!context.parentURL) {
|
|
50
53
|
return {
|
|
@@ -57,8 +60,11 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
57
60
|
if (context.parentURL.includes("/node_modules/") && !isTS) {
|
|
58
61
|
return nextResolve(specifier);
|
|
59
62
|
}
|
|
63
|
+
|
|
64
|
+
const isFileUrl = specifier.startsWith("file:");
|
|
65
|
+
|
|
60
66
|
const { resolvedModule } = ts.resolveModuleName(
|
|
61
|
-
specifier,
|
|
67
|
+
isFileUrl ? fileURLToPath(specifier) : specifier,
|
|
62
68
|
fileURLToPath(context.parentURL),
|
|
63
69
|
tsconfig,
|
|
64
70
|
host,
|
|
@@ -72,7 +78,9 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
72
78
|
) {
|
|
73
79
|
return {
|
|
74
80
|
format: "ts",
|
|
75
|
-
url:
|
|
81
|
+
url:
|
|
82
|
+
pathToFileURL(resolvedModule.resolvedFileName).href +
|
|
83
|
+
`?update=${Date.now()}`,
|
|
76
84
|
shortCircuit: true,
|
|
77
85
|
};
|
|
78
86
|
}
|
package/package.json
CHANGED
package/src/provideConfig.ts
CHANGED
|
@@ -3,12 +3,18 @@ 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 configPath = fs.existsSync(tsConfigFilePath)
|
|
16
|
+
? tsConfigFilePath
|
|
17
|
+
: configFilePath;
|
|
18
|
+
|
|
19
|
+
return (await import(configPath)).default;
|
|
14
20
|
};
|