@ray-js/builder-component 1.7.9 → 1.7.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/lib/build.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CliOptions } from '@ray-js/types';
1
+ import type { CliOptions } from '@ray-js/types';
2
2
  type Options = Pick<CliOptions, 'source' | 'output' | 'watch'> & {
3
3
  cwd: string;
4
4
  transformMode: 'pure' | 'auto';
package/lib/build.js CHANGED
@@ -13,11 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.default = build;
16
+ const path_1 = __importDefault(require("path"));
16
17
  const chokidar_1 = __importDefault(require("chokidar"));
17
18
  const colors_1 = __importDefault(require("colors"));
18
19
  const globby_1 = __importDefault(require("globby"));
19
- const path_1 = __importDefault(require("path"));
20
20
  const shared_1 = require("@ray-js/shared");
21
+ const fs_1 = require("fs");
22
+ const node_fs_1 = require("node:fs");
21
23
  const transform_1 = require("./transform");
22
24
  colors_1.default.enable();
23
25
  const LOG_PREFIX = 'builder-component';
@@ -29,6 +31,17 @@ function build(options) {
29
31
  const emitDTS = (0, transform_1.generateDTS)((file, content) => {
30
32
  const fileBase = path_1.default.relative(sourceDir, file);
31
33
  const dtsFilePath = path_1.default.join(outputDir, fileBase);
34
+ const sourceFile = path_1.default.join(sourceDir, fileBase.replace('.d.ts', '.ts'));
35
+ if ((0, node_fs_1.existsSync)(sourceFile)) {
36
+ const sourceFileContent = (0, fs_1.readFileSync)(sourceFile, 'utf-8');
37
+ // 匹配 /// <reference ... 文本
38
+ const referenceComment = sourceFileContent.match(/\/\/\/\s*<reference\s+[^>]+>/gm);
39
+ if (referenceComment) {
40
+ referenceComment.forEach((comment) => {
41
+ content = comment + '\n' + content;
42
+ });
43
+ }
44
+ }
32
45
  (0, shared_1.writeFileSync)(dtsFilePath, content);
33
46
  shared_1.log.verbose(LOG_PREFIX, fileBase.gray);
34
47
  });
@@ -1,5 +1,5 @@
1
1
  import type { Modules } from '@ray-js/babel-preset-standard';
2
- import { Target } from '@ray-js/types';
2
+ import type { Target } from '@ray-js/types';
3
3
  /**
4
4
  * 因匿名化需要将 tuya => thing
5
5
  * 但历史项目仍需要支持
@@ -14,8 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.legacyTarget = void 0;
16
16
  exports.default = babelTransform;
17
- const fs_extra_1 = __importDefault(require("fs-extra"));
18
17
  const core_1 = require("@babel/core");
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
19
  /**
20
20
  * 因匿名化需要将 tuya => thing
21
21
  * 但历史项目仍需要支持
@@ -1,4 +1,4 @@
1
- import { TransformOptions, TransformMode } from '@ray-js/types';
1
+ import { type TransformMode, type TransformOptions } from '@ray-js/types';
2
2
  export { generateDTS } from './type';
3
3
  /***
4
4
  * 根据原文件,移除对应生成的平台文件
@@ -48,13 +48,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.generateDTS = void 0;
49
49
  exports.unlinkPlatformFiles = unlinkPlatformFiles;
50
50
  exports.transformPlatformFiles = transformPlatformFiles;
51
- const colors_1 = __importDefault(require("colors"));
52
- const fs_extra_1 = __importDefault(require("fs-extra"));
53
51
  const path_1 = __importDefault(require("path"));
54
52
  const shared_1 = require("@ray-js/shared");
55
53
  const types_1 = require("@ray-js/types");
56
- const babelTransform_1 = __importStar(require("./babelTransform"));
54
+ const colors_1 = __importDefault(require("colors"));
55
+ const fs_extra_1 = __importDefault(require("fs-extra"));
57
56
  const helper_1 = require("../helper");
57
+ const babelTransform_1 = __importStar(require("./babelTransform"));
58
58
  var type_1 = require("./type");
59
59
  Object.defineProperty(exports, "generateDTS", { enumerable: true, get: function () { return type_1.generateDTS; } });
60
60
  colors_1.default.enable();
@@ -118,7 +118,7 @@ function unlinkPlatformFiles(options) {
118
118
  const { groups } = matched;
119
119
  plt = groups.target;
120
120
  }
121
- let unlinkPaths = [];
121
+ const unlinkPaths = [];
122
122
  // js 文件
123
123
  if (jsFileExt.includes(ext) && ext !== '.d.ts') {
124
124
  if (mode == 'pure') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/builder-component",
3
- "version": "1.7.9",
3
+ "version": "1.7.10",
4
4
  "description": "Ray builder for component",
5
5
  "keywords": [
6
6
  "ray"
@@ -20,16 +20,17 @@
20
20
  "scripts": {
21
21
  "build": "tsc -p ./tsconfig.build.json",
22
22
  "clean": "rm -rf lib esm dts",
23
- "watch": "tsc -p ./tsconfig.build.json --watch"
23
+ "watch": "tsc -p ./tsconfig.build.json --watch",
24
+ "test": "vitest --run"
24
25
  },
25
26
  "dependencies": {
26
27
  "@babel/core": "^7.26.10",
27
28
  "@babel/helper-plugin-utils": "^7.26.5",
28
29
  "@babel/traverse": "^7.27.0",
29
30
  "@babel/types": "^7.27.0",
30
- "@ray-js/babel-preset-standard": "1.7.9",
31
- "@ray-js/shared": "1.7.9",
32
- "@ray-js/types": "1.7.9",
31
+ "@ray-js/babel-preset-standard": "1.7.10",
32
+ "@ray-js/shared": "1.7.10",
33
+ "@ray-js/types": "1.7.10",
33
34
  "babel-plugin-import": "^1.13.8",
34
35
  "chokidar": "^3.6.0",
35
36
  "colors": "1.4.0",
@@ -38,11 +39,12 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/fs-extra": "^11.0.4",
41
- "typescript": "^5.8.3"
42
+ "typescript": "^5.8.3",
43
+ "vitest": "^3.1.3"
42
44
  },
43
45
  "publishConfig": {
44
46
  "access": "public",
45
47
  "registry": "https://registry.npmjs.com"
46
48
  },
47
- "gitHead": "d39e56928dfec12ff41e0f9d81c3987334c2d650"
49
+ "gitHead": "47adc13b06111a27e3a719a1e02dd118c6e365d9"
48
50
  }