@rsbuild/plugin-source-build 1.0.1 → 1.0.3

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.
@@ -0,0 +1,23 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import { type ExtraMonorepoStrategies } from './project-utils/index.js';
3
+ import type { Project } from './project.js';
4
+ export declare const PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
5
+ export declare const getSourceInclude: (options: {
6
+ projects: Project[];
7
+ sourceField: string;
8
+ }) => Promise<string[]>;
9
+ export interface PluginSourceBuildOptions {
10
+ /**
11
+ * Used to configure the resolve field of the source code files.
12
+ * @default 'source''
13
+ */
14
+ sourceField?: string;
15
+ /**
16
+ * Whether to read source code or output code first.
17
+ * @default 'source'
18
+ */
19
+ resolvePriority?: 'source' | 'output';
20
+ projectName?: string;
21
+ extraMonorepoStrategies?: ExtraMonorepoStrategies;
22
+ }
23
+ export declare function pluginSourceBuild(options?: PluginSourceBuildOptions): RsbuildPlugin;
@@ -0,0 +1,4 @@
1
+ import type { Project } from '../project.js';
2
+ export type Filter = FilterFunction;
3
+ export type FilterFunction = (projects: Project[]) => Project[] | Promise<Project[]>;
4
+ export declare const filterByField: (fieldName: string, checkExports?: boolean) => FilterFunction;
@@ -0,0 +1,12 @@
1
+ import type { Project } from '../project.js';
2
+ import type { MonorepoAnalyzer } from '../types/index.js';
3
+ import type { Filter } from './filter.js';
4
+ export type ExtraMonorepoStrategies = Record<string, MonorepoAnalyzer>;
5
+ export interface GetDependentProjectsOptions {
6
+ cwd?: string;
7
+ recursive?: boolean;
8
+ filter?: Filter;
9
+ extraMonorepoStrategies?: ExtraMonorepoStrategies;
10
+ }
11
+ declare const getDependentProjects: (projectNameOrRootPath: string, options: GetDependentProjectsOptions) => Promise<Project[]>;
12
+ export { getDependentProjects };
@@ -0,0 +1,2 @@
1
+ export * from './getDependentProjects.js';
2
+ export * from './filter.js';
@@ -0,0 +1,18 @@
1
+ import type { INodePackageJson } from './types/packageJson.js';
2
+ export declare class Project {
3
+ #private;
4
+ name: string;
5
+ dir: string;
6
+ metaData: INodePackageJson;
7
+ constructor(name: string, dir: string);
8
+ init(): Promise<void>;
9
+ getMetaData(): INodePackageJson;
10
+ getDependentProjects(monorepoProjects: Project[], options?: {
11
+ recursive?: boolean;
12
+ }): Project[];
13
+ getDirectDependentProjects(allProjectMap: Map<string, Project>): Project[];
14
+ getSourceEntryPaths(options?: {
15
+ field?: string;
16
+ exports?: boolean;
17
+ }): string[];
18
+ }
@@ -0,0 +1,16 @@
1
+ import type { GetProjectsFunc } from '../common/getProjects.js';
2
+ import type { IsMonorepoFn } from '../common/isMonorepo.js';
3
+ export * from './packageJson.js';
4
+ export * from './rushJson.js';
5
+ export interface MonorepoAnalyzer {
6
+ check: IsMonorepoFn;
7
+ getProjects: GetProjectsFunc;
8
+ }
9
+ export interface IPnpmWorkSpace {
10
+ packages: string[];
11
+ }
12
+ export type TsConfig = {
13
+ references?: Array<{
14
+ path?: string;
15
+ }>;
16
+ };
@@ -1,5 +1,3 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
3
1
  /**
4
2
  * The following code is modified based on
5
3
  * https://github.com/microsoft/rushstack/blob/main/libraries/node-core-library/src/IPackageJson.ts
@@ -13,14 +11,14 @@ import { RsbuildPlugin } from '@rsbuild/core';
13
11
  * "dependencies", "optionalDependencies", and "devDependencies" fields.
14
12
  * @public
15
13
  */
