nathanreyes / v-calendar

An elegant calendar and datepicker plugin for Vue.
https://vcalendar.io
MIT License
4.37k stars 850 forks source link

Failed to compile. ./node_modules/v-calendar/lib/v-calendar.umd.min.js Module parse failed: Unexpected token #683

Open KoHoKyung opened 3 years ago

KoHoKyung commented 3 years ago

Failed to compile.

./node_modules/v-calendar/lib/v-calendar.umd.min.js Module parse failed: Unexpected token (1:20648) You may need an appropriate loader to handle this file type. | (function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["v-calendar"]=e(require("vue")):t["v-calendar"]=e(t["Vue"])})("undefined"!==typeof self?self:this,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,

npm install v-calendar There is an error after installation.

I don't know what the problem is. I want to know the solution.

burakkp commented 3 years ago

I have the same kind of problem.

Davids89 commented 3 years ago

Same here

Edit:

OS: MacOS 10.15.7 Node version: 12.16.0 Yarn version: 1.22.10

beDenz commented 3 years ago

Same error but only Linux, macOS is work

doutatsu commented 3 years ago

Same, version 2.0+ just doesn't work at the moment

roarkmccolgan commented 3 years ago

Same here

doutatsu commented 3 years ago

Tagging @nathanreyes, in case he missed this one. I had to rollback myself, due to this issue

nathanreyes commented 3 years ago

Will definitely start looking into it. If anyone can edit their comment with what OS they're on, npm vs yarn...that would help out some. I see Linux for at least one person.

beDenz commented 3 years ago

fail on linux, node 8

roarkmccolgan commented 3 years ago

Same here

macOS Mojave 10.14 Node 6.14

dungtt8 commented 3 years ago

I have the same kind of problem. ZZZ MacOS 10.15.7

holiber commented 3 years ago

The minified code has an unsupported destructor operator ... This is the reason of this issue

loekwetzels commented 3 years ago
ERROR in ./node_modules/v-calendar/lib/v-calendar.umd.min.js
Module parse failed: Unexpected token (1:28639)
You may need an appropriate loader to handle this file type.

MacOS Big Sur 11.0.1 (20B29) using npm

holiber commented 3 years ago

Configuring Babel for compiling the folder inside node_modules resolved this issue for me I added these lines into Webpack config

      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,

        // v-calendar has modern js features in compiled code
        // we need to transpile them via babel
        include: /node_modules\/v-calendar/,
      },
DariuszWalkiewicz commented 3 years ago

Configuring Babel for compiling the folder inside node_modules resolved this issue for me I added these lines into Webpack config

Adding this rule to webpack.base.conf in section:

