diff --git a/commands/application.react.js b/commands/application.react.js index a291e6007..ba8299894 100644 --- a/commands/application.react.js +++ b/commands/application.react.js @@ -101,6 +101,7 @@ const addTemplate = (appPath, appName, templateOptions) => { const templateSourcePath = path.join(__dirname, '..', 'templates', 'react', 'application'); const packagePath = path.join(appPath, 'package.json'); const manifestPath = path.join(appPath, 'public', 'manifest.json'); + const indexPath = path.join(appPath, 'src', 'index.js'); const styles = [ 'devextreme/dist/css/dx.common.css', './themes/generated/theme.additional.css', @@ -112,6 +113,7 @@ const addTemplate = (appPath, appName, templateOptions) => { } preparePackageJsonForTemplate(packagePath, appName); updateJsonPropName(manifestPath, appName); + addPolyfills(packagePath, indexPath); install({}, appPath, styles); }; @@ -124,6 +126,15 @@ const install = (options, appPath, styles) => { runCommand('npm', ['install'], { cwd: appPath }); }; +const addPolyfills = (packagePath, indexPath) => { + const packages = [ + { name: 'react-app-polyfill', version: '^1.0.0' } + ]; + + packageJsonUtils.addDependencies(packagePath, packages); + moduleUtils.insertImport(indexPath, './polyfills'); +}; + const addStylesToApp = (filePath, styles) => { styles.forEach(style => { moduleUtils.insertImport(filePath, style); diff --git a/templates/react/application/src/polyfills.js b/templates/react/application/src/polyfills.js new file mode 100644 index 000000000..89b637058 --- /dev/null +++ b/templates/react/application/src/polyfills.js @@ -0,0 +1,2 @@ +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable';