Skip to content

Commit

Permalink
chore: remove enable-rspack action in generator run new
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored and KyrieLii committed Jan 29, 2024
1 parent 4fd1da7 commit 104ceab
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 61 deletions.
8 changes: 8 additions & 0 deletions .changeset/fuzzy-ants-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@modern-js/rspack-generator': patch
'@modern-js/generator-common': patch
---

chore: remove enable-rspack action in generator run new

chore: 在生成器 run new 中移除 ‘启用 Rspack’ 的功能
2 changes: 1 addition & 1 deletion packages/generator/generator-cases/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('test generator cases', () => {
});
test('test getMWANewCases', async () => {
const mwaNewCases = getMWANewCases();
expect(mwaNewCases.length).toBe(14);
expect(mwaNewCases.length).toBe(13);
});
test('test getModuleNewCases', async () => {
const moduleNewCases = getModuleNewCases();
Expand Down
1 change: 0 additions & 1 deletion packages/generator/generator-common/src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const EN_LOCALE = {
polyfill: 'Enable UA-based Polyfill Feature',
proxy: 'Enable Global Proxy',
swc: 'Enable SWC Compile',
rspack: 'Enable Rspack Build (experimental)',
module_doc: 'Enable Module Doc',
},
element: {
Expand Down
1 change: 0 additions & 1 deletion packages/generator/generator-common/src/locale/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const ZH_LOCALE = {
polyfill: '启用「基于 UA 的 Polyfill」功能',
proxy: '启用「全局代理」',
swc: '启用「SWC 编译」',
rspack: '启用「Rspack 构建」(实验性)',
module_doc: '启动「模块文档」功能',
},
element: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export enum ActionFunction {
Polyfill = 'polyfill',
Proxy = 'proxy',
SWC = 'swc',
Rspack = 'rspack',
ModuleDoc = 'module_doc',
}

Expand Down Expand Up @@ -69,7 +68,6 @@ export const ActionFunctionText: Record<ActionFunction, () => string> = {
[ActionFunction.Polyfill]: () => i18n.t(localeKeys.action.function.polyfill),
[ActionFunction.Proxy]: () => i18n.t(localeKeys.action.function.proxy),
[ActionFunction.SWC]: () => i18n.t(localeKeys.action.function.swc),
[ActionFunction.Rspack]: () => i18n.t(localeKeys.action.function.rspack),
[ActionFunction.ModuleDoc]: () =>
i18n.t(localeKeys.action.function.module_doc),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const MWAActionTypes = [
];

export const MWAActionFunctions = [
ActionFunction.Rspack,
ActionFunction.TailwindCSS,
ActionFunction.BFF,
ActionFunction.SSG,
Expand Down Expand Up @@ -186,7 +185,6 @@ export const MWANewActionGenerators: Record<
[ActionFunction.Polyfill]: '@modern-js/dependence-generator',
[ActionFunction.Proxy]: '@modern-js/dependence-generator',
[ActionFunction.SWC]: '@modern-js/dependence-generator',
[ActionFunction.Rspack]: '@modern-js/rspack-generator',
},
[ActionType.Refactor]: {
[ActionRefactor.ReactRouter5]: '@modern-js/router-v5-generator',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ describe('new action test', () => {
expect(ActionFunctionText[ActionFunction.Proxy]()).toBe('启用「全局代理」');
});
it('mwa', () => {
expect(MWAActionFunctions.length).toBe(11);
expect(MWAActionFunctions.length).toBe(10);
});
});
39 changes: 1 addition & 38 deletions packages/generator/generators/rspack-generator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import path from 'path';
import { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
import { AppAPI } from '@modern-js/codesmith-api-app';
import {
chalk,
getModernConfigFile,
isTsProject,
} from '@modern-js/generator-utils';
import { isTsProject } from '@modern-js/generator-utils';
import {
DependenceGenerator,
i18n as commonI18n,
Language,
} from '@modern-js/generator-common';
import { i18n, localeKeys } from './locale';

const getGeneratorPath = (generator: string, distTag: string) => {
if (process.env.CODESMITH_ENV === 'development') {
Expand Down Expand Up @@ -69,37 +64,5 @@ export default async (context: GeneratorContext, generator: GeneratorCore) => {

await handleTemplateFile(context, generator, appApi);

if (!context.config.isSubGenerator) {
await appApi.runInstall(undefined, { ignoreScripts: true });
const appDir = context.materials.default.basePath;
const configFile = await getModernConfigFile(appDir);
const isTS = configFile.endsWith('ts');
console.info(
chalk.green(`\n[INFO]`),
`${i18n.t(localeKeys.success)}`,
chalk.yellow.bold(`${configFile}`),
':',
'\n',
);
if (isTS) {
console.info(`
export default defineConfig${chalk.yellow.bold("<'rspack'>")}({
...,
plugins: [appTools(${chalk.yellow.bold(
`{ bundler: 'experimental-rspack' }`,
)}), ...],
});
`);
} else {
console.info(`
module.exports = {
...,
plugins: [appTools(${chalk.yellow.bold(
`{ bundler: 'experimental-rspack' }`,
)}), ...],
};
`);
}
}
generator.logger.debug(`forge @modern-js/rspack-generator succeed `);
};

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 104ceab

Please sign in to comment.