-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.mjs
More file actions
33 lines (31 loc) · 1.11 KB
/
loader.mjs
File metadata and controls
33 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export async function resolve(specifier, context, defaultResolve) {
// ---- MOCK @pipedream/platform ----
if (specifier === "@pipedream/platform") {
return {
url:
"data:text/javascript," +
encodeURIComponent(`
export const axios = async ($, config) => {
globalThis.__axiosCalls = globalThis.__axiosCalls || [];
globalThis.__axiosCalls.push(config);
return { status: 200 };
};
`),
shortCircuit: true,
};
}
// ---- Existing version-stripping logic ----
if (specifier.includes("@")) {
const parts = specifier.split("@");
// If it looks like a Pipedream versioned import (e.g., 'alasql@^4')
// and it's not a scoped package (which would start with @)
if (parts.length === 2 && !specifier.startsWith("@")) {
return defaultResolve(parts[0], context, defaultResolve);
}
// Handle scoped packages (e.g., '@scope/pkg@^1')
if (parts.length === 3 && specifier.startsWith("@")) {
return defaultResolve(`@${parts[1]}`, context, defaultResolve);
}
}
return defaultResolve(specifier, context, defaultResolve);
}