Skip to content

Commit df43559

Browse files
authored
fix(core): toolsType is overridden when install multiple solutions (#3717)
1 parent 8007951 commit df43559

File tree

13 files changed

+36
-14
lines changed

13 files changed

+36
-14
lines changed

.changeset/cool-ants-complain.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@modern-js/monorepo-tools': patch
3+
'@modern-js/module-tools': patch
4+
'@modern-js/app-tools': patch
5+
'@modern-js/doc-tools': patch
6+
'@modern-js/core': patch
7+
---
8+
9+
fix(core): toolsType is overridden when install multiple solutions
10+
11+
fix(core): 修复安装多个 solutions 时 toolsType 被覆盖的问题

packages/cli/core/src/context.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
IAppContext,
88
InternalPlugins,
99
NormalizedConfig,
10-
ToolsType,
1110
} from './types';
1211

1312
export const AppContext = createContext<IAppContext>({} as IAppContext);
@@ -50,7 +49,6 @@ export const initAppContext = ({
5049
options,
5150
serverConfigFile,
5251
serverInternalPlugins,
53-
toolsType,
5452
}: {
5553
appDirectory: string;
5654
plugins: CliPlugin[];
@@ -64,7 +62,6 @@ export const initAppContext = ({
6462
};
6563
serverConfigFile: string;
6664
serverInternalPlugins: InternalPlugins;
67-
toolsType?: ToolsType;
6865
}): IAppContext => {
6966
const {
7067
metaName = 'modern-js',
@@ -100,6 +97,5 @@ export const initAppContext = ({
10097
apiOnly: false,
10198
internalDirAlias: `@_${metaName.replace(/-/g, '_')}_internal`,
10299
internalSrcAlias: `@_${metaName.replace(/-/g, '_')}_src`,
103-
toolsType,
104100
};
105101
};

packages/cli/core/src/createCli.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const createCli = () => {
7979
plugins.forEach(plugin => plugin && manager.usePlugin(plugin));
8080

8181
const appContext = initAppContext({
82-
toolsType: mergedOptions?.toolsType,
8382
appDirectory,
8483
plugins,
8584
configFile: loaded.filePath,

packages/cli/core/src/types/coreOptions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ErrorObject } from '@modern-js/utils/compiled/ajv';
22
import type { InternalPlugins } from './plugin';
3-
import type { ToolsType } from './context';
43
import type { UserConfig } from './config';
54

65
export interface CoreOptions {
@@ -21,7 +20,6 @@ export interface CoreOptions {
2120
distDir?: string;
2221
sharedDir?: string;
2322
};
24-
toolsType?: ToolsType;
2523

2624
/** force the modern-js core auto register plugin exist in the package.json */
2725
forceAutoLoadPlugins?: boolean;

packages/solutions/app-tools/bin/modern.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ require('@modern-js/core/runBin').run({
1111
server: INTERNAL_SERVER_PLUGINS,
1212
autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
1313
},
14-
toolsType: 'app-tools',
1514
});

packages/solutions/app-tools/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ export default (
150150
],
151151

152152
setup: api => {
153+
const appContext = api.useAppContext();
154+
api.setAppContext({
155+
...appContext,
156+
toolsType: 'app-tools',
157+
});
158+
153159
const locale = getLocaleLanguage();
154160
i18n.changeLanguage({ locale });
155161

packages/solutions/app-tools/tests/helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const runCli = async (options: {
2929
internalPlugins: {
3030
cli: plugins,
3131
},
32-
toolsType: 'app-tools',
3332
forceAutoLoadPlugins: true,
3433
},
3534
disableWatcher: true,

packages/solutions/doc-tools/bin/modern.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ require('@modern-js/core/runBin').run({
55
internalPlugins: {
66
cli: INTERNAL_DOC_TOOLS_PLUGINS,
77
},
8-
toolsType: 'doc-tools',
98
});

packages/solutions/doc-tools/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const WATCH_FILE_TYPES = ['.md', '.mdx', '.tsx', '.jsx', '.ts', '.js'];
3636
export default (options: DocToolsOptions = {}): CliPlugin => ({
3737
name: '@modern-js/doc-tools',
3838
setup: async api => {
39+
const appContext = api.useAppContext();
40+
api.setAppContext({
41+
...appContext,
42+
toolsType: 'doc-tools',
43+
});
44+
3945
const { configFiles = MODERN_CONFIG_FILES, extraDocConfig = {} } = options;
4046
const { dev, build, serve } = await import('@modern-js/doc-core');
4147
let server: ServerInstance | undefined;

packages/solutions/module-tools/bin/modern.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ require('@modern-js/core/runBin').run({
55
internalPlugins: {
66
cli: INTERNAL_MODULE_TOOLS_PLUGINS,
77
},
8-
toolsType: 'module-tools',
98
});

0 commit comments

Comments
 (0)