@rsbuild/plugin-source-build 0.6.15 → 0.7.0-beta.0

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.
@@ -1,19 +1,44 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
3
-
4
-
5
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
6
- import { fileURLToPath } from "url";
7
- import path from "path";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
8
29
 
9
30
  // src/index.ts
10
- import fs from "fs";
11
- import path2 from "path";
12
- import {
13
- filterByField,
14
- getDependentProjects
15
- } from "@rsbuild/monorepo-utils";
16
- import { TS_CONFIG_FILE, fse } from "@rsbuild/shared";
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ PLUGIN_SOURCE_BUILD_NAME: () => PLUGIN_SOURCE_BUILD_NAME,
34
+ getSourceInclude: () => getSourceInclude,
35
+ pluginSourceBuild: () => pluginSourceBuild
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+ var import_node_fs = __toESM(require("fs"));
39
+ var import_node_path = __toESM(require("path"));
40
+ var import_monorepo_utils = require("@rsbuild/monorepo-utils");
41
+ var import_shared = require("@rsbuild/shared");
17
42
  var PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
18
43
  var getSourceInclude = async (options) => {
19
44
  const { projects, sourceField } = options;
@@ -38,10 +63,10 @@ function pluginSourceBuild(options) {
38
63
  const projectRootPath = api.context.rootPath;
39
64
  let projects = [];
40
65
  api.modifyRsbuildConfig(async (config) => {
41
- projects = await getDependentProjects(projectName || projectRootPath, {
66
+ projects = await (0, import_monorepo_utils.getDependentProjects)(projectName || projectRootPath, {
42
67
  cwd: projectRootPath,
43
68
  recursive: true,
44
- filter: filterByField(sourceField, true),
69
+ filter: (0, import_monorepo_utils.filterByField)(sourceField, true),
45
70
  extraMonorepoStrategies
46
71
  });
47
72
  const includes = await getSourceInclude({
@@ -67,11 +92,11 @@ function pluginSourceBuild(options) {
67
92
  }
68
93
  });
69
94
  const getReferences = async () => {
70
- const refers = projects.map((project) => path2.join(project.dir, TS_CONFIG_FILE)).filter((filePath) => fs.existsSync(filePath));
95
+ const refers = projects.map((project) => import_node_path.default.join(project.dir, import_shared.TS_CONFIG_FILE)).filter((filePath) => import_node_fs.default.existsSync(filePath));
71
96
  if (api.context.tsconfigPath) {
72
97
  const { default: json5 } = await import("@rsbuild/shared/json5");
73
98
  const { references } = json5.parse(
74
- fse.readFileSync(api.context.tsconfigPath, "utf-8")
99
+ import_shared.fse.readFileSync(api.context.tsconfigPath, "utf-8")
75
100
  );
76
101
  return Array.isArray(references) ? references.map((r) => r.path).filter(Boolean).concat(refers) : refers;
77
102
  }
@@ -107,8 +132,9 @@ function pluginSourceBuild(options) {
107
132
  }
108
133
  };
109
134
  }
110
- export {
135
+ // Annotate the CommonJS export names for ESM import in node:
136
+ 0 && (module.exports = {
111
137
  PLUGIN_SOURCE_BUILD_NAME,
112
138
  getSourceInclude,
113
139
  pluginSourceBuild
114
- };
140
+ });
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import { Project, ExtraMonorepoStrategies } from '@rsbuild/monorepo-utils';
3
-
4
- declare const PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
5
- declare const getSourceInclude: (options: {
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import { type ExtraMonorepoStrategies, type Project } from '@rsbuild/monorepo-utils';
3
+ export declare const PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
4
+ export declare const getSourceInclude: (options: {
6
5
  projects: Project[];
7
6
  sourceField: string;
8
7
  }) => Promise<string[]>;
9
- interface PluginSourceBuildOptions {
8
+ export interface PluginSourceBuildOptions {
10
9
  /**
11
10
  * Used to configure the resolve field of the source code files.
12
11
  * @default 'source''
@@ -20,6 +19,4 @@ interface PluginSourceBuildOptions {
20
19
  projectName?: string;
21
20
  extraMonorepoStrategies?: ExtraMonorepoStrategies;
22
21
  }
23
- declare function pluginSourceBuild(options?: PluginSourceBuildOptions): RsbuildPlugin;
24
-
25
- export { PLUGIN_SOURCE_BUILD_NAME, type PluginSourceBuildOptions, getSourceInclude, pluginSourceBuild };
22
+ export declare function pluginSourceBuild(options?: PluginSourceBuildOptions): RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,44 +1,19 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
3
+
4
+
5
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
6
+ import { fileURLToPath } from "url";
7
+ import path from "path";
29
8
 
30
9
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- PLUGIN_SOURCE_BUILD_NAME: () => PLUGIN_SOURCE_BUILD_NAME,
34
- getSourceInclude: () => getSourceInclude,
35
- pluginSourceBuild: () => pluginSourceBuild
36
- });
37
- module.exports = __toCommonJS(src_exports);
38
- var import_node_fs = __toESM(require("fs"));
39
- var import_node_path = __toESM(require("path"));
40
- var import_monorepo_utils = require("@rsbuild/monorepo-utils");
41
- var import_shared = require("@rsbuild/shared");
10
+ import fs from "fs";
11
+ import path2 from "path";
12
+ import {
13
+ filterByField,
14
+ getDependentProjects
15
+ } from "@rsbuild/monorepo-utils";
16
+ import { TS_CONFIG_FILE, fse } from "@rsbuild/shared";
42
17
  var PLUGIN_SOURCE_BUILD_NAME = "rsbuild:source-build";
43
18
  var getSourceInclude = async (options) => {
44
19
  const { projects, sourceField } = options;
@@ -63,10 +38,10 @@ function pluginSourceBuild(options) {
63
38
  const projectRootPath = api.context.rootPath;
64
39
  let projects = [];
65
40
  api.modifyRsbuildConfig(async (config) => {
66
- projects = await (0, import_monorepo_utils.getDependentProjects)(projectName || projectRootPath, {
41
+ projects = await getDependentProjects(projectName || projectRootPath, {
67
42
  cwd: projectRootPath,
68
43
  recursive: true,
69
- filter: (0, import_monorepo_utils.filterByField)(sourceField, true),
44
+ filter: filterByField(sourceField, true),
70
45
  extraMonorepoStrategies
71
46
  });
72
47
  const includes = await getSourceInclude({
@@ -92,11 +67,11 @@ function pluginSourceBuild(options) {
92
67
  }
93
68
  });
94
69
  const getReferences = async () => {
95
- const refers = projects.map((project) => import_node_path.default.join(project.dir, import_shared.TS_CONFIG_FILE)).filter((filePath) => import_node_fs.default.existsSync(filePath));
70
+ const refers = projects.map((project) => path2.join(project.dir, TS_CONFIG_FILE)).filter((filePath) => fs.existsSync(filePath));
96
71
  if (api.context.tsconfigPath) {
97
72
  const { default: json5 } = await import("@rsbuild/shared/json5");
98
73
  const { references } = json5.parse(
99
- import_shared.fse.readFileSync(api.context.tsconfigPath, "utf-8")
74
+ fse.readFileSync(api.context.tsconfigPath, "utf-8")
100
75
  );
101
76
  return Array.isArray(references) ? references.map((r) => r.path).filter(Boolean).concat(refers) : refers;
102
77
  }
@@ -132,9 +107,8 @@ function pluginSourceBuild(options) {
132
107
  }
133
108
  };
134
109
  }
135
- // Annotate the CommonJS export names for ESM import in node:
136
- 0 && (module.exports = {
110
+ export {
137
111
  PLUGIN_SOURCE_BUILD_NAME,
138
112
  getSourceInclude,
139
113
  pluginSourceBuild
140
- });
114
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-source-build",
3
- "version": "0.6.15",
3
+ "version": "0.7.0-beta.0",
4
4
  "description": "Source build plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,32 +9,32 @@
9
9
  "directory": "packages/plugin-source-build"
10
10
  },
11
11
  "license": "MIT",
12
- "type": "commonjs",
12
+ "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@rsbuild/monorepo-utils": "0.6.15",
27
- "@rsbuild/shared": "0.6.15"
26
+ "@rsbuild/monorepo-utils": "0.7.0-beta.0",
27
+ "@rsbuild/shared": "0.7.0-beta.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.24.5",
31
31
  "typescript": "^5.4.2",
32
- "@rsbuild/core": "0.6.15",
33
- "@rsbuild/plugin-babel": "0.6.15",
34
- "@scripts/test-helper": "0.6.15"
32
+ "@rsbuild/core": "0.7.0-beta.0",
33
+ "@rsbuild/plugin-babel": "0.7.0-beta.0",
34
+ "@scripts/test-helper": "0.7.0-beta.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "^0.6.15"
37
+ "@rsbuild/core": "^0.7.0-beta.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",