gruhn / vue-qrcode-reader

A set of Vue.js components for detecting and decoding QR codes.
https://gruhn.github.io/vue-qrcode-reader
MIT License
2.09k stars 335 forks source link

Module parse failed: Unexpected token (67:10) #359

Closed tangtrongnghia closed 1 year ago

tangtrongnghia commented 1 year ago

code: import { QrcodeStream } from 'vue-qrcode-reader'

build error: ERROR in ./node_modules/vue-qrcode-reader/dist/vue-qrcode-reader.js Module parse failed: Unexpected token (67:10) You may need an appropriate loader to handle this file type. | try { | return n instanceof HTMLImageElement; | } catch { | return !1; | } @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["@babel/preset-env",{"modules":false,"targets":{"browsers":["> 2%"]},"forceAllTransforms":true}]],"plugins":["@babel/plugin-proposal-object-rest-spread",["@babel/plugin-transform-runtime",{"helpers":false}],"transform-es2015-constants","syntax-dynamic-import","@babel/plugin-proposal-optional-chaining"]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/js/components/common/QrCodeScanner.vue 21:0-49

Sec-ant commented 1 year ago

This is caused by the optional catch binding (omitting catch bindings in a try...catch clause) syntax not being supported by the loader. If you use babel-loader, it should be fixed by this plugin: @babel/plugin-transform-optional-catch-binding

tangtrongnghia commented 1 year ago

not working

devDependencies

"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-transform-optional-catch-binding": "^7.22.5",
"@babel/polyfill": "^7.2.5",
"babel-eslint": "^10.0.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-es2015-constants": "^6.1.4",

.babelrc

{
    "presets": [],
    "plugins": [
        "@babel/plugin-transform-optional-catch-binding",
        "transform-es2015-constants",
        "syntax-dynamic-import",
        "@babel/plugin-proposal-optional-chaining"
    ]
}
Sec-ant commented 1 year ago

Interesting, is it still the same error? May it be caused by some sorts of conflicts between the plugins? Could you try to narrow it down by disabling some of the plugins or starting with a simple default configuration? If you can provide a minimal repro that would be helpful so I can help track down this problem.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 5.3.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: