TimDaub / simple-caldav

caldav in JavaScript; made easy.
20 stars 3 forks source link

Cannot use version 0.8 installed with npm #28

Closed mkasprz closed 3 years ago

mkasprz commented 3 years ago

I installed the version 0.8 with npm install simple-caldav@0.8 successfully, but while building a project an error occurred:

error in ./node_modules/simple-caldav/src/index.js

Module parse failed: Unexpected token (396: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 const summaryLang = alarm .getFirstProperty("summary") > ?.getParameter("language"); let summary;

It seems like ?. causes the issue (as far as I know it's not available in pure JS yet, I may be wrong though). Even after fixing the issue above, another one appears:

const descLang = alarm .getFirstProperty("description") > ?.getParameter("language"); let description;

I found two more places with ?..

Is there something more I should install or setup, or it just needs to be changed in the code?

TimDaub commented 3 years ago

Yes, that's the optional chaining operator that landed in node 14: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

It looks like you're using webpack. You may have to use babel then. Otherwise simple-caldav@0.7.1 doesn't require node >= 14.

TimDaub commented 3 years ago

Another option to solving this problem is that we embed an esbuild process that is targeting es6 browsers

mkasprz commented 3 years ago

Ok, thank You. I generally have used Babel before I believe, as I had @vue/cli-plugin-babel installed, but I've found out that by default dependencies are not transpiled. I had to include the following in my vue.conf.js.

module.exports = {
  // ...
  transpileDependencies: [
    'simple-caldav'
  ]
}

The other solution You proposed it seems reasonable to me too, if I understood it correctly. Thanks.

TimDaub commented 3 years ago

OK great! Feel free to close of your problem was resolved.