question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional Chaining not working

See original GitHub issue

Version

4.5.11

Environment info

  System:
    OS: macOS 11.1
    CPU: (16) x64 Intel(R) Xeon(R) W-2140B CPU @ 3.20GHz
  Binaries:
    Node: 13.12.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.10 - /usr/local/bin/npm
  Browsers:
    Chrome: 88.0.4324.150
    Edge: Not Found
    Firefox: Not Found
    Safari: 14.0.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1 
    @vue/babel-helper-vue-transform-on:  1.0.2 
    @vue/babel-plugin-jsx:  1.0.3 
    @vue/babel-plugin-transform-vue-jsx:  1.2.1 
    @vue/babel-preset-app:  4.5.11 
    @vue/babel-preset-jsx:  1.2.4 
    @vue/babel-sugar-composition-api-inject-h:  1.2.1 
    @vue/babel-sugar-composition-api-render-instance:  1.2.4 
    @vue/babel-sugar-functional-vue:  1.2.2 
    @vue/babel-sugar-inject-h:  1.2.2 
    @vue/babel-sugar-v-model:  1.2.3 
    @vue/babel-sugar-v-on:  1.2.3 
    @vue/cli-overlay:  4.5.11 
    @vue/cli-plugin-babel: ~4.5.0 => 4.5.11 
    @vue/cli-plugin-eslint: ~4.5.0 => 4.5.11 
    @vue/cli-plugin-router:  4.5.11 
    @vue/cli-plugin-unit-jest: ~4.5.0 => 4.5.11 
    @vue/cli-plugin-vuex: ~4.5.0 => 4.5.11 
    @vue/cli-service: ~4.5.0 => 4.5.11 
    @vue/cli-shared-utils:  4.5.11 
    @vue/component-compiler-utils:  3.2.0 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/preload-webpack-plugin:  1.1.2 
    @vue/test-utils: ^1.0.3 => 1.1.3 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^6.2.2 => 6.2.2 
    jest-serializer-vue:  2.0.2 
    vue: ^2.6.11 => 2.6.12 
    vue-cal: ^3.7.0 => 3.10.0 
    vue-eslint-parser:  7.4.1 
    vue-flickity: ^1.2.1 => 1.2.1 
    vue-hot-reload-api:  2.3.4 
    vue-jest:  3.0.7 
    vue-loader:  15.9.6 (16.1.2)
    vue-router:  3.5.1 
    vue-server-renderer:  2.6.12 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.12 
    vue-template-es2015-compiler:  1.9.1 
    vue2-google-maps: ^0.10.7 => 0.10.7 
    vuepress: ^1.7.1 => 1.8.0 
    vuepress-html-webpack-plugin:  3.2.0 
    vuepress-plugin-container:  2.1.5 
    vuepress-plugin-smooth-scroll:  0.0.3 
    vuex: ^3.4.0 => 3.6.2 
  npmGlobalPackages:
    @vue/cli: 4.5.11

Steps to reproduce

vue-cli-service build

What is expected?

build to succeed

What is actually happening?

build failed


error in ./src/components/TheNavbar.vue?vue&type=script&lang=js&

Module parse failed: Unexpected token (86:31) File was processed with these loaders:

  • ./node_modules/cache-loader/dist/cjs.js
  • ./node_modules/thread-loader/dist/cjs.js
  • ./node_modules/babel-loader/lib/index.js
  • ./node_modules/cache-loader/dist/cjs.js
  • ./node_modules/vue-loader/lib/index.js You may need an additional loader to handle the result of these loaders. | | hasContactNumber() {
  return this.$store.state?.location?.contact_no;

| },

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
matthewsuancommented, Feb 17, 2021

Ya it was an issue with @vue/cli-plugin-babel/preset.

All the default browser targets in the said preset now supports optional chaining.

So Babel did not compile with optional chaining enabled since target browsers already support it.

2reactions
mgibascommented, Feb 23, 2021

@matthewsuan hmmm, weirdly this doesn’t work in my case - even adding IE11 doesn’t force the transpilation 😦 If you have any other ideas or things I can check it would be great. Thanks for a quick response though 👍🏼

Edit: Oh, I forgot to mention that im hitting these issues during cypress tests run

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is optional chaining not working in my Node REPL?
I literally copy pasted example code from MDN but optional chaining wont work in my node(v12.13.0) REPL. Throws out a syntax error saying ......
Read more >
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >
What is wrong with optional chaining and how to fix it - DEV ...
There is no possibility to chain custom expression working on the positive result of optional chaining. This always needs to be done by...
Read more >
Optional chaining '?.' - The Modern JavaScript Tutorial
The optional chaining ?. is a safe way to access nested object properties, even if an intermediate property doesn't exist.
Read more >
Optional chaining not working (no, not in the template) #1697
What is actually happening? My code fails to compile and Vue CLI outputs this error (doesn't like the optional chaining operator):. Building for ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found