#javascript #webpack #babel-loader
Вопрос:
У меня возникла проблема с анализом недавно добавленного модуля «дата-праздники» в моем проекте webpack. Я обновил до последней версии babel-core и babel-loader без какого-либо успеха.
Ошибка:
Module parse failed: Unexpected token (16:28) You may need an appropriate loader to handle this file type. | export class HolidayRule { | constructor (ruleObj) { | const { rule, fn, opts, ...other } = ruleObj | Object.assign(this, { rule, ...other }) | } @ ./node_modules/date-holidays-parser/src/index.js 2:0-32 @ ./node_modules/date-holidays/src/Holidays.js @ ./node_modules/date-holidays/src/index.js @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=scriptamp;index=0!./src/components/Modals/CalendarModal.vue @ ./src/components/Modals/CalendarModal.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=scriptamp;index=0!./src/components/Modal.vue @ ./src/components/Modal.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=scriptamp;index=0!./src/App.vue @ ./src/App.vue @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
webpack.base.conf.js:
module: { rules: [ ...(config.dev.useEslint ? [createLintingRule()] : []), { test: /.vue$/, exclude: /node_modules/, loader: 'vue-loader', options: vueLoaderConfig }, { test: /.js$/, exclude: /node_modules/, loader: 'babel-loader' } }, { test: /.(png|jpe?g|gif|svg)(?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /.(mp4|webm|ogg|mp3|wav|flac|aac)(?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('media/[name].[hash:7].[ext]') } }, { test: /.(woff2?|eot|ttf|otf)(?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } ] }
Я также попытался добавить плагины @babel/plugin-proposal-object-rest-spread, а также @babel/plugin-transform-spread, но это тоже не сработало.