16
- interface IPackageJsonDependencyTable {
14
+ export interface IPackageJsonDependencyTable {
17
15
  /**
18
16
  * The key is the name of a dependency. The value is a Semantic Versioning (SemVer)
19
17
  * range specifier.
20
18
  */
21
19
  [dependencyName: string]: string;
22
20
  }
23
- interface IPackageJsonRepository {
21
+ export interface IPackageJsonRepository {
24
22
  /**
25
23
  * The source control type for the repository that hosts the project. This is typically "git".
26
24
  */
@@ -39,7 +37,7 @@ interface IPackageJsonRepository {
39
37
  * "scripts" field.
40
38
  * @public
41
39
  */
42
- interface IPackageJsonScriptTable {
40
+ export interface IPackageJsonScriptTable {
43
41
  /**
44
42
  * The key is the name of the script hook. The value is the script body which may
45
43
  * be a file path or shell script command.
@@ -51,16 +49,16 @@ interface IPackageJsonScriptTable {
51
49
  * "peerDependenciesMeta" field.
52
50
  * @public
53
51
  */
54
- interface IPeerDependenciesMetaTable {
52
+ export interface IPeerDependenciesMetaTable {
55
53
  [dependencyName: string]: {
56
54
  optional?: boolean;
57
55
  };
58
56
  }
59
- type ExportsModuleRules = string | Record<string, string> | Record<string, string | Record<string, string>>;
60
- interface ExportsConfig {
57
+ export type ExportsModuleRules = string | Record<string, string> | Record<string, string | Record<string, string>>;
58
+ export interface ExportsConfig {
61
59
  [modulePath: string]: ExportsModuleRules;
62
60
  }
63
- interface INodePackageJson {
61
+ export interface INodePackageJson {
64
62
  /**
65
63
  * The name of the package.
66
64
  */
@@ -148,60 +146,7 @@ interface INodePackageJson {
148
146
  */
149
147
  resolutions?: Record<string, string>;
150
148
  }
151
-
152
- declare class Project {
153
- #private;
154
- name: string;
155
- dir: string;
156
- metaData: INodePackageJson;
157
- constructor(name: string, dir: string);
158
- init(): Promise<void>;
159
- getMetaData(): INodePackageJson;
160
- getDependentProjects(monorepoProjects: Project[], options?: {
161
- recursive?: boolean;
162
- }): Project[];
163
- getDirectDependentProjects(allProjectMap: Map<string, Project>): Project[];
164
- getSourceEntryPaths(options?: {
165
- field?: string;
166
- exports?: boolean;
167
- }): string[];
168
- }
169
-
170
- interface IMonorepoBaseData {
171
- isMonorepo: boolean;
172
- type: string;
173
- rootPath: string;
174
- getProjects?: GetProjectsFunc;
175
- }
176
- declare const getMonorepoBaseData: (starFindPath: string, otherMonorepoAnalyzer?: Record<string, MonorepoAnalyzer>) => Promise<IMonorepoBaseData>;
177
-
178
- type GetProjectsFunc = (rootPath: string) => Promise<Project[]> | Project[];
179
- declare const getMonorepoSubProjects: (monorepoBaseData: IMonorepoBaseData) => Promise<Project[]>;
180
-
181
- type IsMonorepoFn = (monorepoRootPath: string) => Promise<boolean> | boolean;
182
-
183
- interface MonorepoAnalyzer {
184
- check: IsMonorepoFn;
185
- getProjects: GetProjectsFunc;
186
- }
187
-
188
- type ExtraMonorepoStrategies = Record<string, MonorepoAnalyzer>;
189
-
190
- declare const PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
191
- interface PluginSourceBuildOptions {
192
- /**
193
- * Used to configure the resolve field of the source code files.
194
- * @default 'source''
195
- */
196
- sourceField?: string;
197
- /**
198
- * Whether to read source code or output code first.
199
- * @default 'source'
200
- */
201
- resolvePriority?: 'source' | 'output';
202
- projectName?: string;
203
- extraMonorepoStrategies?: ExtraMonorepoStrategies;
149
+ export interface IPackageJson extends INodePackageJson {
150
+ /** {@inheritDoc INodePackageJson.version} */
151
+ version: string;
204
152
  }
205
- declare function pluginSourceBuild(options?: PluginSourceBuildOptions): RsbuildPlugin;
206
-
207
- export { type MonorepoAnalyzer, PLUGIN_SOURCE_BUILD_NAME, type PluginSourceBuildOptions, Project, getMonorepoBaseData, getMonorepoSubProjects, pluginSourceBuild };
@@ -0,0 +1,7 @@
1
+ export interface RushConfigurationProject {
2
+ readonly packageName: string;
3
+ readonly projectFolder: string;
4
+ }
5
+ export interface IRushConfig {
6
+ projects?: RushConfigurationProject[];
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { INodePackageJson, IRushConfig } from './types/index.js';
2
+ export declare const readPackageJson: (pkgJsonFilePath: string) => Promise<INodePackageJson>;
3
+ export declare const readRushJson: (rushJsonFilePath: string) => Promise<IRushConfig>;
4
+ export declare const readJson: <T>(jsonFileAbsPath: string) => Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-source-build",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
+ "description": "An Rsbuild plugin to provide support for monorepo source code referencing.",
4
5
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-source-build",
5
6
  "license": "MIT",
6
7
  "type": "module",
@@ -14,9 +15,16 @@
14
15
  "main": "./dist/index.js",
15
16
  "module": "./dist/index.mjs",
16
17
  "types": "./dist/index.d.ts",
17
- "files": [
18
- "dist"
19
- ],
18
+ "files": ["dist"],
19
+ "scripts": {
20
+ "build": "rslib build",
21
+ "dev": "rslib build --watch",
22
+ "lint": "biome check .",
23
+ "lint:write": "biome check . --write",
24
+ "prepare": "simple-git-hooks && npm run build",
25
+ "test": "playwright test",
26
+ "bump": "npx bumpp"
27
+ },
20
28
  "simple-git-hooks": {
21
29
  "pre-commit": "npx nano-staged"
22
30
  },
@@ -26,44 +34,38 @@
26
34
  ]
27
35
  },
28
36
  "dependencies": {
29
- "fast-glob": "^3.3.2",
37
+ "fast-glob": "^3.3.3",
30
38
  "json5": "^2.2.3",
31
- "yaml": "^2.5.0"
39
+ "yaml": "^2.8.0"
32
40
  },
33
41
  "devDependencies": {
34
- "@biomejs/biome": "^1.8.3",
35
- "@playwright/test": "^1.45.3",
36
- "@rsbuild/core": "^1.0.1-beta.8",
37
- "@rsbuild/plugin-react": "1.0.1-beta.10",
38
- "@rsbuild/plugin-type-check": "1.0.1-beta.10",
39
- "@types/node": "^20.14.13",
40
- "@types/react": "^18.3.3",
41
- "@types/react-dom": "^18.3.0",
42
+ "@biomejs/biome": "^1.9.4",
43
+ "@playwright/test": "^1.54.1",
44
+ "@rsbuild/core": "^1.4.12",
45
+ "@rsbuild/plugin-react": "^1.3.4",
46
+ "@rsbuild/plugin-type-check": "^1.2.3",
47
+ "@rslib/core": "^0.11.0",
48
+ "@types/node": "^22.17.0",
49
+ "@types/react": "^19.1.9",
50
+ "@types/react-dom": "^19.1.7",
42
51
  "nano-staged": "^0.8.0",
43
- "playwright": "^1.45.3",
44
- "react": "^18.3.1",
45
- "react-dom": "^18.3.1",
46
- "simple-git-hooks": "^2.11.1",
47
- "tsup": "^8.2.3",
48
- "typescript": "^5.5.4"
52
+ "playwright": "^1.54.1",
53
+ "react": "^19.1.1",
54
+ "react-dom": "^19.1.1",
55
+ "simple-git-hooks": "^2.13.1",
56
+ "typescript": "^5.9.2"
49
57
  },
50
58
  "peerDependencies": {
51
- "@rsbuild/core": "0.x || 1.x || ^1.0.1-beta.0"
59
+ "@rsbuild/core": "1.x"
52
60
  },
53
61
  "peerDependenciesMeta": {
54
62
  "@rsbuild/core": {
55
63
  "optional": true
56
64
  }
57
65
  },
66
+ "packageManager": "pnpm@10.14.0",
58
67
  "publishConfig": {
59
68
  "access": "public",
60
69
  "registry": "https://registry.npmjs.org/"
61
- },
62
- "scripts": {
63
- "build": "tsup",
64
- "dev": "tsup --watch",
65
- "lint": "biome check .",
66
- "lint:write": "biome check . --write",
67
- "test": "playwright test"
68
70
  }
69
- }
71
+ }