module: { rules: [ ...(config.dev.useEslint ? [createLintingRule()] : []), { test: /.vue$/, loader: 'vue-loader', options: vueLoaderConfig }, { test: /.js$/, loader: 'babel-loader', include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] }, { test: /.js$/, loader: 'babel-loader', exclude: /node_modules/, include: /node_modules\/v-calendar/, }, ....

NOT resolves this problem (win 10, npm 6.14.4, node 12.18.0)

ex1t3 commented 3 years ago

same problem, on win 10

lpf763827726 commented 3 years ago

same problem,i try to adding the rule in webpack.base.conf,but it doesn't work,(win 10, npm 6.14.8, node 14.15.1, vue 2.9.6)

Leewonwoo commented 3 years ago

npm install babel-plugin-transform-object-rest-spread -D and set the .babelrc "plugins": [ ["transform-object-rest-spread", { "useBuiltIns": true }] ] and set the webpack config { test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules\/(?!(v-calendar)\/).*/, }

or

exclude: [ // Use an object instead of a string { test: path.resolve(__dirname, 'node_modules'), // Exclude the following from the exclusion exclude: path.resolve(__dirname, 'node_modules/name-of-package') } ],

it works on me

dcolley commented 3 years ago

@Leewonwoo could you please share some context - where to put these entries? E.g. what section in

.babelrc

which section please?

vue.config.js

    "configureWebpack": {
        module: {
            rules: [
                {
                    test: /\.jsx?$/, 
                    loader: 'babel-loader', 
                    exclude: /node_modules\/(?!(v-calendar)\/).*/,
                }
            ]
        }
    }
dcolley commented 3 years ago

FYI - I downgraded to v1 and it does not have the same problem.

npm uninstall --save v-calendar
npm install --save v-calendar@1
Leewonwoo commented 3 years ago

@Leewonwoo could you please share some context - where to put these entries? E.g. what section in

.babelrc

which section please?

vue.config.js

    "configureWebpack": {
        module: {
            rules: [
                {
                    test: /\.jsx?$/, 
                    loader: 'babel-loader', 
                    exclude: /node_modules\/(?!(v-calendar)\/).*/,
                }
            ]
        }
    }

here is my .babelrc

{
 "presets": [
   ["env", { "modules": false }],
   "es2015",
   "stage-0"
 ],
 "plugins": [
   "syntax-dynamic-import",
   ["transform-object-rest-spread", { "useBuiltIns": true }]
 ]
}

and dependencies(package.json)

 "dependencies": {
    "apollo-boost": "^0.1.28",
    "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.13",
    "apollo-link-error": "^1.1.12",
    "apollo-link-http": "^1.5.16",
    "apollo-link-token-refresh": "^0.2.5",
    "apollo-link-ws": "^1.0.19",
    "apollo-upload-client": "^13.0.0",
    "apollo-utilities": "^1.3.3",
    "bootstrap-vue": "^2.20.1",
    "compression": "^1.7.1",
    "cross-env": "^5.1.1",
    "es6-promise": "^4.1.1",
    "express": "^4.16.2",
    "extract-text-webpack-plugin": "^3.0.2",
    "firebase": "^7.24.0",
    "isomorphic-unfetch": "^3.0.0",
    "lru-cache": "^4.1.1",
    "route-cache": "0.4.3",
    "serve-favicon": "^2.4.5",
    "socket.io-client": "^2.3.0",
    "stats": "^1.0.0",
    "v-calendar": "^2.1.1",
    "vue": "^2.5.22",
    "vue-analytics": "^5.22.1",
    "vue-apollo": "^3.0.0-beta.11",
    "vue-blu": "^0.1.9",
    "vue-content-loader": "^0.2.3",
    "vue-meta": "^2.3.3",
    "vue-resource": "^1.5.1",
    "vue-responsive": "^1.0.1",
    "vue-router": "^3.0.1",
    "vue-server-renderer": "^2.5.22",
    "vuex": "^3.0.1",
    "vuex-router-sync": "^5.0.0"
  },
  "devDependencies": {
    "@babel/plugin-transform-spread": "^7.12.1",
    "autoprefixer": "^7.1.6",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "chokidar": "^1.7.0",
    "css-loader": "^0.28.11",
    "file-loader": "^1.1.5",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "rimraf": "^2.6.2",
    "style-loader": "^2.0.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1",
    "sw-precache-webpack-plugin": "^0.11.4",
    "url-loader": "^0.6.2",
    "vue-loader": "^15.3.0",
    "vue-style-loader": "^4.1.2",
    "vue-template-compiler": "^2.5.22",
    "webpack": "^3.8.1",
    "webpack-dev-middleware": "^1.12.0",
    "webpack-graphql-loader": "^1.0.2",
    "webpack-hot-middleware": "^2.20.0",
    "webpack-merge": "^4.2.1",
    "webpack-node-externals": "^1.7.2"
  }
norman-kong commented 3 years ago

FYI - I downgraded to v1 and it does not have the same problem.

npm uninstall --save v-calendar
npm install --save v-calendar@1

this worked for me !

websiteduck commented 3 years ago

I was able to get v2 working in laravel mix by installing: npm install laravel-mix-transpile-node-modules --save-dev

then adding to webpack.mix.js:

let mix = require('laravel-mix');
require('laravel-mix-transpile-node-modules');
mix.transpileNodeModules(['v-calendar']);
erenergul commented 3 years ago

So there is no proper fix for this issue ?

sefacndmr01 commented 3 years ago

Same here,

Win10, npm 6.14.6

monochromatique commented 3 years ago

So, really no solution since more than half an year? Looks like abandoned project..

red-fox-yj commented 1 year ago

FYI - I downgraded to v1 and it does not have the same problem.

npm uninstall --save v-calendar
npm install --save v-calendar@1

谢谢

lbgm commented 1 year ago

i know this issue is old, but if it can helps anyone:

My v-calendar version : 3.0.0-alpha.7

// babel.config.js
module.exports = {
  presets: ['@vue/cli-plugin-babel/preset'],
  plugins: [
    '@babel/plugin-proposal-optional-chaining',
    '@babel/plugin-proposal-nullish-coalescing-operator',
  ],
};

First solution

Configure vue.config.js's transpileDependencies option as below:

// vue.config.js
module.exports = {
  publicPath: '/',
  transpileDependencies: [
    'v-calendar',
    'vue3-pdf',
    '@fawmi/vue-google-maps'
  ],
  configureWebpack: {
    optimization: {
      splitChunks: {
          chunks: 'async',
          minSize: 150000,
          maxSize: 300000
      }
    }
  }
  //...
};

Second Solution: not work on all project

Configure vue.config.js as below with esbuild-loader: https://github.com/esbuild-kit/esbuild-loader

module.exports = {
  // ...
  configureWebpack: {
    module: {
      rules: [
        { test: /\.[jt]sx?$/, use: 'esbuild-loader' },
      ]
    }
  }
 //...
};
Wladisluv commented 7 months ago

FYI - I downgraded to v1 and it does not have the same problem.

npm uninstall --save v-calendar
npm install --save v-calendar@1

Work for me. Big thanks!)