@nocobase/build 1.9.46 → 1.9.49
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/lib/buildDeclaration.js +67 -23
- package/package.json +2 -5
package/lib/buildDeclaration.js
CHANGED
|
@@ -30,32 +30,76 @@ __export(buildDeclaration_exports, {
|
|
|
30
30
|
buildDeclaration: () => buildDeclaration
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(buildDeclaration_exports);
|
|
33
|
-
var
|
|
34
|
-
var import_gulp_typescript = __toESM(require("gulp-typescript"));
|
|
33
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
35
34
|
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_typescript = __toESM(require("typescript"));
|
|
36
36
|
var import_constant = require("./constant");
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
const INCLUDE_PATTERNS = ["**/*.{ts,tsx}"];
|
|
38
|
+
const EXCLUDE_PATTERNS = [
|
|
39
|
+
"**/fixtures{,/**}",
|
|
40
|
+
"**/demos{,/**}",
|
|
41
|
+
"**/__test__{,/**}",
|
|
42
|
+
"**/__tests__{,/**}",
|
|
43
|
+
"**/__benchmarks__{,/**}",
|
|
44
|
+
"**/__e2e__{,/**}",
|
|
45
|
+
"**/*.mdx",
|
|
46
|
+
"**/*.md",
|
|
47
|
+
"**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)",
|
|
48
|
+
"**/tsconfig{,.*}.json",
|
|
49
|
+
".umi{,-production,-test}{,/**}"
|
|
50
|
+
];
|
|
51
|
+
const diagnosticHost = {
|
|
52
|
+
getCurrentDirectory: () => process.cwd(),
|
|
53
|
+
getCanonicalFileName: (fileName) => import_typescript.default.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
54
|
+
getNewLine: () => import_typescript.default.sys.newLine
|
|
55
|
+
};
|
|
56
|
+
function loadCompilerOptions() {
|
|
57
|
+
const configPath = import_path.default.join(import_constant.ROOT_PATH, "tsconfig.json");
|
|
58
|
+
const configFile = import_typescript.default.readConfigFile(configPath, import_typescript.default.sys.readFile);
|
|
59
|
+
if (configFile.error) {
|
|
60
|
+
throw new Error(import_typescript.default.formatDiagnosticsWithColorAndContext([configFile.error], diagnosticHost));
|
|
61
|
+
}
|
|
62
|
+
const parsedConfig = import_typescript.default.parseJsonConfigFileContent(
|
|
63
|
+
configFile.config,
|
|
64
|
+
import_typescript.default.sys,
|
|
65
|
+
import_path.default.dirname(configPath),
|
|
66
|
+
void 0,
|
|
67
|
+
configPath
|
|
68
|
+
);
|
|
69
|
+
const options = {
|
|
70
|
+
...parsedConfig.options
|
|
71
|
+
};
|
|
72
|
+
delete options.paths;
|
|
73
|
+
return options;
|
|
74
|
+
}
|
|
75
|
+
const buildDeclaration = async (cwd, targetDir) => {
|
|
76
|
+
const srcPath = import_path.default.join(cwd, "src");
|
|
77
|
+
const targetPath = import_path.default.join(cwd, targetDir);
|
|
78
|
+
const files = await (0, import_fast_glob.default)(INCLUDE_PATTERNS, {
|
|
79
|
+
cwd: srcPath,
|
|
80
|
+
ignore: EXCLUDE_PATTERNS,
|
|
81
|
+
absolute: true,
|
|
82
|
+
dot: true
|
|
58
83
|
});
|
|
84
|
+
if (!files.length) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const compilerOptions = {
|
|
88
|
+
...loadCompilerOptions(),
|
|
89
|
+
declaration: true,
|
|
90
|
+
emitDeclarationOnly: true,
|
|
91
|
+
declarationDir: targetPath,
|
|
92
|
+
outDir: targetPath,
|
|
93
|
+
rootDir: srcPath
|
|
94
|
+
};
|
|
95
|
+
const program = import_typescript.default.createProgram(files, compilerOptions);
|
|
96
|
+
const emitResult = program.emit(void 0, void 0, void 0, true);
|
|
97
|
+
const diagnostics = import_typescript.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
98
|
+
if (diagnostics.length) {
|
|
99
|
+
const details = import_typescript.default.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticHost);
|
|
100
|
+
throw new Error(`Failed to build declarations for ${cwd}
|
|
101
|
+
${details}`);
|
|
102
|
+
}
|
|
59
103
|
};
|
|
60
104
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
105
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/build",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.49",
|
|
4
4
|
"description": "Library build tool based on rollup.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"@rsdoctor/rspack-plugin": "^0.4.8",
|
|
20
20
|
"@rspack/core": "1.3.2",
|
|
21
21
|
"@svgr/webpack": "^8.1.0",
|
|
22
|
-
"@types/gulp": "^4.0.13",
|
|
23
22
|
"@types/lerna__package": "5.1.0",
|
|
24
23
|
"@types/lerna__project": "5.1.0",
|
|
25
24
|
"@types/tar": "^6.1.5",
|
|
@@ -31,8 +30,6 @@
|
|
|
31
30
|
"css-loader": "^6.8.1",
|
|
32
31
|
"esbuild-register": "^3.4.2",
|
|
33
32
|
"fast-glob": "^3.3.1",
|
|
34
|
-
"gulp": "4.0.2",
|
|
35
|
-
"gulp-typescript": "6.0.0-alpha.1",
|
|
36
33
|
"javascript-obfuscator": "^4.1.1",
|
|
37
34
|
"less": "^4.2.0",
|
|
38
35
|
"less-loader": "^12.2.0",
|
|
@@ -54,5 +51,5 @@
|
|
|
54
51
|
"build": "tsup",
|
|
55
52
|
"build:watch": "tsup --watch"
|
|
56
53
|
},
|
|
57
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b90fa583f837a84067c354a72574e738cc6c3281"
|
|
58
55
|
}
|