dumi 2.4.25 → 2.4.26
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.
|
@@ -35,6 +35,7 @@ __export(compile_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(compile_exports);
|
|
36
36
|
var import_react = __toESM(require("../../techStacks/react"));
|
|
37
37
|
var import_utils = require("../../utils");
|
|
38
|
+
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
38
39
|
var import_fs = __toESM(require("fs"));
|
|
39
40
|
var import_path = __toESM(require("path"));
|
|
40
41
|
var import_assets = require("../assets");
|
|
@@ -42,6 +43,31 @@ var import_makoHooks = require("./makoHooks");
|
|
|
42
43
|
var import_utils2 = require("./utils");
|
|
43
44
|
var import_utoopackLoaders = require("./utoopackLoaders");
|
|
44
45
|
var techStacks = [];
|
|
46
|
+
function normalizeMakoAliases(alias, cwd) {
|
|
47
|
+
const normalizedAlias = { ...alias };
|
|
48
|
+
const resolver = import_enhanced_resolve.default.create.sync({
|
|
49
|
+
alias,
|
|
50
|
+
conditionNames: ["import", "require", "default", "browser", "node"],
|
|
51
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".json"],
|
|
52
|
+
exportsFields: [],
|
|
53
|
+
mainFields: ["browser", "module", "main"]
|
|
54
|
+
});
|
|
55
|
+
Object.keys(alias).forEach((key) => {
|
|
56
|
+
if (!key.endsWith("$"))
|
|
57
|
+
return;
|
|
58
|
+
const makoAliasKey = key.slice(0, -1);
|
|
59
|
+
const aliasValue = alias[key];
|
|
60
|
+
delete normalizedAlias[key];
|
|
61
|
+
if (makoAliasKey in normalizedAlias)
|
|
62
|
+
return;
|
|
63
|
+
try {
|
|
64
|
+
normalizedAlias[makoAliasKey] = resolver(cwd, aliasValue);
|
|
65
|
+
} catch {
|
|
66
|
+
normalizedAlias[makoAliasKey] = aliasValue;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return normalizedAlias;
|
|
70
|
+
}
|
|
45
71
|
var compile_default = (api) => {
|
|
46
72
|
api.describe({ key: "dumi:compile" });
|
|
47
73
|
api.register({
|
|
@@ -182,6 +208,7 @@ var compile_default = (api) => {
|
|
|
182
208
|
fn: (memo) => {
|
|
183
209
|
var _a;
|
|
184
210
|
if (memo.mako || ((_a = memo.ssr) == null ? void 0 : _a.builder) === "mako") {
|
|
211
|
+
memo.alias = normalizeMakoAliases(memo.alias, api.cwd);
|
|
185
212
|
memo.mako ?? (memo.mako = {});
|
|
186
213
|
memo.mako.plugins = [
|
|
187
214
|
{
|