Skip to content

Commit 0f73926

Browse files
Add a version of the react with a SWC transpiler (#929)
* replace create-react-app by create-vite for creating React App template
1 parent cf234b4 commit 0f73926

File tree

13 files changed

+137
-112
lines changed

13 files changed

+137
-112
lines changed

.github/workflows/applications.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
- angular
2121
- vue-v3
2222
- react
23+
- react-swc
2324
- react-ts
25+
- react-swc-ts
2426
NODE:
2527
- 18
2628
OS:

packages/devextreme-cli/src/applications/application.react.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
const fs = require('fs');
44
const getLayoutInfo = require('../utility/prompts/layout');
55
const getTemplateTypeInfo = require('../utility/prompts/typescript');
6+
const getTranspilerTypeInfo = require('../utility/prompts/transpiler');
67
const templateCreator = require('../utility/template-creator');
78
const packageManager = require('../utility/package-manager');
89
const packageJsonUtils = require('../utility/package-json-utils');
@@ -52,6 +53,7 @@ const updateJsonPropName = (path, name) => {
5253

5354
const create = async(appName, options) => {
5455
const templateType = await getTemplateTypeInfo(options.template);
56+
const transpiler = await getTranspilerTypeInfo(options.transpiler);
5557
const layoutType = await getLayoutInfo(options.layout);
5658

5759
const templateOptions = Object.assign({}, options, {
@@ -62,7 +64,7 @@ const create = async(appName, options) => {
6264

6365
const commandArguments = [`-p=create-vite@${latestVersions['create-vite']}`, 'create-vite', appName];
6466

65-
commandArguments.push(`--template react${templateOptions.isTypeScript ? '-ts' : ''}`);
67+
commandArguments.push(`--template react${transpiler === 'swc' ? '-swc' : ''}${templateOptions.isTypeScript ? '-ts' : ''}`);
6668

6769
await runCommand('npx', commandArguments);
6870

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const prompts = require('./prompts');
2+
3+
const choices = [
4+
{ value: 'babel', title: 'Babel' },
5+
{ value: 'swc', title: 'SWC' }
6+
];
7+
8+
const question = {
9+
message: 'Specify desired transpiler type:',
10+
choices: choices
11+
};
12+
13+
const getTranspilerTypeInfo = async(defaultValue) => {
14+
return await prompts(question, choices, defaultValue);
15+
};
16+
17+
module.exports = getTranspilerTypeInfo;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { reactSwcTs } = require('../env.react');
2+
const testAppTemplate = require('../app-template.test.shared.js');
3+
testAppTemplate(reactSwcTs);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { reactSwcJs } = require('../env.react');
2+
const testAppTemplate = require('../app-template.test.shared.js');
3+
testAppTemplate(reactSwcJs);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const reactEnv = require('../env.react-ts');
1+
const { reactTs } = require('../env.react');
22
const testAppTemplate = require('../app-template.test.shared.js');
3-
testAppTemplate(reactEnv);
3+
testAppTemplate(reactTs);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const reactEnv = require('../env.react');
1+
const { reactJs } = require('../env.react');
22
const testAppTemplate = require('../app-template.test.shared.js');
3-
testAppTemplate(reactEnv);
3+
testAppTemplate(reactJs);

packages/devextreme-cli/testing/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// NOTE: All puppeteer devices: https://github.com/GoogleChrome/puppeteer/blob/master/lib/DeviceDescriptors.js
2+
const reactConfigs = require('./env.react');
23

34
exports.envs = [
45
require('./env.angular'),
5-
require('./env.react'),
6-
require('./env.react-ts'),
6+
...Object.values(reactConfigs),
77
require('./env.vue-v3'),
88
];
99

packages/devextreme-cli/testing/env.angular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports.appPath = appPath;
2929
exports.deployPath = path.join(appPath, 'dist', 'my-app', 'browser');
3030
// disable optimization due to https://github.com/angular/angular-cli/issues/20760
3131
exports.npmArgs = ['run', 'build', '--', '--configuration', 'development'];
32-
exports.fileExtention = 'ts';
32+
exports.fileExtension = 'ts';
3333

3434
exports.createApp = async(toolingVersion) => {
3535
await rimraf(sandboxPath);

packages/devextreme-cli/testing/env.react-ts.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)