Skip to content

Commit 8744330

Browse files
mandarinivsavkin
authored andcommitted
fix(bundling): react-standalone take into account bundler (#14573)
1 parent 5ae53c6 commit 8744330

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

e2e/workspace-create/src/create-nx-workspace.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('create-nx-workspace', () => {
3232
checkFilesExist('project.json');
3333
});
3434

35-
it('should create a workspace with a single react app at the root', () => {
35+
it('should create a workspace with a single react app with vite at the root', () => {
3636
const wsName = uniq('react');
3737

3838
runCreateWorkspace(wsName, {
@@ -45,6 +45,23 @@ describe('create-nx-workspace', () => {
4545

4646
checkFilesExist('package.json');
4747
checkFilesExist('project.json');
48+
checkFilesExist('vite.config.ts');
49+
});
50+
51+
it('should create a workspace with a single react app with webpack at the root', () => {
52+
const wsName = uniq('react');
53+
54+
runCreateWorkspace(wsName, {
55+
preset: 'react-standalone',
56+
appName: wsName,
57+
style: 'css',
58+
packageManager,
59+
bundler: 'webpack',
60+
});
61+
62+
checkFilesExist('package.json');
63+
checkFilesExist('project.json');
64+
checkFilesExist('webpack.config.js');
4865
});
4966

5067
it('should be able to create an empty workspace built for apps', () => {

packages/create-nx-workspace/bin/create-nx-workspace.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
241241
skipGit,
242242
commit,
243243
framework,
244+
bundler,
244245
} = parsedArgs;
245246

246247
output.log({
@@ -266,6 +267,7 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
266267
nxCloud,
267268
defaultBase,
268269
framework,
270+
bundler,
269271
}
270272
);
271273

packages/workspace/src/generators/new/generate-preset.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export function generatePreset(host: Tree, opts: NormalizedSchema) {
7373
opts.linter ? `--linter=${opts.linter}` : null,
7474
opts.npmScope ? `--npmScope=${opts.npmScope}` : `--npmScope=${opts.name}`,
7575
opts.preset ? `--preset=${opts.preset}` : null,
76+
opts.bundler ? `--bundler=${opts.bundler}` : null,
7677
opts.framework ? `--framework=${opts.framework}` : null,
7778
opts.packageManager ? `--packageManager=${opts.packageManager}` : null,
7879
parsedArgs.interactive ? '--interactive=true' : '--interactive=false',

packages/workspace/src/generators/new/new.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface Schema {
2626
defaultBase: string;
2727
framework?: string;
2828
linter?: Linter;
29+
bundler?: 'vite' | 'webpack';
2930
packageManager?: PackageManager;
3031
}
3132

packages/workspace/src/generators/preset/preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function createPreset(tree: Tree, options: Schema) {
7171
rootProject: true,
7272
bundler: options.bundler ?? 'vite',
7373
e2eTestRunner: 'cypress',
74-
unitTestRunner: 'vitest',
74+
unitTestRunner: options.bundler === 'vite' ? 'vitest' : 'jest',
7575
});
7676
} else if (options.preset === Preset.NextJs) {
7777
const { applicationGenerator: nextApplicationGenerator } = require('@nrwl' +

0 commit comments

Comments
 (0)