ERROR in ../../js/webix/webixClass.js 50:11 (Webpack 5.4.0)
При сборке проекта силами webpack'a, при добавлении import { SendServer } from "../../js/webix/sendServer" выскакивает ошибка:
../www-common/www/web/js/webix/webixClass.js 1.97 KiB [built] [code generated] [1 error]
ERROR in ../www-common/www/web/js/webix/webixClass.js 50:11
Module parse failed: Unexpected token (50:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| * @param def
| */
> proper = (obj = {}, name = "", def="")=>{
| if (obj.hasOwnProperty(name))
| this[name] = obj[name]
@ ../www-common/www/web/js/webix/sendServer.js 5:0-40 23:32-42
@ ./www/web/js/classAdmission.js 3:0-79
@ ./www/web/js/admission.js 1:0-49 3:31-45
@ ./www/web/js/index.js 2:0-39 102:32-41
webpack 5.4.0 compiled with 1 error in 427 ms
[webpack-cli] watching files for updates...
Стоит закомментировать импорт и ошибка исчезает.
webpack.mscd.config.js
const path = require("path"),
HTMLPlugin = require('html-webpack-plugin'),
isDev = process.env.NODE_ENV === 'development',
isProd = !isDev,
{CleanWebpackPlugin} = require('clean-webpack-plugin'),
WebpackShellPlugin = require('webpack-shell-plugin'),
MiniCssExtractPlugin = require('mini-css-extract-plugin'),
WebpackBar = require('webpackbar'),
runtime = require('babel-plugin-transform-runtime')
const filename = ext => isDev ? `[name].${ext}` : `[name].[hash].${ext}`
const cssLoaders = extra => {
const loaders = [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: isDev,
reloadAll: true
},
},
'css-loader'
]
if (extra) {
loaders.push(extra)
}
return loaders
}
module.exports = {
entry: [
'./www/web/js/index.js'
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'www', 'web', 'dist',),
publicPath: "/dist/"
},
module: {
rules: [
{
test: /\.css$/,
use: cssLoaders()
},
{
test: /\.m?js$/,
exclude: [
/\core-js\b/,
/\webpack\/buildin\b/,
/\node_modules\b/,
/\bregenerator-runtime\b/,
],
// use: {
// loader: 'babel-loader',
// options: {
// presets: [
// ['@babel/preset-env', { targets: "defaults" }]
// ]
// }
// },
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: "file-loader"
},
]
},
resolve: {
modules: [path.resolve('/node_modules')],
alias: {
'@js': path.resolve(__dirname, 'www/web/js'),
'@css': path.resolve(__dirname, 'www/web/css'),
'@scss': path.resolve(__dirname, 'www/web/scss'),
'@sass': path.resolve(__dirname, 'www/web/sass'),
'@font': path.resolve(__dirname, 'www/web/font'),
'@node_models': path.resolve(__dirname, 'node_models'),
'@dir': path.resolve(__dirname),
}
},
plugins: [
new HTMLPlugin({
inject: false,
filename: path.resolve(__dirname, './www/app/themes/1/pages/mscd/dist/index.tpl'),
template: './www/app/themes/1/pages/index.tpl',
publicPath: "/"
}),
new HTMLPlugin({
// cache: false,
// inject: false,
title: "APP",
filename: path.resolve(__dirname, './www/web/dist/index.html'),
template: './www/web/html/index.html',
"assets": {
"style": "./css/style.css",
}
// publicPath: "/"
}),
new MiniCssExtractPlugin({
filename: filename('css')
}),
new CleanWebpackPlugin({dangerouslyAllowCleanPatternsOutsideProject: true}),
new WebpackBar()
// new WebpackShellPlugin({onBuildStart:['echo "Webpack Start"'], onBuildEnd:['/bin/bash sync.sh']})
],
devtool: isDev ? 'source-map' : ''
}
package.json:
{
"name": "...",
"version": "0.8.0",
"description": "...",
"private": true,
"author": "...",
"license": "ISC",
"main": "index.js",
"directories": {
"doc": "doc"
},
"keywords": [],
"browserslist": [
"defaults",
"Firefox 29",
"safari 5"
],
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-syntax-class-properties": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.7",
"@babel/runtime": "7.12.5",
"add-asset-html-webpack-plugin": "^3.1.3",
"babel": "^6.23.0",
"babel-loader": "^8.2.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.0.15",
"babel-preset-es2017": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^7.0.2",
"css-loader": "^5.0.1",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^4.5.0",
"json-loader": "^0.5.7",
"mini-css-extract-plugin": "^1.3.1",
"moment-locales-webpack-plugin": "^1.2.0",
"node-sass": "^5.0.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"raw-loader": "^4.0.2",
"sass": "^1.29.0",
"sass-loader": "^10.1.0",
"style-loader": "^2.0.0",
"twig-html-loader": "^0.1.8",
"url-loader": "^4.1.1",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0",
"webpack-hot-middleware": "^2.25.0",
"webpack-shell-plugin": "^0.5.0",
"webpackbar": "^4.0.0"
},
"scripts": {
"mscdDev": "cross-env NODE_ENV=development webpack --mode development --config webpack.mscd.config.js --progress",
"mscdDevW": "cross-env NODE_ENV=development webpack --mode development --config webpack.mscd.config.js --watch",
"mscdPro": "cross-env NODE_ENV=production webpack --mode production --config webpack.mscd.config.js"
},
"dependencies": {
"babel-runtime": "^6.26.0"
}
}