@modern-js/builder 2.34.0 → 2.35.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,13 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
import type { BuilderPluginAPI as WebpackBuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
3
|
import type { BuilderPluginAPI as RspackBuilderPluginAPI } from '@modern-js/builder-rspack-provider';
|
|
4
|
-
import { type ExtraMonorepoStrategies } from '@modern-js/monorepo-utils';
|
|
4
|
+
import { type Project, type ExtraMonorepoStrategies } from '@modern-js/monorepo-utils';
|
|
5
5
|
export declare const pluginName = "builder-plugin-source-build";
|
|
6
6
|
export declare const getSourceInclude: (options: {
|
|
7
|
-
|
|
8
|
-
findMonorepoStartPath: string;
|
|
7
|
+
projects: Project[];
|
|
9
8
|
sourceField: string;
|
|
10
|
-
extraMonorepoStrategies?: ExtraMonorepoStrategies;
|
|
11
9
|
}) => Promise<string[]>;
|
|
12
10
|
export interface PluginSourceBuildOptions {
|
|
13
11
|
projectName?: string;
|
|
@@ -20,18 +20,15 @@ _export(exports, {
|
|
|
20
20
|
return builderPluginSourceBuild;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
24
|
+
const _buildershared = require("@modern-js/builder-shared");
|
|
23
25
|
const _monorepoutils = require("@modern-js/monorepo-utils");
|
|
24
26
|
const _utils = require("@modern-js/utils");
|
|
27
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
25
28
|
const log = (0, _utils.debug)("BUILDER_PLUGIN_SOURCE_BUILD");
|
|
26
29
|
const pluginName = "builder-plugin-source-build";
|
|
27
30
|
const getSourceInclude = async (options) => {
|
|
28
|
-
const {
|
|
29
|
-
const projects = await (0, _monorepoutils.getDependentProjects)(projectNameOrRootPath, {
|
|
30
|
-
cwd: findMonorepoStartPath,
|
|
31
|
-
recursive: true,
|
|
32
|
-
filter: (0, _monorepoutils.filterByField)(sourceField),
|
|
33
|
-
extraMonorepoStrategies
|
|
34
|
-
});
|
|
31
|
+
const { projects, sourceField } = options;
|
|
35
32
|
const includes = [];
|
|
36
33
|
for (const project of projects) {
|
|
37
34
|
includes.push(...project.getSourceEntryPaths({
|
|
@@ -47,19 +44,24 @@ function builderPluginSourceBuild(options) {
|
|
|
47
44
|
name: pluginName,
|
|
48
45
|
async setup(api) {
|
|
49
46
|
const projectRootPath = api.context.rootPath;
|
|
47
|
+
let projects = [];
|
|
50
48
|
if (api.context.bundlerType === "webpack") {
|
|
51
49
|
api.modifyBuilderConfig(async (config) => {
|
|
52
50
|
var _config_experiments;
|
|
53
|
-
const { sourceBuild
|
|
51
|
+
const { sourceBuild } = (_config_experiments = config.experiments) !== null && _config_experiments !== void 0 ? _config_experiments : {};
|
|
54
52
|
if (!sourceBuild) {
|
|
55
53
|
return;
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
projects = await (0, _monorepoutils.getDependentProjects)(projectName || projectRootPath, {
|
|
56
|
+
cwd: projectRootPath,
|
|
57
|
+
recursive: true,
|
|
58
|
+
filter: (0, _monorepoutils.filterByField)(sourceField),
|
|
61
59
|
extraMonorepoStrategies
|
|
62
60
|
});
|
|
61
|
+
const includes = await getSourceInclude({
|
|
62
|
+
projects,
|
|
63
|
+
sourceField
|
|
64
|
+
});
|
|
63
65
|
var _config_source;
|
|
64
66
|
config.source = (_config_source = config.source) !== null && _config_source !== void 0 ? _config_source : {};
|
|
65
67
|
var _config_source_include;
|
|
@@ -68,7 +70,7 @@ function builderPluginSourceBuild(options) {
|
|
|
68
70
|
...includes
|
|
69
71
|
];
|
|
70
72
|
});
|
|
71
|
-
api.
|
|
73
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
72
74
|
const { experiments: { sourceBuild }, tools: { tsLoader } } = api.getNormalizedConfig();
|
|
73
75
|
if (!sourceBuild) {
|
|
74
76
|
return;
|
|
@@ -84,6 +86,16 @@ function builderPluginSourceBuild(options) {
|
|
|
84
86
|
sourceField
|
|
85
87
|
]
|
|
86
88
|
});
|
|
89
|
+
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
90
|
+
if (chain.resolve.plugins.has(TS_CONFIG_PATHS)) {
|
|
91
|
+
chain.resolve.plugin(TS_CONFIG_PATHS).tap((options2) => {
|
|
92
|
+
const references = projects.map((project) => _path.default.join(project.dir, _buildershared.TS_CONFIG_FILE)).filter((filePath) => _utils.fs.existsSync(filePath)).map((filePath) => _path.default.relative(projectRootPath, filePath));
|
|
93
|
+
return options2.map((option) => ({
|
|
94
|
+
...option,
|
|
95
|
+
references
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
87
99
|
});
|
|
88
100
|
}
|
|
89
101
|
}
|
|
@@ -49,7 +49,7 @@ async function splitByExperience(ctx) {
|
|
|
49
49
|
const { override, polyfill, rootPath, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
50
50
|
const experienceCacheGroup = {};
|
|
51
51
|
const packageRegExps = {
|
|
52
|
-
react: createDependenciesRegExp("react", "react-dom"),
|
|
52
|
+
react: createDependenciesRegExp("react", "react-dom", "scheduler"),
|
|
53
53
|
router: createDependenciesRegExp("react-router", "react-router-dom", "@remix-run/router", "history"),
|
|
54
54
|
lodash: createDependenciesRegExp("lodash", "lodash-es"),
|
|
55
55
|
axios: createDependenciesRegExp("axios", /axios-.+/)
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=14.0.0"
|
|
20
20
|
},
|
|
21
|
-
"version": "2.
|
|
21
|
+
"version": "2.35.0",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@svgr/webpack": "8.0.1",
|
|
47
47
|
"@swc/helpers": "0.5.1",
|
|
48
|
-
"@modern-js/
|
|
49
|
-
"@modern-js/
|
|
50
|
-
"@modern-js/node-bundle-require": "2.
|
|
51
|
-
"@modern-js/utils": "2.
|
|
48
|
+
"@modern-js/builder-shared": "2.35.0",
|
|
49
|
+
"@modern-js/monorepo-utils": "2.35.0",
|
|
50
|
+
"@modern-js/node-bundle-require": "2.35.0",
|
|
51
|
+
"@modern-js/utils": "2.35.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/babel__core": "^7.20.0",
|
|
55
55
|
"@types/node": "^14",
|
|
56
56
|
"typescript": "^5",
|
|
57
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
58
|
-
"@modern-js/builder-rspack-provider": "2.
|
|
59
|
-
"@scripts/build": "2.
|
|
60
|
-
"@scripts/vitest-config": "2.
|
|
57
|
+
"@modern-js/builder-webpack-provider": "2.35.0",
|
|
58
|
+
"@modern-js/builder-rspack-provider": "2.35.0",
|
|
59
|
+
"@scripts/build": "2.35.0",
|
|
60
|
+
"@scripts/vitest-config": "2.35.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"registry": "https://registry.npmjs.org/",
|