Bootstrap for ReactJS - reactjs

I installed a npm package bootstrap#4.1.0 for ReactJS portfolio App , but getting an error that non-JS module files deprecated.
So should I stop thinking of using Bootstrap for React app?
crbug/1173575, non-JS module files deprecated.
This is my package.json:
"name": "react-scripts",
"version": "4.0.3",
"description": "Configuration and scripts for Create React App.",
"repository": {
"type": "git",
"url": "https://github.com/facebook/create-react-app.git",
"directory": "packages/react-scripts"
},
"license": "MIT",
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"bugs": {
"url": "https://github.com/facebook/create-react-app/issues"
},
"files": [
"bin",
"config",
"lib",
"scripts",
"template",
"template-typescript",
"utils"
],
"bin": {
"react-scripts": "./bin/react-scripts.js"
},
"types": "./lib/react-app.d.ts",
"dependencies": {
"#babel/core": "7.12.3",
"#pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"#svgr/webpack": "5.5.0",
"#typescript-eslint/eslint-plugin": "^4.5.0",
"#typescript-eslint/parser": "^4.5.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
"camelcase": "^6.1.0",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "4.3.0",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"eslint": "^7.11.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.9.2",
"eslint-webpack-plugin": "^2.5.2",
"file-loader": "6.1.1",
"fs-extra": "^9.0.1",
"html-webpack-plugin": "4.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"mini-css-extract-plugin": "0.11.3",
"optimize-css-assets-webpack-plugin": "5.0.4",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2",
"prompts": "2.4.0",
"react-app-polyfill": "^2.0.0",
"react-dev-utils": "^11.0.3",
"react-refresh": "^0.8.3",
"resolve": "1.18.1",
"resolve-url-loader": "^3.1.2",
"sass-loader": "^10.0.5",
"semver": "7.3.2",
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
"url-loader": "4.1.1",
"webpack": "4.44.2",
"webpack-dev-server": "3.11.1",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "5.1.4"
},
"devDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"optionalDependencies": {
"fsevents": "^2.1.3"
},
"peerDependencies": {
"react": ">= 16",
"typescript": "^3.2.1 || ^4"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"gitHead": "f92c37a6e6636ed1650ffd976c6881f59b1be803"
}
This is my webpack.config.js:
``` {
test: cssRegex,
exclude: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
modules:true,
sourceMap: isEnvProduction
? shouldUseSourceMap
: isEnvDevelopment,
}),
// Don't consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},```
Hope I have shared it correctly:)

Related

Module not found: Can't resolve 'apollo-client'

While migrating from apollo-boost to #apollo/client 3.x lib. for reactjs-graphql application facing this issue.
Failed to compile.
./node_modules/#apollo/react-hooks/lib/react-hooks.esm.js
Module not found: Can't resolve 'apollo-client' in 'C:\geospat\node_modules\#apollo\react-hooks\lib'
For reference used apollo-boost-migration and apollo-client-3-migration documents.
Below is the new package.json
{
"name": "gui",
"version": "0.1.0",
"private": true,
"dependencies": {
"#apollo/client": "^3.3.21",
"graphql": "14.5.8",
"#material-ui/core": "^4.11.0",
"leaflet": "1.5.1",
"luxon": "^1.24.1",
"moment": "2.24.0",
"i18next": "17.0.12",
"i18next-xhr-backend": "3.1.2",
"#types/jest": "24.0.17",
"#types/leaflet": "1.5.1",
"#types/luxon": "^1.24.0",
"#types/node": "12.7.1",
"#types/react": "16.9.1",
"#types/react-dom": "16.8.5",
"#types/react-leaflet": "2.4.0",
"#types/react-loader-spinner": "^3.1.0",
"#types/recharts": "^1.8.16",
"classnames": "2.2.6",
"jest-sonar-reporter": "2.0.0",
"node-sass": "4.12.0",
"normalize.css": "8.0.1",
"numeral": "2.0.6",
"ramda": "0.26.1",
"react": "16.12.0",
"react-apollo": "3.1.3",
"react-dom": "16.12.0",
"react-i18next": "10.12.2",
"react-idle-timer": "^4.5.2",
"react-leaflet": "2.4.0",
"react-loader-spinner": "^3.1.14",
"react-redux": "7.1.0",
"react-router-dom": "5.0.1",
"react-scripts": "3.3.0",
"redux": "4.0.4",
"typescript": "3.5.3",
"use-query-params": "0.4.5"
},
"devDependencies": {
"#types/classnames": "2.2.9",
"#types/debug": "4.1.5",
"#types/enzyme": "3.10.3",
"#types/enzyme-adapter-react-16": "1.0.5",
"#types/enzyme-to-json": "1.5.3",
"#types/ramda": "0.26.29",
"#types/react-redux": "7.1.1",
"#types/react-router-dom": "4.3.5",
"#types/redux-mock-store": "1.0.1",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.14.0",
"enzyme-to-json": "3.4.0",
"mock-apollo-client": "1.1.0",
"react-dates": "21.0.1",
"react-leaflet-vectorgrid": "2.2.1",
"recharts": "1.7.1",
"redux-devtools-extension": "2.13.8",
"redux-mock-store": "1.5.3",
"waait": "1.0.5"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"collectCoverageFrom": [
"!src/**/*.snap",
"src/components/**/*.{ts,tsx}",
"src/configuration/**/*"
],
"transformIgnorePatterns": []
},
"jestSonar": {
"reportPath": "coverage",
"reportFile": "jest-sonar-report.xml",
"indent": 4
}
}
Tried deleting old node_modules directory and then ran npm i command but the same error was shown on the console.
What is missed here?
When migrating to #apollo/client 3.x from earlier version or apollo-boost, all other apollo related libraries needs to be removed and their references in code ( mostly import statements ) needs to be replaced by '#apollo/client'.
In the above package.json most of the apollo packages were removed except "react-apollo".
Once that package is removed, the error mentioned above went away or rather replaced by new errors.
But it's just replacing the erring import statements with the one for '#apollo/client'.
npm i #apollo/client and then using #apollo/client in import statement

CSS Loader has been initialized using an options object that does not match the API schema

Error: Module build failed: ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
options has an unknown property 'localIdentName'. These properties are valid:
object { url?, import?, modules?, icss?, sourceMap?, importLoaders?, esModule? }
below is the package.json file of my create-react-app
please help me find the error.
{
"name": "burger-project",
"version": "0.1.0",
"private": true,
"dependencies": {
"autoprefixer": "7.1.6",
"axios": "^0.19.2",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "^26.3.0",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.2",
"babel-runtime": "6.26.0",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"dotenv": "4.0.0",
"dotenv-expand": "4.2.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.1.0",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.29.0",
"jest": "^26.4.2",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
"promise": "8.0.1",
"prop-types": "^15.7.2",
"raf": "3.4.0",
"react": "^16.13.1",
"react-dev-utils": "^5.0.2",
"react-dom": "^16.13.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"resolve": "1.6.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.6.2",
"webpack-dev-server": "^2.7.1",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node",
"mjs"
]
},
"babel": {
"presets": [
"react-app"
]
},
"eslintConfig": {
"extends": "react-app"
},
"devDependencies": {
"babel-plugin-add-module-exports": "^1.0.2",
"css-loader": "^3.1.0",
"webpack": "^3.0.0"
}
}

Noob question: How can I turn my create-react-app into a standalone offline video game .exe program that does not require anything else to run?

I'm making a video game with create-react-app and typescript. I've tried distributing with electron but it is such a mess and I'm totally lost. I've put so much effort on this game that I really need to make a proper .exe build for, and now that I want to make a build I'm totally lost and helpless.
Also, there are some stuff I need to be able to do:
I need to be able to change resolution from the .tsx files
I need to be able to toggle fullscreen from the .tsx files
I need to be able to load assets located in /src
Everything needs to run locally and even offline
I need my public folder to be trully accessible and moddable for the end user
I can't find anything that I can properly understand and execute after several weeks of trying.
Please help.
nb: I did this eject thing once to fix electron which can't be undone.
directories and how things are structured
My package.json file:
{
"name": "<the name>",
"author": "<my name>",
"version": "0.1.0",
"description": "<the description>",
"private": true,
"dependencies": {
"#babel/core": "7.9.0",
"#electron/typescript-definitions": "^8.7.4",
"#kennethormandy/react-fittext": "^0.6.0",
"#material-ui/icons": "^4.9.1",
"#react-native-community/async-storage": "^1.10.0",
"#svgr/webpack": "4.3.3",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"#typegoose/typegoose": "^7.0.0",
"#types/jest": "^24.9.1",
"#types/mongoose": "^5.7.14",
"#types/node": "^12.12.37",
"#types/react": "^16.9.34",
"#types/react-beautiful-dnd": "^12.1.2",
"#types/react-dom": "^16.9.7",
"#types/socket.io-client": "^1.4.32",
"#types/tweenjs": "^1.0.0",
"#typescript-eslint/eslint-plugin": "^2.10.0",
"#typescript-eslint/parser": "^2.10.0",
"alm": "^2.39.1",
"babel-eslint": "10.1.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"electron-browser-storage": "^1.0.6",
"electron-simple-window-manager": "^1.1.1",
"electron-store": "^5.1.1",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0",
"fs-extra": "^8.1.0",
"howler": "^2.2.0",
"html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"mongoose": "^5.9.11",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.4",
"popmotion": "^8.7.3",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-aspect-ratio": "^1.0.42",
"react-beautiful-dnd": "^13.0.0",
"react-dev-utils": "^10.2.1",
"react-dnd": "^10.0.2",
"react-dnd-html5-backend": "^10.0.2",
"react-dom": "^16.13.1",
"react-draggable": "^4.3.1",
"react-fittext": "^1.0.0",
"react-icons": "^3.10.0",
"react-image-tint": "^1.0.2",
"react-native-easy-dnd": "^1.0.2",
"react-responsive-spritesheet": "^2.3.9",
"react-textfit": "^1.1.0",
"react-z-index": "^3.0.0",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass-loader": "8.0.2",
"semver": "6.3.0",
"socket.io-client": "^2.3.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "2.3.5",
"ts-pnp": "1.1.6",
"tweenjs": "^1.0.2",
"typescript-react-draggable": "^1.0.0",
"url-loader": "2.3.0",
"webpack": "4.42.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1",
"xml-js": "^1.6.11"
},
"scripts": {
"pack": "electron-builder build --dir",
"dist": "npm run build && electron-builder build",
"postinstall": "install-app-deps",
"start": "nf start -p 3000",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"eject": "node scripts/eject.js",
"electron": "electron .",
"electron-start": "node src/electron-wait-react.js",
"react-start": "set BROWSER=nul && node scripts/start.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/express": "^4.17.6",
"#types/howler": "^2.1.2",
"#types/socket.io": "^2.1.4",
"electron-builder": "^22.6.0",
"express": "^4.17.1",
"foreman": "^3.0.1",
"node-sass": "^4.14.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-native-web": "0.11.2",
"socketio": "^1.0.0",
"typescript": "^3.8.3"
},
"homepage": "./",
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [
"C:\\Users\\mr003\\Documents\\programmation\\ZwangReact\\zwang\\src"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}

my react app is not rendering in internet explorer (because of arrow function)

My react+redux app is not working on Internet explorer 11. It is working fine on edge, Firefox and chrome.
I have already tried so many answers available on internet like this but didn't get any success, below attached error is I am getting in console
when I opened this error it shows like this
this file is generating when I am serving my app and can't change anything manually
package.json
{
"jest": {
"roots": [
"<rootDir>/"
],
"moduleFileExtensions": [
"js",
"jsx",
"json"
],
"testURL": "http://localhost",
"moduleDirectories": [
"node_modules",
"utils"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"coverageReporters": [
"text"
],
"collectCoverageFrom": [
"**/*.{js,jsx}",
"!**/node_modules/**",
"!**/flow-typed/**",
"!**/vendor/**",
"!./*"
],
"setupFilesAfterEnv": [
"./utils/jestUtils/setupTests.js"
],
"testEnvironment": "./utils/jestUtils/freezeDateEnvironment.js",
"moduleNameMapper": {
"\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/utils/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/utils/__mocks__/fileMock.js"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#synapsestudios/react-drop-n-crop": "^0.2.0",
"attr-accept": "^1.1.0",
"axios": "^0.19.0",
"babel-polyfill": "^6.26.0",
"classnames": "^2.2.6",
"clone-deep": "^3.0.1",
"d3": "^4.9.1",
"deep-equal": "^1.0.1",
"draft-js": "0.10.5",
"draft-js-buttons": "2.0.1",
"draft-js-export-html": "1.2.0",
"file-saver": "^1.3.8",
"formsy-react": "^0.19.5",
"history": "^4.6.3",
"libphonenumber-js": "1.7.16",
"locate-path": "^2.0.0",
"mime": "^2.0.3",
"moment": "^2.18.1",
"nanoid": "^1.0.1",
"node": "^12.10.0",
"node-gyp": "^5.0.3",
"path-to-regexp": "^2.2.1",
"prettier": "^1.6.1",
"prop-types": "^15.5.10",
"qs": "6.7.0",
"query-string": "5.1.1",
"react": "16.7.0",
"react-app-polyfill": "^1.0.5",
"react-autofill": "^1.1.4",
"react-cropper": "^1.0.0",
"react-datepicker": "^1.4.1",
"react-dom": "16.7.0",
"react-dropzone": "^4.1.3",
"react-geosuggest": "2.12.0",
"react-html-parser": "^2.0.2",
"react-infinite-scroller": "^1.1.1",
"react-input-range": "^1.1.4",
"react-intl": "^2.4.0",
"react-intl-redux": "^0.7.0",
"react-media": "^1.8.0",
"react-modal": "^2.3.3",
"react-phone-number-input": "2.3.2",
"react-quill": "^1.0.0",
"react-redux": "^5.0.5",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.2",
"react-scripts": "1.0.10",
"react-select": "^1.0.0-rc.5",
"react-select-plus": "^1.1.0",
"react-tooltip": "^3.3.0",
"react-transition-group": "2.5.3",
"recompact": "^3.3.0",
"redux": "4.0.1",
"redux-form": "7.3.0",
"redux-thunk": "^2.2.0",
"reselect": "^3.0.1",
"resolve-url-loader": "^2.0.2",
"select2": "^4.0.3",
"snake-case": "^2.1.0",
"svg-inline-loader": "^0.7.1",
"svg-url-loader": "^2.0.2",
"validator": "^8.0.0"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"ie 11",
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/core": "7.4.4",
"#babel/node": "7.4.5",
"#babel/plugin-proposal-class-properties": "7.4.4",
"#babel/plugin-proposal-object-rest-spread": "7.4.4",
"#babel/plugin-proposal-optional-chaining": "7.2.0",
"#babel/plugin-transform-arrow-functions": "7.2.0",
"#babel/plugin-transform-classes": "7.4.4",
"#babel/plugin-transform-runtime": "7.4.4",
"#babel/preset-env": "7.4.4",
"#babel/preset-flow": "7.0.0",
"#babel/preset-react": "7.0.0",
"autoprefixer": "^9.5.1",
"axios-mock-adapter": "^1.10.0",
"babel-eslint": "10.0.1",
"babel-loader": "8.0.6",
"babel-plugin-react-intl": "3.0.1",
"babel-plugin-react-intl-auto": "1.7.0",
"colors": "1.3.3",
"cross-env": "^5.1.4",
"css-loader": "3.0.0",
"cssnano": "4.1.10",
"del-cli": "^1.1.0",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "1.7.1",
"eslint": "5.16.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-import-resolver-webpack": "^0.10.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-flowtype": "3.8.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jest": "22.1.2",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"file-loader": "3.0.1",
"flow-babel-webpack-plugin": "1.1.1",
"flow-bin": "0.102.0",
"flow-typed": "2.5.2",
"glob": "^7.1.2",
"jest": "24.8.0",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.12.0",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^3.0.0",
"react-docgen": "^2.20.1",
"react-hot-loader": "^4.3.12",
"react-test-renderer": "^15.6.2",
"redux-devtools": "3.5.0",
"redux-devtools-dock-monitor": "1.1.3",
"redux-devtools-log-monitor": "1.4.0",
"redux-mock-store": "^1.4.0",
"sass-loader": "^6.0.6",
"uglifyjs-webpack-plugin": "^1.1.2",
"url-loader": "^2.1.0",
"webpack": "4.31.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "3.3.1"
}
}
.babelrc
{
"presets": [
["#babel/preset-env", { "targets": { "ie": "11", "esmodules": true }}],
"#babel/preset-react",
"#babel/preset-flow"
],
"plugins": [
"#babel/plugin-transform-runtime",
"#babel/plugin-proposal-object-rest-spread",
"#babel/plugin-proposal-class-properties",
"#babel/plugin-proposal-optional-chaining",
"react-hot-loader/babel",
"#babel/plugin-transform-classes",
"#babel/plugin-transform-arrow-functions"
],
"env": {
"lang":{
"plugins": ["#babel/plugin-syntax-object-rest-spread", ["react-intl", {
"messagesDir": "../assets/build-translations/messages/"
}]]
}
}
}
webpackconfig.js
const { DefinePlugin, NamedModulesPlugin } = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
const path = require('path');
require('babel-polyfill');
const webpackAlias = require('./webpack.config.alias');
const pagenames = require('./utils/pageNames');
const DEV_SERVER_PUBLIC_PATH = 'http://192.168.1.14:44444/webpack/static/';
const environment = process.env && process.env.NODE_ENV || 'production';
const PROD = environment === 'production';
const environmentValues = new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(environment)
});
const UglifyJSPluginInit = new UglifyJSPlugin({
uglifyOptions: {
beautify: false,
ecma: 6,
compress: true,
comments: false,
parallel: true,
sourceMap: true,
warnings: false,
}
});
const flowPlugin = environment === 'lang' ? [] : [new FlowBabelWebpackPlugin()];
const commonPlugins = [environmentValues, ...flowPlugin, new MiniCssExtractPlugin({
filename: '[name].css',
})];
const productionPlugins = [UglifyJSPluginInit];
const pluginsArr = PROD
? [...commonPlugins, ...productionPlugins]
: [...commonPlugins, new NamedModulesPlugin()];
const devtool = PROD ? false : 'cheap-source-map';
const imagePublicPath = PROD ? '/static/' : DEV_SERVER_PUBLIC_PATH;
const modeAlias = PROD ? 'production' : 'development';
const outputPath = path.resolve(__dirname, '../assets');
const entry = {
app: './utils/app.js',
'password-reset': './utils/scss/password-reset.scss',
[pagenames.pageNames1]: './fileurl.js',
[pagenames.pageNames2]: './fileurl.js',
[pagenames.pageNames3]: './fileurl.js',
[pagenames.pageNames4]: './fileurl.js',
};
const config = {
...webpackAlias,
mode: modeAlias,
optimization: {
splitChunks: {
cacheGroups: {
commons: {
minChunks: 13,
name: 'commons',
chunks: 'all',
},
},
}
},
context: __dirname,
entry,
devtool,
output: {
path: outputPath,
publicPath: '/webpack/static/',
filename: '[name].js',
},
devServer: {
contentBase: outputPath,
port: 44444,
host: '192.168.1.14',
publicPath: DEV_SERVER_PUBLIC_PATH,
stats: {
errors: true,
warnings: true,
assets: false,
chunks: true,
chunkGroups: true,
chunkModules: true,
chunkOrigins: true,
builtAt: false,
cached: false,
timings: false,
outputPath: false,
modules: true,
entrypoints: true,
},
headers: {
"Access-Control-Allow-Origin": "\*",
}
},
module: {
rules: [
{
test: /\.svg$/,
loader: 'svg-url-loader'
},
{
test: /\.js$/,
exclude: path.resolve(__dirname, "node_modules"),
include: __dirname,
use: [
{
loader: 'babel-loader',
},
{
loader: 'eslint-loader',
options: {
failOnWarning: false,
failOnError: true
}
}
]
},
{
test: /\.(png|jpg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10000, // Convert images < 10kb to base64 strings
publicPath: imagePublicPath // Since the fallback is file-loader, We end up serving from /static/{file} or during development - wherever the server is located
}
}
]
},
{
test: /\.scss|css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: !PROD,
reloadAll: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
}
},
{ loader: 'postcss-loader' },
{
loader: 'resolve-url-loader'
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
},
]
}
]
},
plugins: pluginsArr
};
console.log('process.env.NODE_ENV', environment);
module.exports = config;
Any help would be appreciated, Thanks in advance.
I can see on your .babelrc presets, under #babel/preset-env you are defining "esmodules": true.
Based on the #babel/preset-env documentation, if you set esmodules to true, browsers targets will be ignored.
Please note: when specifying the esmodules target, browsers targets will be ignored.
Can you try changing this option to see if you have any luck?
Also, I suggest you try a production build to see if you get the same error/behavior.
Try to delete the package-lock.json and the node_modules folder, then using the following package.json content (change the name to your application name. In this file, I changed some package version.) and execute the npm install commands to install the related package. I have created a sample using this file, it works well on my side.
{
"name": "<your application name>",
"version": "0.1.0",
"private": true,
"dependencies": {
"#synapsestudios/react-drop-n-crop": "^0.2.0",
"attr-accept": "^1.1.0",
"axios": "^0.19.0",
"babel-polyfill": "^6.26.0",
"classnames": "^2.2.6",
"clone-deep": "^3.0.1",
"d3": "^4.9.1",
"deep-equal": "^1.0.1",
"draft-js": "0.10.5",
"draft-js-buttons": "2.0.1",
"draft-js-export-html": "1.2.0",
"file-saver": "^1.3.8",
"formsy-react": "^0.19.5",
"history": "^4.6.3",
"libphonenumber-js": "1.7.16",
"locate-path": "^2.0.0",
"mime": "^2.0.3",
"moment": "^2.18.1",
"nanoid": "^1.0.1",
"node": "^12.10.0",
"node-gyp": "^5.0.3",
"path-to-regexp": "^2.2.1",
"prettier": "^1.6.1",
"prop-types": "^15.5.10",
"qs": "6.7.0",
"query-string": "5.1.1",
"raf": "^3.4.1",
"react": "^16.8.6",
"react-app-polyfill": "^1.0.1",
"react-autofill": "^1.1.4",
"react-cropper": "^1.0.0",
"react-datepicker": "^1.4.1",
"react-dom": "^16.8.6",
"react-dropzone": "^4.1.3",
"react-geosuggest": "2.12.0",
"react-html-parser": "^2.0.2",
"react-infinite-scroller": "^1.1.1",
"react-input-range": "^1.3.0",
"react-intl": "^2.4.0",
"react-intl-redux": "^0.7.0",
"react-media": "^1.8.0",
"react-modal": "^2.3.3",
"react-phone-number-input": "2.3.2",
"react-quill": "^1.0.0",
"react-redux": "^7.1.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.2",
"react-scripts": "3.0.1",
"react-select": "^1.0.0-rc.5",
"react-select-plus": "^1.1.0",
"react-tooltip": "^3.3.0",
"react-transition-group": "2.5.3",
"recompact": "^3.3.0",
"redux": "^4.0.4",
"redux-form": "^8.2.5",
"redux-thunk": "^2.2.0",
"reselect": "^3.0.1",
"resolve-url-loader": "^2.0.2",
"select2": "^4.0.3",
"snake-case": "^2.1.0",
"svg-inline-loader": "^0.7.1",
"svg-url-loader": "^2.0.2",
"validator": "^8.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"ie 11",
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/core": "7.4.4",
"#babel/node": "7.4.5",
"#babel/plugin-proposal-class-properties": "7.4.4",
"#babel/plugin-proposal-object-rest-spread": "7.4.4",
"#babel/plugin-proposal-optional-chaining": "7.2.0",
"#babel/plugin-transform-arrow-functions": "7.2.0",
"#babel/plugin-transform-classes": "7.4.4",
"#babel/plugin-transform-runtime": "7.4.4",
"#babel/preset-env": "7.4.4",
"#babel/preset-flow": "7.0.0",
"#babel/preset-react": "7.0.0",
"autoprefixer": "^9.5.1",
"axios-mock-adapter": "^1.10.0",
"babel-eslint": "10.0.1",
"babel-loader": "8.0.6",
"babel-plugin-react-intl": "3.0.1",
"babel-plugin-react-intl-auto": "1.7.0",
"colors": "1.3.3",
"cross-env": "^5.1.4",
"css-loader": "3.0.0",
"cssnano": "4.1.10",
"del-cli": "^1.1.0",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "1.7.1",
"eslint": "5.16.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-import-resolver-webpack": "^0.10.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-flowtype": "3.8.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jest": "22.1.2",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"file-loader": "3.0.1",
"flow-babel-webpack-plugin": "1.1.1",
"flow-bin": "0.102.0",
"flow-typed": "2.5.2",
"glob": "^7.1.2",
"jest": "24.8.0",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.12.0",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^3.0.0",
"react-docgen": "^2.20.1",
"react-hot-loader": "^4.3.12",
"react-test-renderer": "^15.6.2",
"redux-devtools": "^3.5.0",
"redux-devtools-dock-monitor": "1.1.3",
"redux-devtools-log-monitor": "1.4.0",
"redux-mock-store": "^1.4.0",
"sass-loader": "^6.0.6",
"uglifyjs-webpack-plugin": "^1.1.2",
"url-loader": "^2.1.0",
"webpack": "4.31.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "3.3.1"
}
}
Unless you're supplying a .babelrc or babel.config.js (documentation) that you didn't include with your question, then your #babel/preset-env dependency may not be getting applied during transpilation.
The default behavior for #babel/preset-env is to transpile down to EMCAScript 2015+, which would then work for IE11.
Sidenote, if no targets are specified, #babel/preset-env will transform all ECMAScript 2015+ code by default.
I would suggest adding one of those. For example:
.babelrc
{
"presets": ["#babel/preset-env"]
}
babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["#babel/preset-env"],
};
}
If the arrow function is ending up in the browser, then it doesn’t look like you are transpiling your code before serving it to the browser. I see your installing webpack and Babel, but their are no scripts in your package.json to run either. As you have not shared a webpack config, you give us little to go on without seeing how the rest of your project is setup
I would suggest moving your code into create-react-app and try running it from that.
Till now Internet Explorer 11 does not ECMAScript 6 (ES6) version of JavaScript.You have to write the function in old ways (curly brackets).Some thing like below:
var name = ""
function func1(filter){
if (filter instanceof RegExp === true)
return filter.text(name)
else{
return filter === name
}
}
function testParameter(name, filters){
name = this.name
return filters.some(func1);
}
Array.some() function is of ES5 which is supported in Internet Explorer.
Reference:
https://interoperability.blob.core.windows.net/web/MS-ES5EX/%5BMS-ES5EX%5D-180828.pdf

How can I divide prod and dev version in create-react-app

I have an application on the react, when the build I want insert another path, how can this be done?
I have two files with paths that need to be changed
........................................................................................................................................
config.js
const config = {
url: 'http://45.86.181.235' // here
};
export default config;
package.json
{
"name": "celbine",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/core": "7.5.5",
"#svgr/webpack": "4.3.2",
"#typescript-eslint/eslint-plugin": "1.13.0",
"#typescript-eslint/parser": "1.13.0",
"axios": "^0.19.0",
"babel-eslint": "10.0.2",
"babel-jest": "^24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-named-asset-import": "^0.3.3",
"babel-preset-react-app": "^9.0.1",
"camelcase": "^5.2.0",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"chart.js": "^2.8.0",
"classnames": "^2.2.6",
"css-loader": "2.1.1",
"dotenv-expand": "4.2.0",
"eslint": "^6.1.0",
"eslint-config-react-app": "^5.0.1",
"eslint-loader": "2.2.1",
"eslint-plugin-flowtype": "3.13.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "3.0.1",
"font-awesome": "^4.7.0",
"fs-extra": "7.0.1",
"html-webpack-plugin": "4.0.0-beta.5",
"identity-obj-proxy": "3.0.0",
"is-wsl": "^1.1.0",
"jest": "24.8.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.8.0",
"jest-watch-typeahead": "0.3.1",
"jwt-decode": "^2.2.0",
"mini-css-extract-plugin": "0.5.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"parallax-js": "^3.1.0",
"pnp-webpack-plugin": "1.5.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "7.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"raphael": "^2.3.0",
"react": "^16.9.0",
"react-addons-css-transition-group": "^15.6.2",
"react-addons-transition-group": "^15.6.2",
"react-app-polyfill": "^1.0.2",
"react-chartjs-2": "^2.7.6",
"react-dev-utils": "^9.0.3",
"react-dom": "^16.9.0",
"react-moment": "^0.9.6",
"react-notifications-component": "^2.1.0",
"react-raphael": "^0.9.0",
"react-redux": "^7.1.1",
"react-router-dom": "^5.0.1",
"react-transition-group": "^4.3.0",
"redis-commander": "^0.6.6",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"sass-loader": "7.2.0",
"semver": "6.3.0",
"socket.io-client": "^2.2.0",
"style-loader": "1.0.0",
"styled-components": "^4.4.0",
"terser-webpack-plugin": "1.4.1",
"ts-pnp": "1.1.2",
"url-loader": "2.1.0",
"webpack": "4.39.1",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.3.1"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"build-prod": "set PUBLIC_URL=production11 && node scripts/start.js",
"build1": "set APP_ENV=development webpack"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
},
"devDependencies": {
"dotenv": "^6.2.0",
"react-app-env": "^1.2.3"
},
"proxy": "http://45.86.181.235" // here
}
You can keep environment variables in .env file for different environments
.env file
REACT_APP_CONFIG_URL=http://45.86.181.235
And you can access the value in react like this:
const configUrl = process.env.REACT_APP_CONFIG_URL
And if you want to change by script,
In windows:
"REACT_APP_CONFIG_URL=45.86.181.235" && npm start
In linux or macOs:
REACT_APP_CONFIG_URL=45.86.181.235 npm start
More info:
https://create-react-app.dev/docs/adding-custom-environment-variables/
Try this npm install dotenv --save
Details here: dotenv-how to ues it
In .env file, you can add this:
REACT_APP_API=http://xxxx.xxxx.xxxx.xxxx:8080/api
And in your http service for api you can use it as following
const baseURL = process.env.REACT_APP_API;
Enjoy.

Resources