Я искал эту проблему по поводу ... пожалуйста, поверьте мне, я прошел через все подобные проблемы с переполнением стека и на github, но не смог решить эту проблему.код находится в разработке .. мне действительно нужно исправить это .. пожалуйста, помогите
error in ./src/routes/lazy.js
Module parse failed: Unexpected token (25:11)
You may need an appropriate loader to handle this file type.
| var UserDashboard = exports.UserDashboard = (0, _reactLoadable2.default)({
| loader: function loader() {
> return import('./dashboard/user');
| },
| loading: _Loading2.default
@ ./src/containers/App.js 43:13-38
@ ./src/App.js
@ ./src/index.js
@ multi (webpack)-dev-server/client?http://localhost:3000 (webpack)/hot/dev-server.js babel-polyfill react-hot-loader/patch ./src/index.js
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: { minimize: true }
}
]
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
// Scss compiler
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}
]
},
Webpack conf
"dependencies": {
"axios": "^0.18.0",
"base-64": "^0.1.0",
"classnames": "2.2.6",
"fs": "0.0.1-security",
"jquery": "^3.3.1",
"lodash": "^4.17.11",
"module": "^1.2.5",
"moment": "^2.23.0",
"net": "^1.0.2",
"proptypes": "^1.1.0",
"react": "^16.6.3",
"react-big-calendar": "^0.20.2",
"react-calendar": "^2.18.1",
"react-chat-window": "^1.1.1",
"react-contextmenu": "^2.10.0",
"react-countdown-clock": "^2.5.0",
"react-date-picker": "^7.2.0",
"react-dom": "^16.4.1",
"react-file-base64": "^1.0.3",
"react-headroom": "^2.2.4",
"react-input-calendar": "^0.5.4",
"react-intl": "2.4.0",
"react-loadable": "^5.5.0",
"react-modal": "^3.8.1",
"react-mousetrap": "^0.2.0",
"react-perfect-scrollbar": "^1.1.1",
"react-quill": "^1.3.3",
"react-redux": "5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.4.0-beta.6",
"react-scroll-to-component": "^1.0.2",
"react-select": "^2.1.2",
"react-toastify": "^4.5.2",
"react-toastr": "^3.0.0",
"react-transition-group": "^1.2.0",
"reactstrap": "^6.3.0",
"redux": "4.0.0",
"redux-saga": "^0.16.0",
"socket.io-client": "^2.2.0",
"validator": "^10.11.0"
package.json
import Loading from 'Components/Loading';
import Loadable from 'react-loadable';
/*
User
*/
// User Dashboard
export const UserDashboard = Loadable({
loader: () => import('./dashboard/user'),
loading: Loading
});
export const UserSuccessCoach = Loadable({
loader: () => import('./user/userSuccessCoach'),
loading: Loading
});
// List of Dashboard Cards
export const UserMilestones = Loadable({
loader: () => import('./user/userMilestones'),
loading: Loading
});
export const UserOverdue = Loadable({
loader: () => import('./user/userOverdue'),
loading: Loading
});
export const UserActions = Loadable({
loader: () => import('./user/userActions'),
loading: Loading
});
lazy.js
Я попытался изменить импорт внутри тех функций, которые требуются lazy.js.затем он компилируется, но когда я пытаюсь открыть приложение, он выдает мне новую ошибку
index.js
import React from 'react';
import ReactDOM from 'react-dom';
const rootEl = document.getElementById('root');
let render = () => {
const MainApp = require('./App').default;
ReactDOM.render(<MainApp />, rootEl);
};
if (module.hot) {
module.hot.accept('./App', () => {
const NextApp = require('./App').default;
render(<NextApp />, rootEl);
});
}
render();