@gjsify/esbuild-plugin-alias 0.0.3 → 0.0.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/dist/cjs/index.cjs +29 -28
- package/dist/esm/index.mjs +29 -28
- package/package.json +3 -3
- package/src/plugin.ts +30 -32
- package/tsconfig.json +2 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -38,37 +38,38 @@ var aliasPlugin = (aliasObj) => {
|
|
|
38
38
|
build.onResolve({ filter: re }, async (args) => {
|
|
39
39
|
let resolvedAliasPath = aliasObj[args.path];
|
|
40
40
|
let namespace = args.namespace;
|
|
41
|
-
if (resolvedAliasPath) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
if (!resolvedAliasPath) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (resolvedAliasPath.startsWith("http://")) {
|
|
45
|
+
namespace = "http";
|
|
46
|
+
resolvedAliasPath = resolvedAliasPath.slice(5);
|
|
47
|
+
} else if (resolvedAliasPath.startsWith("https://")) {
|
|
48
|
+
namespace = "https";
|
|
49
|
+
resolvedAliasPath = resolvedAliasPath.slice(6);
|
|
50
|
+
} else {
|
|
51
|
+
const resolvedAlias = await build.resolve(resolvedAliasPath, {
|
|
52
|
+
importer: args.importer,
|
|
53
|
+
kind: args.kind,
|
|
54
|
+
namespace,
|
|
55
|
+
resolveDir: args.resolveDir,
|
|
56
|
+
pluginData: args.pluginData
|
|
57
|
+
});
|
|
58
|
+
if (resolvedAlias.errors.length > 0) {
|
|
59
|
+
console.error(resolvedAlias.errors);
|
|
60
|
+
return resolvedAlias;
|
|
48
61
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
kind: args.kind,
|
|
52
|
-
namespace,
|
|
53
|
-
resolveDir: args.resolveDir,
|
|
54
|
-
pluginData: args.pluginData
|
|
55
|
-
});
|
|
56
|
-
if (resolvedAlias.errors) {
|
|
57
|
-
return resolvedAlias;
|
|
58
|
-
} else {
|
|
59
|
-
resolvedAliasPath = resolvedAlias.path;
|
|
60
|
-
namespace = resolvedAlias.namespace;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if ((0, import_fs.existsSync)(resolvedAliasPath)) {
|
|
64
|
-
resolvedAliasPath = await (0, import_promises.realpath)(resolvedAliasPath);
|
|
62
|
+
resolvedAliasPath = resolvedAlias.path;
|
|
63
|
+
namespace = resolvedAlias.namespace;
|
|
65
64
|
}
|
|
66
|
-
return {
|
|
67
|
-
path: resolvedAliasPath,
|
|
68
|
-
namespace
|
|
69
|
-
};
|
|
70
65
|
}
|
|
71
|
-
|
|
66
|
+
if ((0, import_fs.existsSync)(resolvedAliasPath)) {
|
|
67
|
+
resolvedAliasPath = await (0, import_promises.realpath)(resolvedAliasPath);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
path: resolvedAliasPath,
|
|
71
|
+
namespace
|
|
72
|
+
};
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -13,37 +13,38 @@ var aliasPlugin = (aliasObj) => {
|
|
|
13
13
|
build.onResolve({ filter: re }, async (args) => {
|
|
14
14
|
let resolvedAliasPath = aliasObj[args.path];
|
|
15
15
|
let namespace = args.namespace;
|
|
16
|
-
if (resolvedAliasPath) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (!resolvedAliasPath) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (resolvedAliasPath.startsWith("http://")) {
|
|
20
|
+
namespace = "http";
|
|
21
|
+
resolvedAliasPath = resolvedAliasPath.slice(5);
|
|
22
|
+
} else if (resolvedAliasPath.startsWith("https://")) {
|
|
23
|
+
namespace = "https";
|
|
24
|
+
resolvedAliasPath = resolvedAliasPath.slice(6);
|
|
25
|
+
} else {
|
|
26
|
+
const resolvedAlias = await build.resolve(resolvedAliasPath, {
|
|
27
|
+
importer: args.importer,
|
|
28
|
+
kind: args.kind,
|
|
29
|
+
namespace,
|
|
30
|
+
resolveDir: args.resolveDir,
|
|
31
|
+
pluginData: args.pluginData
|
|
32
|
+
});
|
|
33
|
+
if (resolvedAlias.errors.length > 0) {
|
|
34
|
+
console.error(resolvedAlias.errors);
|
|
35
|
+
return resolvedAlias;
|
|
23
36
|
} else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
kind: args.kind,
|
|
27
|
-
namespace,
|
|
28
|
-
resolveDir: args.resolveDir,
|
|
29
|
-
pluginData: args.pluginData
|
|
30
|
-
});
|
|
31
|
-
if (resolvedAlias.errors) {
|
|
32
|
-
return resolvedAlias;
|
|
33
|
-
} else {
|
|
34
|
-
resolvedAliasPath = resolvedAlias.path;
|
|
35
|
-
namespace = resolvedAlias.namespace;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (existsSync(resolvedAliasPath)) {
|
|
39
|
-
resolvedAliasPath = await realpath(resolvedAliasPath);
|
|
37
|
+
resolvedAliasPath = resolvedAlias.path;
|
|
38
|
+
namespace = resolvedAlias.namespace;
|
|
40
39
|
}
|
|
41
|
-
return {
|
|
42
|
-
path: resolvedAliasPath,
|
|
43
|
-
namespace
|
|
44
|
-
};
|
|
45
40
|
}
|
|
46
|
-
|
|
41
|
+
if (existsSync(resolvedAliasPath)) {
|
|
42
|
+
resolvedAliasPath = await realpath(resolvedAliasPath);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
path: resolvedAliasPath,
|
|
46
|
+
namespace
|
|
47
|
+
};
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/esbuild-plugin-alias",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.cjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"plugin"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"esbuild": "^0.
|
|
30
|
-
"typescript": "^5.
|
|
29
|
+
"esbuild": "^0.19.10",
|
|
30
|
+
"typescript": "^5.3.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -23,44 +23,42 @@ export const aliasPlugin = (aliasObj: Record<string, string>) => {
|
|
|
23
23
|
|
|
24
24
|
let namespace = args.namespace;
|
|
25
25
|
|
|
26
|
-
if (resolvedAliasPath) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
namespace = 'http';
|
|
30
|
-
resolvedAliasPath = resolvedAliasPath.slice(5)
|
|
31
|
-
} else if (resolvedAliasPath.startsWith('https://')) {
|
|
32
|
-
namespace = 'https';
|
|
33
|
-
resolvedAliasPath = resolvedAliasPath.slice(6)
|
|
34
|
-
} else {
|
|
35
|
-
const resolvedAlias = (await build.resolve(resolvedAliasPath, {
|
|
36
|
-
importer: args.importer,
|
|
37
|
-
kind: args.kind,
|
|
38
|
-
namespace: namespace,
|
|
39
|
-
resolveDir: args.resolveDir,
|
|
40
|
-
pluginData: args.pluginData,
|
|
41
|
-
}));
|
|
26
|
+
if (!resolvedAliasPath) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
if (resolvedAliasPath.startsWith('http://')) {
|
|
31
|
+
namespace = 'http';
|
|
32
|
+
resolvedAliasPath = resolvedAliasPath.slice(5)
|
|
33
|
+
} else if (resolvedAliasPath.startsWith('https://')) {
|
|
34
|
+
namespace = 'https';
|
|
35
|
+
resolvedAliasPath = resolvedAliasPath.slice(6)
|
|
36
|
+
} else {
|
|
37
|
+
const resolvedAlias = (await build.resolve(resolvedAliasPath, {
|
|
38
|
+
importer: args.importer,
|
|
39
|
+
kind: args.kind,
|
|
40
|
+
namespace: namespace,
|
|
41
|
+
resolveDir: args.resolveDir,
|
|
42
|
+
pluginData: args.pluginData,
|
|
43
|
+
}));
|
|
50
44
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
45
|
+
if (resolvedAlias.errors.length > 0) {
|
|
46
|
+
console.error(resolvedAlias.errors);
|
|
47
|
+
return resolvedAlias;
|
|
48
|
+
} else {
|
|
49
|
+
resolvedAliasPath = resolvedAlias.path;
|
|
50
|
+
namespace = resolvedAlias.namespace;
|
|
53
51
|
}
|
|
52
|
+
}
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
path: resolvedAliasPath,
|
|
59
|
-
namespace: namespace,
|
|
60
|
-
}
|
|
54
|
+
if (existsSync(resolvedAliasPath)) {
|
|
55
|
+
resolvedAliasPath = await realpath(resolvedAliasPath);
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
path: resolvedAliasPath,
|
|
60
|
+
namespace: namespace,
|
|
61
|
+
};
|
|
64
62
|
});
|
|
65
63
|
},
|
|
66
64
|
};
|
package/tsconfig.json
CHANGED