pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

Module parse failed: Unexpected token. You may need an additional loader to handle the result of these loaders. #374

Open utopictown opened 6 months ago

utopictown commented 6 months ago

hello, i got transpiling error below on my react app configured with react-app-rewired

Module parse failed: Unexpected token (2126:11)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   }
|   class Q {
>     _config;
|     hashHistory;
|     constructor({

i have tried adding some babel plugins in config-overrides.js

...
const { override, fixBabelImports, addLessLoader, addWebpackAlias, addBabelPlugin } = require('customize-cra')

module.exports = override(
  ...,
  addBabelPlugin("@babel/plugin-transform-private-property-in-object"),
  addBabelPlugin("@babel/plugin-transform-class-properties"),
  addBabelPlugin("@babel/plugin-transform-private-methods")
)

and include them in .babelrc plugins list

  {
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "object-to-json-parse", 
    "styled-components",
    "@babel/plugin-transform-private-property-in-object",
    "@babel/plugin-transform-class-properties", 
    "@babel/plugin-transform-private-methods"
  ]
}

here are some devDependencies that might be useful

    "@babel/plugin-transform-class-properties": "^7.24.1",
    "@babel/plugin-transform-private-methods": "^7.24.1",
    "@babel/plugin-transform-private-property-in-object": "^7.24.5",
    "@babel/preset-env": "^7.24.5",
    "customize-cra": "^0.9.1",
    "react-app-rewired": "^2.1.5",
    "react-scripts": "^3.4.4",

pubnub version: "^8.1.0" node version: v18.20.2

can anyone please help figuring this out?