@rsbuild/plugin-source-build 1.0.1 → 1.0.2
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/README.md +11 -4
- package/README.zh-CN.md +11 -4
- package/dist/common/getBaseData.d.ts +9 -0
- package/dist/common/getProjects.d.ts +4 -0
- package/dist/common/index.d.ts +6 -0
- package/dist/common/isMonorepo.d.ts +8 -0
- package/dist/common/pnpm.d.ts +2 -0
- package/dist/common/rush.d.ts +2 -0
- package/dist/constants.d.ts +3 -0
- package/dist/index.cjs +442 -522
- package/dist/index.d.ts +4 -207
- package/dist/index.js +363 -485
- package/dist/plugin.d.ts +23 -0
- package/dist/project-utils/filter.d.ts +4 -0
- package/dist/project-utils/getDependentProjects.d.ts +12 -0
- package/dist/project-utils/index.d.ts +2 -0
- package/dist/project.d.ts +18 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/{index.d.cts → types/packageJson.d.ts} +10 -65
- package/dist/types/rushJson.d.ts +7 -0
- package/dist/utils.d.ts +4 -0
- package/package.json +27 -25
package/dist/index.cjs
CHANGED
|
@@ -1,567 +1,487 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
yaml: function(module) {
|
|
4
|
+
module.exports = import("yaml");
|
|
5
|
+
}
|
|
19
6
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
7
|
+
/************************************************************************/ // The module cache
|
|
8
|
+
var __webpack_module_cache__ = {};
|
|
9
|
+
// The require function
|
|
10
|
+
function __webpack_require__(moduleId) {
|
|
11
|
+
// Check if module is in cache
|
|
12
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
+
// Create a new module (and put it into the cache)
|
|
15
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
16
|
+
exports: {}
|
|
17
|
+
};
|
|
18
|
+
// Execute the module function
|
|
19
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
20
|
+
// Return the exports of the module
|
|
21
|
+
return module.exports;
|
|
22
|
+
}
|
|
23
|
+
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
24
|
+
(()=>{
|
|
25
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
26
|
+
__webpack_require__.n = function(module) {
|
|
27
|
+
var getter = module && module.__esModule ? function() {
|
|
28
|
+
return module['default'];
|
|
29
|
+
} : function() {
|
|
30
|
+
return module;
|
|
31
|
+
};
|
|
32
|
+
__webpack_require__.d(getter, {
|
|
33
|
+
a: getter
|
|
34
|
+
});
|
|
35
|
+
return getter;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
// webpack/runtime/define_property_getters
|
|
39
|
+
(()=>{
|
|
40
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
41
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: definition[key]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
// webpack/runtime/has_own_property
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.o = function(obj, prop) {
|
|
50
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
// webpack/runtime/make_namespace_object
|
|
54
|
+
(()=>{
|
|
55
|
+
// define __esModule on exports
|
|
56
|
+
__webpack_require__.r = function(exports1) {
|
|
57
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
58
|
+
value: 'Module'
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
61
|
+
value: true
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
})();
|
|
65
|
+
/************************************************************************/ var __webpack_exports__ = {};
|
|
66
|
+
// ESM COMPAT FLAG
|
|
67
|
+
__webpack_require__.r(__webpack_exports__);
|
|
68
|
+
// EXPORTS
|
|
69
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
70
|
+
getMonorepoBaseData: ()=>/* reexport */ getMonorepoBaseData,
|
|
71
|
+
PLUGIN_SOURCE_BUILD_NAME: ()=>/* reexport */ PLUGIN_SOURCE_BUILD_NAME,
|
|
72
|
+
pluginSourceBuild: ()=>/* reexport */ pluginSourceBuild,
|
|
73
|
+
getMonorepoSubProjects: ()=>/* reexport */ getMonorepoSubProjects,
|
|
74
|
+
Project: ()=>/* reexport */ Project
|
|
38
75
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// src/common/getBaseData.ts
|
|
51
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
52
|
-
|
|
53
|
-
// src/common/isMonorepo.ts
|
|
54
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
55
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
56
|
-
|
|
57
|
-
// src/constants.ts
|
|
58
|
-
var PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
59
|
-
var RUSH_JSON_FILE = "rush.json";
|
|
60
|
-
var PACKAGE_JSON = "package.json";
|
|
61
|
-
|
|
62
|
-
// src/common/isMonorepo.ts
|
|
63
|
-
async function pathExists(path9) {
|
|
64
|
-
return import_node_fs.default.promises.access(path9).then(() => true).catch(() => false);
|
|
76
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
77
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
78
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
79
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
80
|
+
const external_json5_namespaceObject = require("json5");
|
|
81
|
+
var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
|
|
82
|
+
const PNPM_WORKSPACE_FILE = 'pnpm-workspace.yaml';
|
|
83
|
+
const RUSH_JSON_FILE = 'rush.json';
|
|
84
|
+
const PACKAGE_JSON = 'package.json';
|
|
85
|
+
async function pathExists(path) {
|
|
86
|
+
return external_node_fs_default().promises.access(path).then(()=>true).catch(()=>false);
|
|
65
87
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
return existPnpmWorkspaceFile;
|
|
88
|
+
const isPnpmMonorepo = async (monorepoRootPath)=>{
|
|
89
|
+
const existPnpmWorkspaceFile = await pathExists(external_node_path_default().join(monorepoRootPath, PNPM_WORKSPACE_FILE));
|
|
90
|
+
return existPnpmWorkspaceFile;
|
|
71
91
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
return existRushJsonFile;
|
|
92
|
+
const isRushMonorepo = async (monorepoRootPath)=>{
|
|
93
|
+
const existRushJsonFile = await pathExists(external_node_path_default().join(monorepoRootPath, RUSH_JSON_FILE));
|
|
94
|
+
return existRushJsonFile;
|
|
77
95
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (typeof monorepoCheck === "function" && await monorepoCheck(monorepoRootPath)) {
|
|
84
|
-
return {
|
|
85
|
-
isMonorepo: true,
|
|
86
|
-
type: monorepoType
|
|
96
|
+
const isMonorepo = async (monorepoRootPath, otherMonorepoChecks)=>{
|
|
97
|
+
if ('object' == typeof otherMonorepoChecks) {
|
|
98
|
+
for (const [monorepoType, monorepoCheck] of Object.entries(otherMonorepoChecks))if ('function' == typeof monorepoCheck && await monorepoCheck(monorepoRootPath)) return {
|
|
99
|
+
isMonorepo: true,
|
|
100
|
+
type: monorepoType
|
|
87
101
|
};
|
|
88
|
-
}
|
|
89
102
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
if (await isPnpmMonorepo(monorepoRootPath)) return {
|
|
104
|
+
isMonorepo: true,
|
|
105
|
+
type: 'pnpm'
|
|
106
|
+
};
|
|
107
|
+
if (await isRushMonorepo(monorepoRootPath)) return {
|
|
108
|
+
isMonorepo: true,
|
|
109
|
+
type: 'rush'
|
|
95
110
|
};
|
|
96
|
-
}
|
|
97
|
-
if (await isRushMonorepo(monorepoRootPath)) {
|
|
98
111
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
isMonorepo: false,
|
|
113
|
+
type: ''
|
|
101
114
|
};
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
isMonorepo: false,
|
|
105
|
-
type: ""
|
|
106
|
-
};
|
|
107
115
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
for (const [monoType, analyzer] of Object.entries(otherMonorepoAnalyzer)) {
|
|
118
|
-
otherMonorepoChecks[monoType] = analyzer.check;
|
|
116
|
+
const getMonorepoBaseData = async (starFindPath, otherMonorepoAnalyzer)=>{
|
|
117
|
+
var _otherMonorepoAnalyzer_type;
|
|
118
|
+
let repoIsMonorepo = false;
|
|
119
|
+
let findPath = starFindPath;
|
|
120
|
+
let type = '';
|
|
121
|
+
let otherMonorepoChecks;
|
|
122
|
+
if (otherMonorepoAnalyzer) {
|
|
123
|
+
otherMonorepoChecks = otherMonorepoChecks ?? {};
|
|
124
|
+
for (const [monoType, analyzer] of Object.entries(otherMonorepoAnalyzer))otherMonorepoChecks[monoType] = analyzer.check;
|
|
119
125
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
while(true){
|
|
127
|
+
const result = await isMonorepo(findPath, otherMonorepoChecks);
|
|
128
|
+
if (result.isMonorepo) {
|
|
129
|
+
repoIsMonorepo = true;
|
|
130
|
+
({ type } = result);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
// find system root path
|
|
134
|
+
if (findPath === external_node_path_default().dirname(findPath)) break;
|
|
135
|
+
findPath = external_node_path_default().dirname(findPath);
|
|
130
136
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
getProjects: otherMonorepoAnalyzer?.[type]?.getProjects
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/common/pnpm.ts
|
|
142
|
-
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
143
|
-
var import_node_path5 = __toESM(require("path"), 1);
|
|
144
|
-
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
145
|
-
|
|
146
|
-
// src/project.ts
|
|
147
|
-
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
148
|
-
var import_node_path4 = __toESM(require("path"), 1);
|
|
149
|
-
|
|
150
|
-
// src/utils.ts
|
|
151
|
-
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
152
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
153
|
-
var import_json5 = __toESM(require("json5"), 1);
|
|
154
|
-
var readPackageJson = async (pkgJsonFilePath) => {
|
|
155
|
-
return readJson(pkgJsonFilePath);
|
|
137
|
+
return {
|
|
138
|
+
isMonorepo: repoIsMonorepo,
|
|
139
|
+
rootPath: repoIsMonorepo ? findPath : '',
|
|
140
|
+
type,
|
|
141
|
+
getProjects: null == otherMonorepoAnalyzer ? void 0 : null === (_otherMonorepoAnalyzer_type = otherMonorepoAnalyzer[type]) || void 0 === _otherMonorepoAnalyzer_type ? void 0 : _otherMonorepoAnalyzer_type.getProjects
|
|
142
|
+
};
|
|
156
143
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
const external_fast_glob_namespaceObject = require("fast-glob");
|
|
145
|
+
var external_fast_glob_default = /*#__PURE__*/ __webpack_require__.n(external_fast_glob_namespaceObject);
|
|
146
|
+
const readPackageJson = async (pkgJsonFilePath)=>readJson(pkgJsonFilePath);
|
|
147
|
+
const readRushJson = async (rushJsonFilePath)=>{
|
|
148
|
+
const rushJson = readJson(rushJsonFilePath.includes(RUSH_JSON_FILE) ? rushJsonFilePath : external_node_path_default().join(rushJsonFilePath, RUSH_JSON_FILE));
|
|
149
|
+
return rushJson;
|
|
162
150
|
};
|
|
163
|
-
async function
|
|
164
|
-
|
|
151
|
+
async function utils_pathExists(path) {
|
|
152
|
+
return external_node_fs_default().promises.access(path).then(()=>true).catch(()=>false);
|
|
165
153
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const json = import_json5.default.parse(content);
|
|
172
|
-
return json;
|
|
154
|
+
const readJson = async (jsonFileAbsPath)=>{
|
|
155
|
+
if (!await utils_pathExists(jsonFileAbsPath)) return {};
|
|
156
|
+
const content = await external_node_fs_default().promises.readFile(jsonFileAbsPath, 'utf-8');
|
|
157
|
+
const json = external_json5_default().parse(content);
|
|
158
|
+
return json;
|
|
173
159
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
160
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
161
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
162
|
+
}
|
|
163
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
164
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
165
|
+
return fn;
|
|
166
|
+
}
|
|
167
|
+
function _class_private_method_init(obj, privateSet) {
|
|
168
|
+
_check_private_redeclaration(obj, privateSet);
|
|
169
|
+
privateSet.add(obj);
|
|
170
|
+
}
|
|
171
|
+
function _define_property(obj, key, value) {
|
|
172
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
173
|
+
value: value,
|
|
174
|
+
enumerable: true,
|
|
175
|
+
configurable: true,
|
|
176
|
+
writable: true
|
|
177
|
+
});
|
|
178
|
+
else obj[key] = value;
|
|
179
|
+
return obj;
|
|
180
|
+
}
|
|
181
|
+
var _getExportsSourceDirs = /*#__PURE__*/ new WeakSet(), /**
|
|
182
|
+
*
|
|
183
|
+
* @param paths normalize paths
|
|
184
|
+
* @returns common root paths
|
|
185
|
+
*/ _getCommonRootPaths = /*#__PURE__*/ new WeakSet(), _getRootPath = /*#__PURE__*/ new WeakSet();
|
|
186
|
+
class Project {
|
|
187
|
+
async init() {
|
|
188
|
+
this.metaData = await readPackageJson(external_node_path_default().join(this.dir, PACKAGE_JSON));
|
|
200
189
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(p) => !computedSet.has(p.name)
|
|
205
|
-
);
|
|
206
|
-
const result = [];
|
|
207
|
-
while (queue.length > 0) {
|
|
208
|
-
const item = queue.shift();
|
|
209
|
-
if (computedSet.has(item.name)) {
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
result.push(item);
|
|
213
|
-
computedSet.add(item.name);
|
|
214
|
-
const newDeps = item.getDirectDependentProjects(allProjectMap);
|
|
215
|
-
if (newDeps.length > 0) {
|
|
216
|
-
queue.push(...newDeps);
|
|
217
|
-
}
|
|
190
|
+
getMetaData() {
|
|
191
|
+
if (null === this.metaData) throw new Error('The Project object needs to be initialized by executing the `init` function');
|
|
192
|
+
return this.metaData;
|
|
218
193
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
194
|
+
getDependentProjects(monorepoProjects, options) {
|
|
195
|
+
const { recursive } = options ?? {
|
|
196
|
+
recursive: false
|
|
197
|
+
};
|
|
198
|
+
const allProjectMap = new Map();
|
|
199
|
+
for (const project of monorepoProjects)allProjectMap.set(project.name, project);
|
|
200
|
+
if (!recursive) return this.getDirectDependentProjects(allProjectMap);
|
|
201
|
+
const computedSet = new Set();
|
|
202
|
+
computedSet.add(this.name);
|
|
203
|
+
const queue = this.getDirectDependentProjects(allProjectMap).filter((p)=>!computedSet.has(p.name));
|
|
204
|
+
const result = [];
|
|
205
|
+
while(queue.length > 0){
|
|
206
|
+
const item = queue.shift();
|
|
207
|
+
if (computedSet.has(item.name)) continue;
|
|
208
|
+
result.push(item);
|
|
209
|
+
computedSet.add(item.name);
|
|
210
|
+
const newDeps = item.getDirectDependentProjects(allProjectMap);
|
|
211
|
+
if (newDeps.length > 0) queue.push(...newDeps);
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
229
214
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
getDirectDependentProjects(allProjectMap) {
|
|
216
|
+
const pkgJson = this.getMetaData();
|
|
217
|
+
const { dependencies = {}, devDependencies = {} } = pkgJson;
|
|
218
|
+
const projects = [];
|
|
219
|
+
for (const d of Object.keys(dependencies))if (allProjectMap.has(d)) projects.push(allProjectMap.get(d));
|
|
220
|
+
for (const d of Object.keys(devDependencies))if (allProjectMap.has(d)) projects.push(allProjectMap.get(d));
|
|
221
|
+
return projects;
|
|
234
222
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
223
|
+
getSourceEntryPaths(options) {
|
|
224
|
+
const { exports: checkExports = false, field: sourceField = 'source' } = options ?? {};
|
|
225
|
+
const pkgJson = this.getMetaData();
|
|
226
|
+
// normalize strings
|
|
227
|
+
const sourceDirs = pkgJson[sourceField] ? [
|
|
228
|
+
external_node_path_default().normalize(pkgJson[sourceField])
|
|
229
|
+
] : [];
|
|
230
|
+
if (checkExports) {
|
|
231
|
+
/**
|
|
232
|
+
* analyze exports:
|
|
233
|
+
* "exports": {
|
|
234
|
+
* ".": {
|
|
235
|
+
* "source": "./src/index.ts"
|
|
236
|
+
* }
|
|
237
|
+
* },
|
|
238
|
+
*/ const exportsSourceDirs = _class_private_method_get(this, _getExportsSourceDirs, getExportsSourceDirs).call(this, pkgJson.exports ?? {}, sourceField);
|
|
239
|
+
sourceDirs.push(...exportsSourceDirs);
|
|
240
|
+
}
|
|
241
|
+
if (!sourceDirs.length) throw new Error(`"${sourceField}" field is not found in ${this.name} package.json`);
|
|
242
|
+
return _class_private_method_get(this, _getCommonRootPaths, getCommonRootPaths).call(this, sourceDirs);
|
|
247
243
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
constructor(name, dir){
|
|
245
|
+
_class_private_method_init(this, _getExportsSourceDirs);
|
|
246
|
+
_class_private_method_init(this, _getCommonRootPaths);
|
|
247
|
+
_class_private_method_init(this, _getRootPath);
|
|
248
|
+
_define_property(this, "name", void 0);
|
|
249
|
+
_define_property(this, "dir", void 0);
|
|
250
|
+
_define_property(this, "metaData", void 0);
|
|
251
|
+
this.name = name;
|
|
252
|
+
this.dir = dir;
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
#getExportsSourceDirs(exportsConfig, sourceField) {
|
|
254
|
+
}
|
|
255
|
+
function getExportsSourceDirs(exportsConfig, sourceField) {
|
|
256
256
|
const exportsSourceDirs = [];
|
|
257
|
-
if (typeof exportsConfig[sourceField]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
for (const moduleRules of Object.values(exportsConfig)) {
|
|
263
|
-
if (typeof moduleRules === "object" && typeof moduleRules[sourceField] === "string") {
|
|
264
|
-
exportsSourceDirs.push(
|
|
265
|
-
import_node_path4.default.normalize(moduleRules[sourceField])
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
257
|
+
if ('string' == typeof exportsConfig[sourceField]) exportsSourceDirs.push(external_node_path_default().normalize(exportsConfig[sourceField]));
|
|
258
|
+
for (const moduleRules of Object.values(exportsConfig))if ('object' == typeof moduleRules && 'string' == typeof moduleRules[sourceField]) exportsSourceDirs.push(external_node_path_default().normalize(moduleRules[sourceField]));
|
|
259
|
+
// normalize strings
|
|
269
260
|
return exportsSourceDirs;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
} catch {
|
|
283
|
-
dir = import_node_path4.default.dirname(p);
|
|
284
|
-
}
|
|
285
|
-
const rootPath = this.#getRootPath(dir);
|
|
286
|
-
if (!commonRootPathsSet.has(rootPath)) {
|
|
287
|
-
commonRootPathsSet.add(rootPath);
|
|
288
|
-
}
|
|
261
|
+
}
|
|
262
|
+
function getCommonRootPaths(paths) {
|
|
263
|
+
const commonRootPathsSet = new Set();
|
|
264
|
+
for (const p of paths){
|
|
265
|
+
let dir;
|
|
266
|
+
try {
|
|
267
|
+
dir = external_node_fs_default().statSync(p).isDirectory() ? p : external_node_path_default().dirname(p);
|
|
268
|
+
} catch {
|
|
269
|
+
dir = external_node_path_default().dirname(p);
|
|
270
|
+
}
|
|
271
|
+
const rootPath = _class_private_method_get(this, _getRootPath, getRootPath).call(this, dir);
|
|
272
|
+
if (!commonRootPathsSet.has(rootPath)) commonRootPathsSet.add(rootPath);
|
|
289
273
|
}
|
|
290
|
-
return Array.from(commonRootPathsSet).map((p)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return p.split(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const yamlContent = await import_node_fs4.default.promises.readFile(workspaceYamlFilePath, "utf8");
|
|
302
|
-
const pnpmWorkspace = parse(yamlContent);
|
|
303
|
-
return pnpmWorkspace.packages || [];
|
|
274
|
+
return Array.from(commonRootPathsSet).map((p)=>external_node_path_default().join(this.dir, p));
|
|
275
|
+
}
|
|
276
|
+
function getRootPath(p) {
|
|
277
|
+
return p.split(external_node_path_default().sep)[0];
|
|
278
|
+
}
|
|
279
|
+
const getPatternsFromYaml = async (monorepoRoot)=>{
|
|
280
|
+
const { parse } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "yaml"));
|
|
281
|
+
const workspaceYamlFilePath = external_node_path_default().join(monorepoRoot, PNPM_WORKSPACE_FILE);
|
|
282
|
+
const yamlContent = await external_node_fs_default().promises.readFile(workspaceYamlFilePath, 'utf8');
|
|
283
|
+
const pnpmWorkspace = parse(yamlContent);
|
|
284
|
+
return pnpmWorkspace.packages || [];
|
|
304
285
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
"**/node_modules/**"
|
|
286
|
+
const normalize = (results)=>results.map((fp)=>external_node_path_default().normalize(fp));
|
|
287
|
+
const getGlobOpts = (rootPath, patterns)=>{
|
|
288
|
+
const globOpts = {
|
|
289
|
+
cwd: rootPath,
|
|
290
|
+
absolute: true,
|
|
291
|
+
followSymbolicLinks: false
|
|
292
|
+
};
|
|
293
|
+
if (patterns.some((cfg)=>cfg.includes('**') || cfg.includes('*'))) globOpts.ignore = [
|
|
294
|
+
// allow globs like "packages/**" or "packages/*",
|
|
295
|
+
// but avoid picking up node_modules/**/package.json and dist/**/package.json
|
|
296
|
+
'**/dist/**',
|
|
297
|
+
'**/node_modules/**'
|
|
318
298
|
];
|
|
319
|
-
|
|
320
|
-
return globOpts;
|
|
299
|
+
return globOpts;
|
|
321
300
|
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
};
|
|
301
|
+
const makeFileFinder = (rootPath, patterns)=>{
|
|
302
|
+
const globOpts = getGlobOpts(rootPath, patterns);
|
|
303
|
+
return async (fileName, fileMapper)=>{
|
|
304
|
+
let result = await external_fast_glob_default()(patterns.map((globPath)=>external_node_path_default().posix.join(globPath, fileName)), globOpts);
|
|
305
|
+
// fast-glob does not respect pattern order, so we re-sort by absolute path
|
|
306
|
+
result = result.sort();
|
|
307
|
+
// POSIX results always need to be normalized
|
|
308
|
+
result = normalize(result);
|
|
309
|
+
return fileMapper(result);
|
|
310
|
+
};
|
|
333
311
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
312
|
+
const readPnpmProjects = async (monorepoRoot, patterns)=>{
|
|
313
|
+
const finder = makeFileFinder(monorepoRoot, patterns);
|
|
314
|
+
const mapper = async (pkgJsonFilePath)=>{
|
|
315
|
+
const pkgJson = await readPackageJson(pkgJsonFilePath);
|
|
316
|
+
return {
|
|
317
|
+
dir: external_node_path_default().dirname(pkgJsonFilePath),
|
|
318
|
+
manifest: pkgJson
|
|
319
|
+
};
|
|
341
320
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
PACKAGE_JSON,
|
|
345
|
-
(filePaths) => Promise.all(filePaths.map(mapper))
|
|
346
|
-
);
|
|
347
|
-
return projects;
|
|
321
|
+
const projects = await finder(PACKAGE_JSON, (filePaths)=>Promise.all(filePaths.map(mapper)));
|
|
322
|
+
return projects;
|
|
348
323
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
})
|
|
358
|
-
);
|
|
324
|
+
const pnpm_getProjects = async (monorepoRoot)=>{
|
|
325
|
+
const patterns = await getPatternsFromYaml(monorepoRoot);
|
|
326
|
+
const pnpmProjects = await readPnpmProjects(monorepoRoot, patterns);
|
|
327
|
+
return Promise.all(pnpmProjects.filter((p)=>p.manifest.name).map(async (p)=>{
|
|
328
|
+
const project = new Project(p.manifest.name, p.dir);
|
|
329
|
+
await project.init();
|
|
330
|
+
return project;
|
|
331
|
+
}));
|
|
359
332
|
};
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const project = new Project(
|
|
369
|
-
p.packageName,
|
|
370
|
-
import_node_path6.default.join(monorepoRoot, p.projectFolder)
|
|
371
|
-
);
|
|
372
|
-
await project.init();
|
|
373
|
-
return project;
|
|
374
|
-
})
|
|
375
|
-
);
|
|
333
|
+
const rush_getProjects = async (monorepoRoot)=>{
|
|
334
|
+
const rushConfiguration = await readRushJson(monorepoRoot);
|
|
335
|
+
const { projects = [] } = rushConfiguration;
|
|
336
|
+
return Promise.all(projects.map(async (p)=>{
|
|
337
|
+
const project = new Project(p.packageName, external_node_path_default().join(monorepoRoot, p.projectFolder));
|
|
338
|
+
await project.init();
|
|
339
|
+
return project;
|
|
340
|
+
}));
|
|
376
341
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return
|
|
383
|
-
}
|
|
384
|
-
if (type === "rush") {
|
|
385
|
-
return getProjects2(rootPath);
|
|
386
|
-
}
|
|
387
|
-
if (getProjects3) {
|
|
388
|
-
return getProjects3(rootPath);
|
|
389
|
-
}
|
|
390
|
-
return [];
|
|
342
|
+
const getMonorepoSubProjects = async (monorepoBaseData)=>{
|
|
343
|
+
const { type, rootPath, getProjects } = monorepoBaseData;
|
|
344
|
+
if ('pnpm' === type) return pnpm_getProjects(rootPath);
|
|
345
|
+
if ('rush' === type) return rush_getProjects(rootPath);
|
|
346
|
+
if (getProjects) return getProjects(rootPath);
|
|
347
|
+
return [];
|
|
391
348
|
};
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
async function pathExists3(path9) {
|
|
395
|
-
return import_node_fs5.default.promises.access(path9).then(() => true).catch(() => false);
|
|
349
|
+
async function getDependentProjects_pathExists(path) {
|
|
350
|
+
return external_node_fs_default().promises.access(path).then(()=>true).catch(()=>false);
|
|
396
351
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const monoBaseData = await getMonorepoBaseData(cwd, extraMonorepoStrategies);
|
|
415
|
-
if (!monoBaseData.isMonorepo) {
|
|
416
|
-
return [];
|
|
417
|
-
}
|
|
418
|
-
const projects = await getMonorepoSubProjects(monoBaseData);
|
|
419
|
-
const currentProject = projects.find(
|
|
420
|
-
(project) => project.name === projectName
|
|
421
|
-
);
|
|
422
|
-
if (!currentProject) {
|
|
423
|
-
return [];
|
|
424
|
-
}
|
|
425
|
-
let dependentProjects = currentProject.getDependentProjects(projects, {
|
|
426
|
-
recursive
|
|
427
|
-
});
|
|
428
|
-
if (filter) {
|
|
429
|
-
dependentProjects = await filter(dependentProjects);
|
|
430
|
-
}
|
|
431
|
-
return dependentProjects;
|
|
352
|
+
const getDependentProjects = async (projectNameOrRootPath, options)=>{
|
|
353
|
+
const { cwd = process.cwd(), recursive, filter, extraMonorepoStrategies } = options;
|
|
354
|
+
// check if first argument is projectRootPath.
|
|
355
|
+
const currentProjectPkgJsonPath = external_node_path_default().join(projectNameOrRootPath, 'package.json');
|
|
356
|
+
let projectName;
|
|
357
|
+
if (await getDependentProjects_pathExists(currentProjectPkgJsonPath)) ({ name: projectName } = await readPackageJson(currentProjectPkgJsonPath));
|
|
358
|
+
else projectName = projectNameOrRootPath;
|
|
359
|
+
const monoBaseData = await getMonorepoBaseData(cwd, extraMonorepoStrategies);
|
|
360
|
+
if (!monoBaseData.isMonorepo) return [];
|
|
361
|
+
const projects = await getMonorepoSubProjects(monoBaseData);
|
|
362
|
+
const currentProject = projects.find((project)=>project.name === projectName);
|
|
363
|
+
if (!currentProject) return [];
|
|
364
|
+
let dependentProjects = currentProject.getDependentProjects(projects, {
|
|
365
|
+
recursive
|
|
366
|
+
});
|
|
367
|
+
if (filter) dependentProjects = await filter(dependentProjects);
|
|
368
|
+
return dependentProjects;
|
|
432
369
|
};
|
|
433
|
-
|
|
434
|
-
// src/project-utils/filter.ts
|
|
435
370
|
function hasExportsSourceField(exportsConfig, sourceField) {
|
|
436
|
-
|
|
437
|
-
(moduleRules) => typeof moduleRules === "object" && typeof moduleRules[sourceField] === "string"
|
|
438
|
-
);
|
|
371
|
+
return 'string' == typeof exportsConfig[sourceField] || Object.values(exportsConfig).some((moduleRules)=>'object' == typeof moduleRules && 'string' == typeof moduleRules[sourceField]);
|
|
439
372
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const includes = [];
|
|
451
|
-
for (const project of projects) {
|
|
452
|
-
includes.push(
|
|
453
|
-
...project.getSourceEntryPaths({ field: sourceField, exports: true })
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
return includes;
|
|
373
|
+
const filterByField = (fieldName, checkExports)=>(projects)=>projects.filter((p)=>fieldName in p.metaData || checkExports && hasExportsSourceField(p.metaData.exports || {}, fieldName));
|
|
374
|
+
const PLUGIN_SOURCE_BUILD_NAME = 'rsbuild:source-build';
|
|
375
|
+
const getSourceInclude = async (options)=>{
|
|
376
|
+
const { projects, sourceField } = options;
|
|
377
|
+
const includes = [];
|
|
378
|
+
for (const project of projects)includes.push(...project.getSourceEntryPaths({
|
|
379
|
+
field: sourceField,
|
|
380
|
+
exports: true
|
|
381
|
+
}));
|
|
382
|
+
return includes;
|
|
457
383
|
};
|
|
458
384
|
function pluginSourceBuild(options) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
385
|
+
const { projectName, sourceField = 'source', resolvePriority = 'source', extraMonorepoStrategies } = options ?? {};
|
|
386
|
+
return {
|
|
387
|
+
name: PLUGIN_SOURCE_BUILD_NAME,
|
|
388
|
+
setup (api) {
|
|
389
|
+
const projectRootPath = api.context.rootPath;
|
|
390
|
+
let projects;
|
|
391
|
+
api.modifyEnvironmentConfig(async (config)=>{
|
|
392
|
+
projects = projects || await getDependentProjects(projectName || projectRootPath, {
|
|
393
|
+
cwd: projectRootPath,
|
|
394
|
+
recursive: true,
|
|
395
|
+
filter: filterByField(sourceField, true),
|
|
396
|
+
extraMonorepoStrategies
|
|
397
|
+
});
|
|
398
|
+
const includes = await getSourceInclude({
|
|
399
|
+
projects,
|
|
400
|
+
sourceField
|
|
401
|
+
});
|
|
402
|
+
config.source = config.source ?? {};
|
|
403
|
+
config.source.include = [
|
|
404
|
+
...config.source.include ?? [],
|
|
405
|
+
...includes
|
|
406
|
+
];
|
|
407
|
+
});
|
|
408
|
+
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
409
|
+
for (const ruleId of [
|
|
410
|
+
CHAIN_ID.RULE.TS,
|
|
411
|
+
CHAIN_ID.RULE.JS
|
|
412
|
+
])if (chain.module.rules.get(ruleId)) {
|
|
413
|
+
const rule = chain.module.rule(ruleId);
|
|
414
|
+
// https://rspack.dev/config/resolve
|
|
415
|
+
// when source is not exist, other mainFields will effect. // source > Rspack default mainFields.
|
|
416
|
+
rule.resolve.mainFields.merge('source' === resolvePriority ? [
|
|
417
|
+
sourceField,
|
|
418
|
+
'...'
|
|
419
|
+
] : [
|
|
420
|
+
'...',
|
|
421
|
+
sourceField
|
|
422
|
+
]);
|
|
423
|
+
// `conditionNames` is not affected by `resolvePriority`.
|
|
424
|
+
// The priority is controlled by the order of fields declared in `exports`.
|
|
425
|
+
rule.resolve.conditionNames.add('...').add(sourceField);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
const getReferences = async (tsconfigPath, rspackReferences)=>{
|
|
429
|
+
const references = new Set();
|
|
430
|
+
for (const project of projects || []){
|
|
431
|
+
const filePath = external_node_path_default().join(project.dir, 'tsconfig.json');
|
|
432
|
+
if (external_node_fs_default().existsSync(filePath)) references.add(filePath);
|
|
433
|
+
}
|
|
434
|
+
// Add references in the current project's tsconfig.json
|
|
435
|
+
const tsconfig = external_json5_default().parse(external_node_fs_default().readFileSync(tsconfigPath, 'utf-8'));
|
|
436
|
+
const userReferences = [
|
|
437
|
+
...Array.isArray(rspackReferences) ? rspackReferences : [],
|
|
438
|
+
...tsconfig.references ? tsconfig.references.map((item)=>item.path).filter(Boolean) : []
|
|
439
|
+
];
|
|
440
|
+
if (userReferences.length) {
|
|
441
|
+
const baseDir = external_node_path_default().dirname(tsconfigPath);
|
|
442
|
+
for (const item of userReferences){
|
|
443
|
+
if (!item) continue;
|
|
444
|
+
const absolutePath = external_node_path_default().isAbsolute(item) ? item : external_node_path_default().join(baseDir, item);
|
|
445
|
+
references.add(absolutePath);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// avoid self reference, it will break the resolver
|
|
449
|
+
references.delete(tsconfigPath);
|
|
450
|
+
return Array.from(references);
|
|
451
|
+
};
|
|
452
|
+
if ('rspack' === api.context.bundlerType) api.modifyRspackConfig(async (config, { environment })=>{
|
|
453
|
+
const { tsconfigPath } = environment;
|
|
454
|
+
if (!tsconfigPath) return;
|
|
455
|
+
config.resolve ||= {};
|
|
456
|
+
const { tsConfig = {
|
|
457
|
+
configFile: tsconfigPath
|
|
458
|
+
} } = config.resolve;
|
|
459
|
+
const configObject = 'string' == typeof tsConfig ? {
|
|
460
|
+
configFile: tsConfig
|
|
461
|
+
} : tsConfig;
|
|
462
|
+
const references = await getReferences(tsconfigPath, configObject.references);
|
|
463
|
+
config.resolve.tsConfig = {
|
|
464
|
+
configFile: (null == configObject ? void 0 : configObject.configFile) || tsconfigPath,
|
|
465
|
+
references: references
|
|
466
|
+
};
|
|
467
|
+
});
|
|
468
|
+
else api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
469
|
+
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
470
|
+
const { tsconfigPath } = environment;
|
|
471
|
+
if (!chain.resolve.plugins.has(TS_CONFIG_PATHS) || !tsconfigPath) return;
|
|
472
|
+
const references = await getReferences(tsconfigPath);
|
|
473
|
+
// set references config
|
|
474
|
+
// https://github.com/dividab/tsconfig-paths-webpack-plugin#options
|
|
475
|
+
chain.resolve.plugin(TS_CONFIG_PATHS).tap((options)=>options.map((option)=>({
|
|
476
|
+
...option,
|
|
477
|
+
references
|
|
478
|
+
})));
|
|
479
|
+
});
|
|
519
480
|
}
|
|
520
|
-
|
|
521
|
-
return Array.from(references);
|
|
522
|
-
};
|
|
523
|
-
if (api.context.bundlerType === "rspack") {
|
|
524
|
-
api.modifyRspackConfig(async (config, { environment }) => {
|
|
525
|
-
const { tsconfigPath } = environment;
|
|
526
|
-
if (!tsconfigPath) {
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
config.resolve ||= {};
|
|
530
|
-
const { tsConfig = { configFile: tsconfigPath } } = config.resolve;
|
|
531
|
-
const configObject = typeof tsConfig === "string" ? { configFile: tsConfig } : tsConfig;
|
|
532
|
-
const references = await getReferences(
|
|
533
|
-
tsconfigPath,
|
|
534
|
-
configObject.references
|
|
535
|
-
);
|
|
536
|
-
config.resolve.tsConfig = {
|
|
537
|
-
configFile: configObject?.configFile || tsconfigPath,
|
|
538
|
-
references
|
|
539
|
-
};
|
|
540
|
-
});
|
|
541
|
-
} else {
|
|
542
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
|
|
543
|
-
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
544
|
-
const { tsconfigPath } = environment;
|
|
545
|
-
if (!chain.resolve.plugins.has(TS_CONFIG_PATHS) || !tsconfigPath) {
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
const references = await getReferences(tsconfigPath);
|
|
549
|
-
chain.resolve.plugin(TS_CONFIG_PATHS).tap(
|
|
550
|
-
(options2) => options2.map((option) => ({
|
|
551
|
-
...option,
|
|
552
|
-
references
|
|
553
|
-
}))
|
|
554
|
-
);
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
};
|
|
481
|
+
};
|
|
559
482
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
getMonorepoBaseData,
|
|
565
|
-
getMonorepoSubProjects,
|
|
566
|
-
pluginSourceBuild
|
|
483
|
+
var __webpack_export_target__ = exports;
|
|
484
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
485
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
486
|
+
value: true
|
|
567
487
|
});
|