diff --git a/e2e/cases/source-build/components/package.json b/e2e/cases/source-build/components/package.json
index c8298ff517..d363a7de22 100644
--- a/e2e/cases/source-build/components/package.json
+++ b/e2e/cases/source-build/components/package.json
@@ -16,6 +16,7 @@
}
},
"dependencies": {
- "@e2e/source-build-utils": "workspace:*"
+ "@e2e/source-build-utils": "workspace:*",
+ "@e2e/source-build-utils2": "workspace:*"
}
}
diff --git a/e2e/cases/source-build/components/src/card/index.tsx b/e2e/cases/source-build/components/src/card/index.tsx
index e9e1404eb8..5f56061862 100644
--- a/e2e/cases/source-build/components/src/card/index.tsx
+++ b/e2e/cases/source-build/components/src/card/index.tsx
@@ -1,4 +1,5 @@
import { strAdd } from '@e2e/source-build-utils';
+import { toLowerCase } from '@e2e/source-build-utils2';
import './index.less';
export interface CardProps {
@@ -10,7 +11,7 @@ export const Card = (props: CardProps) => {
const { title, content = '' } = props;
return (
-
Card Comp Title: {title}
+
Card Comp Title: {toLowerCase(title)}
{strAdd('Card Comp Content:', content)}
);
diff --git a/e2e/cases/source-build/components/tsconfig.json b/e2e/cases/source-build/components/tsconfig.json
index 42f20c4ab0..e0d3f233aa 100644
--- a/e2e/cases/source-build/components/tsconfig.json
+++ b/e2e/cases/source-build/components/tsconfig.json
@@ -16,6 +16,9 @@
"references": [
{
"path": "../utils"
+ },
+ {
+ "path": "../utils2"
}
],
"include": ["src"]
diff --git a/e2e/cases/source-build/index.test.ts b/e2e/cases/source-build/index.test.ts
index df1b32cd8e..516c6178ca 100644
--- a/e2e/cases/source-build/index.test.ts
+++ b/e2e/cases/source-build/index.test.ts
@@ -16,7 +16,7 @@ rspackOnlyTest(
const locator = page.locator('#root');
await expect(locator).toHaveText(
- 'Card Comp Title: AppCARD COMP CONTENT:hello world',
+ 'Card Comp Title: appCARD COMP CONTENT:hello world',
);
await rsbuild.close();
diff --git a/e2e/cases/source-build/utils2/package.json b/e2e/cases/source-build/utils2/package.json
new file mode 100644
index 0000000000..1c98ff7d6a
--- /dev/null
+++ b/e2e/cases/source-build/utils2/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "@e2e/source-build-utils2",
+ "private": true,
+ "version": "1.0.0",
+ "types": "./dist/types/index.d.ts",
+ "exports": {
+ "types": "./dist/types/index.d.ts",
+ "source": "./src/index.ts"
+ }
+}
diff --git a/e2e/cases/source-build/utils2/src/common/index.ts b/e2e/cases/source-build/utils2/src/common/index.ts
new file mode 100644
index 0000000000..76e0194767
--- /dev/null
+++ b/e2e/cases/source-build/utils2/src/common/index.ts
@@ -0,0 +1,2 @@
+export * from './toUpperCase';
+export * from './toLowerCase';
diff --git a/e2e/cases/source-build/utils2/src/common/toLowerCase.ts b/e2e/cases/source-build/utils2/src/common/toLowerCase.ts
new file mode 100644
index 0000000000..8b59e30792
--- /dev/null
+++ b/e2e/cases/source-build/utils2/src/common/toLowerCase.ts
@@ -0,0 +1 @@
+export const toLowerCase = (s: string) => s.toLowerCase();
diff --git a/e2e/cases/source-build/utils2/src/common/toUpperCase.ts b/e2e/cases/source-build/utils2/src/common/toUpperCase.ts
new file mode 100644
index 0000000000..217125d1f6
--- /dev/null
+++ b/e2e/cases/source-build/utils2/src/common/toUpperCase.ts
@@ -0,0 +1 @@
+export const toUpperCase = (s: string) => s.toUpperCase();
diff --git a/e2e/cases/source-build/utils2/src/index.ts b/e2e/cases/source-build/utils2/src/index.ts
new file mode 100644
index 0000000000..ad37aa8561
--- /dev/null
+++ b/e2e/cases/source-build/utils2/src/index.ts
@@ -0,0 +1,3 @@
+import { toLowerCase } from '@common/index';
+
+export { toLowerCase };
diff --git a/e2e/cases/source-build/utils2/tsconfig.json b/e2e/cases/source-build/utils2/tsconfig.json
new file mode 100644
index 0000000000..f87a29abac
--- /dev/null
+++ b/e2e/cases/source-build/utils2/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "extends": "@rsbuild/config/tsconfig",
+ "compilerOptions": {
+ "composite": true,
+ "declaration": true,
+ "declarationDir": "./dist/types",
+ "declarationMap": true,
+ "jsx": "react-jsx",
+ "baseUrl": "./",
+ "paths": {
+ "@/*": ["./src/*"],
+ "@common/*": ["./src/common/*"]
+ },
+ "outDir": "./dist",
+ "rootDir": "./src"
+ },
+ "include": ["src"]
+}
diff --git a/packages/plugin-source-build/src/project-utils/filter.ts b/packages/plugin-source-build/src/project-utils/filter.ts
index 160368d750..66bf6ba01e 100644
--- a/packages/plugin-source-build/src/project-utils/filter.ts
+++ b/packages/plugin-source-build/src/project-utils/filter.ts
@@ -10,15 +10,16 @@ function hasExportsSourceField(
exportsConfig: ExportsConfig,
sourceField: string,
) {
- return Object.values(exportsConfig).some(
- (moduleRules) =>
- typeof moduleRules === 'object' &&
- typeof moduleRules[sourceField] === 'string',
+ return (
+ typeof exportsConfig[sourceField] === 'string' ||
+ Object.values(exportsConfig).some(
+ (moduleRules) =>
+ typeof moduleRules === 'object' &&
+ typeof moduleRules[sourceField] === 'string',
+ )
);
}
-export const defaultFilter: FilterFunction = (projects) => projects;
-
export const filterByField =
(fieldName: string, checkExports?: boolean): FilterFunction =>
(projects: Project[]) => {
diff --git a/packages/plugin-source-build/src/project-utils/getDependentProjects.ts b/packages/plugin-source-build/src/project-utils/getDependentProjects.ts
index 8e476043b0..a21e6b2b21 100644
--- a/packages/plugin-source-build/src/project-utils/getDependentProjects.ts
+++ b/packages/plugin-source-build/src/project-utils/getDependentProjects.ts
@@ -1,10 +1,9 @@
import fs from 'node:fs';
import path from 'node:path';
import { getMonorepoBaseData, getMonorepoSubProjects } from '../common';
-import type { Project } from '../project/project';
import type { MonorepoAnalyzer } from '../types';
import { readPackageJson } from '../utils';
-import { type Filter, defaultFilter } from './filter';
+import type { Filter } from './filter';
export type ExtraMonorepoStrategies = Record;
@@ -23,14 +22,6 @@ async function pathExists(path: string) {
.catch(() => false);
}
-const filterProjects = async (projects: Project[], filter?: Filter) => {
- if (!filter) {
- return defaultFilter(projects);
- }
-
- return filter(projects);
-};
-
const getDependentProjects = async (
projectNameOrRootPath: string,
options: GetDependentProjectsOptions,
@@ -72,7 +63,9 @@ const getDependentProjects = async (
let dependentProjects = currentProject.getDependentProjects(projects, {
recursive,
});
- dependentProjects = await filterProjects(dependentProjects, filter);
+ if (filter) {
+ dependentProjects = await filter(dependentProjects);
+ }
return dependentProjects;
};
diff --git a/packages/plugin-source-build/src/project/project.ts b/packages/plugin-source-build/src/project/project.ts
index 1636b70717..4234f969ec 100644
--- a/packages/plugin-source-build/src/project/project.ts
+++ b/packages/plugin-source-build/src/project/project.ts
@@ -128,6 +128,12 @@ export class Project {
#getExportsSourceDirs(exportsConfig: ExportsConfig, sourceField: string) {
const exportsSourceDirs: string[] = [];
+ if (typeof exportsConfig[sourceField] === 'string') {
+ exportsSourceDirs.push(
+ path.normalize(exportsConfig[sourceField] as string),
+ );
+ }
+
for (const moduleRules of Object.values(exportsConfig)) {
if (
typeof moduleRules === 'object' &&
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1736a7c6ca..fa1ba21d1c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -302,9 +302,14 @@ importers:
'@e2e/source-build-utils':
specifier: workspace:*
version: link:../utils
+ '@e2e/source-build-utils2':
+ specifier: workspace:*
+ version: link:../utils2
e2e/cases/source-build/utils: {}
+ e2e/cases/source-build/utils2: {}
+
e2e/cases/source-map:
dependencies:
react: