Closed codal-mitalt closed 11 months ago
Can you share your package.json
, webpack config, and Babel config?
{
"name": "",
"version": "",
"private": true,
"dependencies": {
"@ant-design/charts": "^1.1.1",
"@ant-design/icons": "^4.6.2",
"@babel/core": "7.9.0",
"@datadog/browser-rum": "4.44.0",
"@fluentui/react": "^8.112.3",
"@fluentui/react-icons": "^2.0.220",
"@progress/kendo-drawing": "^1.10.1",
"@progress/kendo-licensing": "^1.1.4",
"@progress/kendo-react-pdf": "^4.7.0",
"@revenuegrid/churnzerojs": "^1.0.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",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"antd": "~4.17.3",
"antd-select-infinte-scroll": "^0.9.0",
"aws-sdk": "^2.917.0",
"axios": "^0.21.1",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"country-state-city": "^2.0.0",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"file-loader": "4.3.0",
"file-saver": "^2.0.5",
"fs-extra": "^8.1.0",
"history": "^5.0.0",
"html-webpack-plugin": "4.0.0-beta.11",
"htmldiff": "0.0.4",
"htmldiff-js": "^1.0.5",
"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",
"jspdf": "^2.3.1",
"jspdf-autotable": "^3.5.14",
"jszip": "^3.6.0",
"jszip-utils": "^0.1.0",
"mini-css-extract-plugin": "0.9.0",
"moment": "^2.29.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
"parchment": "^2.0.0-dev.2",
"pnp-webpack-plugin": "1.6.4",
"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",
"qs": "^6.10.1",
"quill": "^1.3.7",
"quill-image-compress": "^1.2.14",
"quill-image-resize-module-react": "^3.0.0",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-back-to-top-button": "0.0.14",
"react-code-splitting": "^1.2.1",
"react-copy-to-clipboard": "^5.0.3",
"react-csv": "^2.0.3",
"react-dev-utils": "^10.2.1",
"react-dom": "^16.13.1",
"react-drag-listview": "^0.1.8",
"react-export-excel": "^0.5.3",
"react-highlight-words": "^0.17.0",
"react-infinite-scroll-component": "^6.1.0",
"react-lines-ellipsis": "^0.14.1",
"react-loader-spinner": "^4.0.0",
"react-number-format": "^4.5.5",
"react-quill": "^1.3.5",
"react-redux": "^7.2.2",
"react-router-dom": "^5.1.2",
"react-scripts": "4.0.3",
"react-select": "^4.3.1",
"react-select-async-paginate": "^0.5.3",
"react-show-more-text": "^1.4.6",
"react-smooth-scrollbar": "^8.0.6",
"react-timezone-select": "^0.10.7",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.9",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass": "^1.63.6",
"sass-convert": "^0.5.2",
"sass-loader": "^8.0.2",
"semver": "6.3.0",
"sendbird-uikit": "1.1.3",
"simple-react-validator": "^1.6.0",
"smooth-scrollbar": "^8.6.2",
"style-loader": "0.23.1",
"styled-components": "^5.2.1",
"terser-webpack-plugin": "2.3.5",
"ts-pnp": "1.1.6",
"url-loader": "2.3.0",
"use-state-with-callback": "^3.0.2",
"uuid": "^9.0.0",
"web-vitals": "^1.1.0",
"xlsx": "^0.17.0"
},
"scripts": {
"start": "react-scripts node scripts_chat/start.js",
},
"lint-staged": {
"*.{ts,tsx,js,jsx,css,scss,module.scss,module.css}": "prettier --write"
},
"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": {
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-optional-chaining": "^7.22.5",
"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",
"brotli-webpack-plugin": "^1.1.0",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^6.1.1",
"cross-env": "7.0.3",
"eslint": "^7.22.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^1.6.1",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^7.0.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "4.42.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1",
"husky": "^8.0.0"
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"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"
]
}
}
here is webpack config
const CompressionPlugin = require('compression-webpack-plugin'); // gzip
const BrotliPlugin = require('brotli-webpack-plugin'); // brotli
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
optimization: {
splitChunks: {
chunks: 'all',
name: false,
},
// Keep the runtime chunk separated to enable long term caching
// https://twitter.com/wSokra/status/969679223278505985
// https://github.com/facebook/create-react-app/issues/5358
runtimeChunk: {
name: entrypoint => `runtime-${entrypoint.name}`,
},
},
plugins: [
new HtmlWebpackPlugin({
template: `public/index.html`,
favicon: `public/favicon.ico`,
}),
new CompressionPlugin({
// gzip plugin
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css|html)$/,
threshold: 8192,
minRatio: 0.8,
}),
new BrotliPlugin({
// brotli plugin
asset: '[path].br[query]',
test: /\.(js|css|html)$/,
threshold: 10240,
minRatio: 0.8,
}),
new BundleAnalyzerPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin({
/* options here */
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
],
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
],
},
entry: {
app: './app.js',
vendor: ['react', 'react-dom', 'react-router', 'styled-components'],
},
};
Can you post your Babel config?
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-optional-chaining"
]
}
Thanks. The error comes from your node_modules, specifically the ml-matrix
library. As node_modules
has been excluded from the babel-loader
, Babel can not transform that code for you. Please enable Babel for the ml-matrix
library.
// webpack.config.js
{
rules: [
{
test: /\.(?:js|mjs|cjs)$/,
exclude: {
and: [/node_modules/], // Exclude libraries in node_modules ...
not: [
// Except for a few of them that needs to be transpiled because they use modern syntax
/ml-matrix/,
]
},
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', '@babel/preset-react']
]
}
}
}
]}
See also https://github.com/babel/babel-loader#some-files-in-my-node_modules-are-not-transpiled-for-ie-11
Please consider upgrade @babel/core
and @babel/preset-env
to the latest version, then these three plugins can be safely removed as they have been included in the preset-env
.
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-optional-chaining"
Can you help me, i have same issue, but my project on CRA. And i don`t uderstand, how to use your solution. Can you help me ?
Creating an optimized production build... Failed to compile.
./node_modules/ml-matrix/src/symmetricMatrix.js 7:2 Module parse failed: Unexpected character '#' (7:2) File was processed with these loaders:
Versions
"babel-loader": "8.1.0",