@nocobase/build 1.9.45 → 1.9.47

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.
@@ -30,32 +30,76 @@ __export(buildDeclaration_exports, {
30
30
  buildDeclaration: () => buildDeclaration
31
31
  });
32
32
  module.exports = __toCommonJS(buildDeclaration_exports);
33
- var import_gulp = __toESM(require("gulp"));
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 buildDeclaration = (cwd, targetDir) => {
38
- return new Promise((resolve, reject) => {
39
- const srcPath = import_path.default.join(cwd, "src");
40
- const targetPath = import_path.default.join(cwd, targetDir);
41
- const tsConfig = import_gulp_typescript.default.createProject(import_path.default.join(import_constant.ROOT_PATH, "tsconfig.json"));
42
- delete tsConfig.config.compilerOptions.paths;
43
- const patterns = [
44
- import_path.default.join(srcPath, "**/*.{ts,tsx}"),
45
- `!${import_path.default.join(srcPath, "**/fixtures{,/**}")}`,
46
- `!${import_path.default.join(srcPath, "**/demos{,/**}")}`,
47
- `!${import_path.default.join(srcPath, "**/__test__{,/**}")}`,
48
- `!${import_path.default.join(srcPath, "**/__tests__{,/**}")}`,
49
- `!${import_path.default.join(srcPath, "**/__benchmarks__{,/**}")}`,
50
- `!${import_path.default.join(srcPath, "**/__e2e__{,/**}")}`,
51
- `!${import_path.default.join(srcPath, "**/*.mdx")}`,
52
- `!${import_path.default.join(srcPath, "**/*.md")}`,
53
- `!${import_path.default.join(srcPath, "**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)")}`,
54
- `!${import_path.default.join(srcPath, "**/tsconfig{,.*}.json")}`,
55
- `!${import_path.default.join(srcPath, ".umi{,-production,-test}{,/**}")}`
56
- ];
57
- import_gulp.default.src(patterns, { base: srcPath, allowEmpty: true }).pipe((0, import_gulp_typescript.default)(tsConfig.config.compilerOptions)).dts.pipe(import_gulp.default.dest(targetPath)).on("end", resolve).on("error", reject);
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.45",
3
+ "version": "1.9.47",
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": "8342b68c6802281d0394ff90519efc35adefd92d"
54
+ "gitHead": "bc3787003d581cc1453444de53d23c7c41b862d8"
58
55
  }