dumi 2.2.9 → 2.2.10
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/features/derivative.js +32 -32
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ function safeExcludeInMFSU(api, excludes) {
|
|
|
65
65
|
var derivative_default = (api) => {
|
|
66
66
|
api.describe({ key: "dumi:derivative" });
|
|
67
67
|
api.onCheck(() => {
|
|
68
|
-
var _a, _b, _c, _d, _e;
|
|
68
|
+
var _a, _b, _c, _d, _e, _f;
|
|
69
69
|
[
|
|
70
70
|
"clientLoader",
|
|
71
71
|
"deadCode",
|
|
@@ -115,45 +115,45 @@ var derivative_default = (api) => {
|
|
|
115
115
|
try {
|
|
116
116
|
const tsconfigPath = import_path.default.join(api.cwd, "tsconfig.json");
|
|
117
117
|
const tsconfig = require(tsconfigPath);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
[
|
|
124
|
-
(_c = api.appData.globalJS) == null ? void 0 : _c[0],
|
|
125
|
-
api.appData.globalLoading,
|
|
126
|
-
(_d = api.appData.appJS) == null ? void 0 : _d.path
|
|
127
|
-
].forEach((file) => {
|
|
128
|
-
if (file && /([\\/])\.dumi\1.*\.tsx?$/.test(file)) {
|
|
129
|
-
expected.push((0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, file)));
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
if (import_fs.default.existsSync(import_path.default.join(api.cwd, import_constants.LOCAL_THEME_DIR))) {
|
|
133
|
-
expected.push(`${import_constants.LOCAL_THEME_DIR}/**/*`);
|
|
134
|
-
}
|
|
135
|
-
if ((_e = tsconfig.include) == null ? void 0 : _e.includes(".dumi/**/*")) {
|
|
136
|
-
tsconfig.include.splice(
|
|
137
|
-
tsconfig.include.indexOf(".dumi/**/*"),
|
|
138
|
-
1,
|
|
139
|
-
...expected.filter((f) => !tsconfig.include.includes(f))
|
|
118
|
+
const dotDumiWildcard = `${import_constants.LOCAL_DUMI_DIR}/**/*`;
|
|
119
|
+
if ((_b = tsconfig.include) == null ? void 0 : _b.includes(dotDumiWildcard)) {
|
|
120
|
+
tsconfig.include = tsconfig.include.filter(
|
|
121
|
+
(i) => i !== dotDumiWildcard
|
|
140
122
|
);
|
|
141
123
|
import_fs.default.writeFileSync(
|
|
142
124
|
tsconfigPath,
|
|
143
125
|
JSON.stringify(tsconfig, null, 2),
|
|
144
126
|
"utf-8"
|
|
145
127
|
);
|
|
146
|
-
import_plugin_utils.logger.
|
|
147
|
-
|
|
128
|
+
import_plugin_utils.logger.info(
|
|
129
|
+
`tsconfig.json \`include\` option has been patched automatically, please check and commit it.
|
|
130
|
+
${import_plugin_utils.chalk.grey("see also: https://github.com/umijs/dumi/pull/1902")}`
|
|
148
131
|
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
132
|
+
}
|
|
133
|
+
const dotDumiPath = import_path.default.join(api.cwd, import_constants.LOCAL_DUMI_DIR);
|
|
134
|
+
const dotDumiTsconfigPath = import_path.default.join(dotDumiPath, "tsconfig.json");
|
|
135
|
+
const hasDotDumiTsFiles = import_fs.default.existsSync(dotDumiPath) && import_fs.default.readdirSync(dotDumiPath).some(
|
|
136
|
+
(f) => import_constants.LOCAL_PAGES_DIR.endsWith(`/${f}`) || import_constants.LOCAL_THEME_DIR.endsWith(`/${f}`) || /\.tsx?$/.test(f)
|
|
137
|
+
);
|
|
138
|
+
if (hasDotDumiTsFiles && !import_fs.default.existsSync(dotDumiTsconfigPath) && !((_c = tsconfig.include) == null ? void 0 : _c.some((i) => /(\.\/)?.dumi\//.test(i)))) {
|
|
139
|
+
import_fs.default.writeFileSync(
|
|
140
|
+
dotDumiTsconfigPath,
|
|
141
|
+
JSON.stringify(
|
|
142
|
+
{ extends: "../tsconfig.json", include: ["**/*"] },
|
|
143
|
+
null,
|
|
144
|
+
2
|
|
145
|
+
),
|
|
146
|
+
"utf-8"
|
|
147
|
+
);
|
|
148
|
+
import_plugin_utils.logger.info(
|
|
149
|
+
"In order to make type prompt works for theme files, .dumi/tsconfig.json has been created automatically, please check and commit it."
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
const configFileName = ((_d = api.service.configManager) == null ? void 0 : _d.mainConfigFile) && import_path.default.basename((_e = api.service.configManager) == null ? void 0 : _e.mainConfigFile);
|
|
153
|
+
if (configFileName && // only .dumirc.ts need to be included in the root tsconfig.json, because the dot files will be excluded by default
|
|
154
|
+
/^\..+\.ts$/.test(configFileName) && !((_f = tsconfig.include) == null ? void 0 : _f.includes(configFileName))) {
|
|
153
155
|
import_plugin_utils.logger.warn(
|
|
154
|
-
`Please append
|
|
155
|
-
", "
|
|
156
|
-
)} into \`include\` option of tsconfig.json, to make sure the type prompt works for ${expected.length > 1 ? "them" : "it"}.`
|
|
156
|
+
`Please append \`${configFileName}\` into \`include\` option of tsconfig.json, to make sure the type prompt works for it.`
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
} catch {
|