Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/cool-ants-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@modern-js/monorepo-tools': patch
'@modern-js/module-tools': patch
'@modern-js/app-tools': patch
'@modern-js/doc-tools': patch
'@modern-js/core': patch
---

fix(core): toolsType is overridden when install multiple solutions

fix(core): 修复安装多个 solutions 时 toolsType 被覆盖的问题
4 changes: 0 additions & 4 deletions packages/cli/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
IAppContext,
InternalPlugins,
NormalizedConfig,
ToolsType,
} from './types';

export const AppContext = createContext<IAppContext>({} as IAppContext);
Expand Down Expand Up @@ -50,7 +49,6 @@ export const initAppContext = ({
options,
serverConfigFile,
serverInternalPlugins,
toolsType,
}: {
appDirectory: string;
plugins: CliPlugin[];
Expand All @@ -64,7 +62,6 @@ export const initAppContext = ({
};
serverConfigFile: string;
serverInternalPlugins: InternalPlugins;
toolsType?: ToolsType;
}): IAppContext => {
const {
metaName = 'modern-js',
Expand Down Expand Up @@ -100,6 +97,5 @@ export const initAppContext = ({
apiOnly: false,
internalDirAlias: `@_${metaName.replace(/-/g, '_')}_internal`,
internalSrcAlias: `@_${metaName.replace(/-/g, '_')}_src`,
toolsType,
};
};
1 change: 0 additions & 1 deletion packages/cli/core/src/createCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const createCli = () => {
plugins.forEach(plugin => plugin && manager.usePlugin(plugin));

const appContext = initAppContext({
toolsType: mergedOptions?.toolsType,
appDirectory,
plugins,
configFile: loaded.filePath,
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/core/src/types/coreOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ErrorObject } from '@modern-js/utils/compiled/ajv';
import type { InternalPlugins } from './plugin';
import type { ToolsType } from './context';
import type { UserConfig } from './config';

export interface CoreOptions {
Expand All @@ -21,7 +20,6 @@ export interface CoreOptions {
distDir?: string;
sharedDir?: string;
};
toolsType?: ToolsType;

/** force the modern-js core auto register plugin exist in the package.json */
forceAutoLoadPlugins?: boolean;
Expand Down
1 change: 0 additions & 1 deletion packages/solutions/app-tools/bin/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ require('@modern-js/core/runBin').run({
server: INTERNAL_SERVER_PLUGINS,
autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
},
toolsType: 'app-tools',
});
6 changes: 6 additions & 0 deletions packages/solutions/app-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ export default (
],

setup: api => {
const appContext = api.useAppContext();
api.setAppContext({
...appContext,
toolsType: 'app-tools',
});

const locale = getLocaleLanguage();
i18n.changeLanguage({ locale });

Expand Down
1 change: 0 additions & 1 deletion packages/solutions/app-tools/tests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const runCli = async (options: {
internalPlugins: {
cli: plugins,
},
toolsType: 'app-tools',
forceAutoLoadPlugins: true,
},
disableWatcher: true,
Expand Down
1 change: 0 additions & 1 deletion packages/solutions/doc-tools/bin/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ require('@modern-js/core/runBin').run({
internalPlugins: {
cli: INTERNAL_DOC_TOOLS_PLUGINS,
},
toolsType: 'doc-tools',
});
6 changes: 6 additions & 0 deletions packages/solutions/doc-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const WATCH_FILE_TYPES = ['.md', '.mdx', '.tsx', '.jsx', '.ts', '.js'];
export default (options: DocToolsOptions = {}): CliPlugin => ({
name: '@modern-js/doc-tools',
setup: async api => {
const appContext = api.useAppContext();
api.setAppContext({
...appContext,
toolsType: 'doc-tools',
});

const { configFiles = MODERN_CONFIG_FILES, extraDocConfig = {} } = options;
const { dev, build, serve } = await import('@modern-js/doc-core');
let server: ServerInstance | undefined;
Expand Down
1 change: 0 additions & 1 deletion packages/solutions/module-tools/bin/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ require('@modern-js/core/runBin').run({
internalPlugins: {
cli: INTERNAL_MODULE_TOOLS_PLUGINS,
},
toolsType: 'module-tools',
});
6 changes: 6 additions & 0 deletions packages/solutions/module-tools/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export const cli = (): CliPlugin<ModuleTools> => ({
});

const setup: CliPlugin<ModuleTools>['setup'] = async api => {
const appContext = api.useAppContext();
api.setAppContext({
...appContext,
toolsType: 'module-tools',
});

const prepare = async () => {
const { initLocalLanguage } = await import('./utils/language');
await initLocalLanguage();
Expand Down
4 changes: 1 addition & 3 deletions packages/solutions/monorepo-tools/bin/modern.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

require('@modern-js/core/runBin').run({
toolsType: 'monorepo-tools',
});
require('@modern-js/core/runBin').run({});
6 changes: 6 additions & 0 deletions packages/solutions/monorepo-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export default (): CliPlugin<MonorepoTools> => ({
usePlugins: [changesetPlugin(), lintPlugin()],
registerHook: hooks,
setup: api => {
const appContext = api.useAppContext();
api.setAppContext({
...appContext,
toolsType: 'monorepo-tools',
});

const locale = getLocaleLanguage();
i18n.changeLanguage({ locale });

Expand Down