dumi 2.2.15 → 2.2.16
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/constants.d.ts +1 -0
- package/dist/constants.js +3 -0
- package/dist/features/compile/index.js +15 -7
- package/dist/features/parser.js +2 -2
- package/dist/features/theme/index.js +13 -11
- package/dist/utils.d.ts +1 -3
- package/dist/utils.js +8 -2
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export declare const PICKED_PKG_FIELDS: {
|
|
|
17
17
|
export declare const USELESS_TMP_FILES: string[];
|
|
18
18
|
export declare const VERSION_2_LEVEL_NAV = "^2.2.0";
|
|
19
19
|
export declare const VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
|
|
20
|
+
export declare const FS_CACHE_DIR = "node_modules/.cache/dumi";
|
package/dist/constants.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/constants.ts
|
|
20
20
|
var constants_exports = {};
|
|
21
21
|
__export(constants_exports, {
|
|
22
|
+
FS_CACHE_DIR: () => FS_CACHE_DIR,
|
|
22
23
|
LOCAL_DUMI_DIR: () => LOCAL_DUMI_DIR,
|
|
23
24
|
LOCAL_PAGES_DIR: () => LOCAL_PAGES_DIR,
|
|
24
25
|
LOCAL_THEME_DIR: () => LOCAL_THEME_DIR,
|
|
@@ -51,8 +52,10 @@ var PICKED_PKG_FIELDS = {
|
|
|
51
52
|
var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
|
|
52
53
|
var VERSION_2_LEVEL_NAV = "^2.2.0";
|
|
53
54
|
var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
|
|
55
|
+
var FS_CACHE_DIR = "node_modules/.cache/dumi";
|
|
54
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
57
|
0 && (module.exports = {
|
|
58
|
+
FS_CACHE_DIR,
|
|
56
59
|
LOCAL_DUMI_DIR,
|
|
57
60
|
LOCAL_PAGES_DIR,
|
|
58
61
|
LOCAL_THEME_DIR,
|
|
@@ -33,6 +33,8 @@ __export(compile_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(compile_exports);
|
|
35
35
|
var import_react = __toESM(require("../../techStacks/react"));
|
|
36
|
+
var import_utils = require("../../utils");
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
36
38
|
var import_assets = require("../assets");
|
|
37
39
|
var compile_default = (api) => {
|
|
38
40
|
api.describe({ key: "dumi:compile" });
|
|
@@ -41,14 +43,20 @@ var compile_default = (api) => {
|
|
|
41
43
|
stage: Infinity,
|
|
42
44
|
fn: () => new import_react.default()
|
|
43
45
|
});
|
|
44
|
-
api.modifyConfig(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
api.modifyConfig({
|
|
47
|
+
stage: Infinity,
|
|
48
|
+
fn: (memo) => {
|
|
49
|
+
if (memo.babelLoaderCustomize) {
|
|
50
|
+
api.logger.warn(
|
|
51
|
+
"Config `babelLoaderCustomize` will be override by dumi, please report issue if you need it."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
memo.babelLoaderCustomize = require.resolve("./babelLoaderCustomize");
|
|
55
|
+
const cacheDirPath = api.userConfig.cacheDirectoryPath || memo.cacheDirectoryPath;
|
|
56
|
+
if (cacheDirPath)
|
|
57
|
+
(0, import_utils._setFSCacheDir)(import_path.default.join(cacheDirPath, "dumi"));
|
|
58
|
+
return memo;
|
|
49
59
|
}
|
|
50
|
-
memo.babelLoaderCustomize = require.resolve("./babelLoaderCustomize");
|
|
51
|
-
return memo;
|
|
52
60
|
});
|
|
53
61
|
api.chainWebpack(async (memo) => {
|
|
54
62
|
const babelInUmi = memo.module.rule("src").use("babel-loader").entries();
|
package/dist/features/parser.js
CHANGED
|
@@ -43,9 +43,9 @@ function filterIgnoredProps(props) {
|
|
|
43
43
|
} else if (prop.type === "object" && "properties" in prop) {
|
|
44
44
|
prop.properties = filterIgnoredProps(prop.properties);
|
|
45
45
|
} else if (prop.oneOf) {
|
|
46
|
-
prop.oneOf = prop.oneOf.map((item) => filterIgnoredProps({ _: item })._);
|
|
46
|
+
prop.oneOf = prop.oneOf.filter(Boolean).map((item) => filterIgnoredProps({ _: item })._);
|
|
47
47
|
} else if (prop.allOf) {
|
|
48
|
-
prop.allOf = prop.allOf.map((item) => filterIgnoredProps({ _: item })._);
|
|
48
|
+
prop.allOf = prop.allOf.filter(Boolean).map((item) => filterIgnoredProps({ _: item })._);
|
|
49
49
|
} else if ("hidden" in prop) {
|
|
50
50
|
isHidden = true;
|
|
51
51
|
}
|
|
@@ -72,11 +72,12 @@ function getPkgThemePath(api) {
|
|
|
72
72
|
})
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
function getModuleExports(modulePath) {
|
|
76
|
-
|
|
75
|
+
async function getModuleExports(modulePath) {
|
|
76
|
+
const [_, exports] = await (0, import_bundler_utils.parseModule)({
|
|
77
77
|
path: modulePath,
|
|
78
78
|
content: import_fs.default.readFileSync(modulePath, "utf-8")
|
|
79
|
-
})
|
|
79
|
+
});
|
|
80
|
+
return exports || [];
|
|
80
81
|
}
|
|
81
82
|
function checkMinor2ByPkg(pkg) {
|
|
82
83
|
var _a, _b, _c;
|
|
@@ -251,14 +252,14 @@ export default DumiLoading;
|
|
|
251
252
|
});
|
|
252
253
|
}
|
|
253
254
|
});
|
|
254
|
-
api.onGenerateFiles(() => {
|
|
255
|
+
api.onGenerateFiles(async () => {
|
|
255
256
|
var _a, _b, _c, _d, _e;
|
|
256
|
-
themeMapKeys.
|
|
257
|
-
Object.values(originalThemeData[key] || {}).
|
|
257
|
+
const pAll = themeMapKeys.flatMap(
|
|
258
|
+
(key) => Object.values(originalThemeData[key] || {}).map(async (item) => {
|
|
258
259
|
if (item.source === "dumi")
|
|
259
260
|
return;
|
|
260
|
-
|
|
261
|
-
const
|
|
261
|
+
const exports = await getModuleExports(item.source);
|
|
262
|
+
const contents = [];
|
|
262
263
|
if (exports.includes("default")) {
|
|
263
264
|
contents.push(`export { default } from '${item.source}';`);
|
|
264
265
|
}
|
|
@@ -270,10 +271,11 @@ export default DumiLoading;
|
|
|
270
271
|
path: `dumi/theme/${key}/${item.specifier}.ts`,
|
|
271
272
|
content: contents.join("\n")
|
|
272
273
|
});
|
|
273
|
-
})
|
|
274
|
-
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
await Promise.all(pAll);
|
|
275
277
|
const entryFile = api.config.resolve.entryFile && [import_path.default.resolve(api.cwd, api.config.resolve.entryFile)].find(import_fs.default.existsSync);
|
|
276
|
-
const entryExports = entryFile ? getModuleExports(entryFile) : [];
|
|
278
|
+
const entryExports = entryFile ? await getModuleExports(entryFile) : [];
|
|
277
279
|
const hasDefaultExport = entryExports.includes("default");
|
|
278
280
|
const hasNamedExport = entryExports.some((exp) => exp !== "default");
|
|
279
281
|
api.writeTmpFile({
|
package/dist/utils.d.ts
CHANGED
|
@@ -21,10 +21,8 @@ export declare function parseCodeFrontmatter(raw: string): {
|
|
|
21
21
|
code: string;
|
|
22
22
|
frontmatter: Record<string, any> | null;
|
|
23
23
|
};
|
|
24
|
-
/**
|
|
25
|
-
* get file-system cache for specific namespace
|
|
26
|
-
*/
|
|
27
24
|
declare const caches: Record<string, ReturnType<typeof Cache>>;
|
|
25
|
+
export declare function _setFSCacheDir(dir: string): void;
|
|
28
26
|
export declare function getCache(ns: string): (typeof caches)['0'];
|
|
29
27
|
/**
|
|
30
28
|
* try to get father config
|
package/dist/utils.js
CHANGED
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
+
_setFSCacheDir: () => _setFSCacheDir,
|
|
32
33
|
getCache: () => getCache,
|
|
33
34
|
getContentHash: () => getContentHash,
|
|
34
35
|
getFileContentByRegExp: () => getFileContentByRegExp,
|
|
@@ -45,6 +46,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
45
46
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
46
47
|
var import_path = __toESM(require("path"));
|
|
47
48
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
49
|
+
var import_constants = require("./constants");
|
|
48
50
|
function getFileIdFromFsPath(fsPath) {
|
|
49
51
|
return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index)?\.\w+$/g, ""));
|
|
50
52
|
}
|
|
@@ -78,8 +80,11 @@ function parseCodeFrontmatter(raw) {
|
|
|
78
80
|
}
|
|
79
81
|
return { code: frontmatter ? code : raw, frontmatter };
|
|
80
82
|
}
|
|
83
|
+
var cacheDir = import_constants.FS_CACHE_DIR;
|
|
81
84
|
var caches = {};
|
|
82
|
-
|
|
85
|
+
function _setFSCacheDir(dir) {
|
|
86
|
+
cacheDir = dir;
|
|
87
|
+
}
|
|
83
88
|
function getCache(ns) {
|
|
84
89
|
if (process.env.DUMI_CACHE === "none") {
|
|
85
90
|
return { set() {
|
|
@@ -88,7 +93,7 @@ function getCache(ns) {
|
|
|
88
93
|
}, getSync() {
|
|
89
94
|
} };
|
|
90
95
|
}
|
|
91
|
-
return caches[ns] ?? (caches[ns] = (0, import_file_system_cache.default)({ basePath: import_path.default.
|
|
96
|
+
return caches[ns] ?? (caches[ns] = (0, import_file_system_cache.default)({ basePath: import_path.default.resolve(cacheDir, ns) }));
|
|
92
97
|
}
|
|
93
98
|
async function tryFatherBuildConfigs(cwd) {
|
|
94
99
|
let configs = [];
|
|
@@ -133,6 +138,7 @@ function getContentHash(content2, length = 8) {
|
|
|
133
138
|
}
|
|
134
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
140
|
0 && (module.exports = {
|
|
141
|
+
_setFSCacheDir,
|
|
136
142
|
getCache,
|
|
137
143
|
getContentHash,
|
|
138
144
|
getFileContentByRegExp,
|