Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Webpack Compilation Error: "You may need an appropriate loader to handle this file type" error after upgrading to 19.0.0 #517

Closed
yalpertem opened this issue Jul 27, 2022 · 2 comments

Comments

@yalpertem
Copy link

yalpertem commented Jul 27, 2022

Describe the bug

We're using @keycloak/keycloak-admin-client in a cypress test project. After upgrading the library to the version 19.0.0 we're getting webpack compilation error.

Version

19.0.0

Expected behavior

No error while importing keycloak-nodejs-admin-client in cypress.

Actual behavior

Error: Webpack Compilation Error
./node_modules/@keycloak/keycloak-admin-client/lib/resources/agent.js 16:50
Module parse failed: Unexpected token (16:50)
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
|     request({ method, path = '', urlParamKeys = [], queryParamKeys = [], catchNotFound = false, keyTransform, payloadKey, returnResourceIdInLocationHeader, ignoredKeys, headers, }) {
|         return async (payload = {}, options) => {
>             const baseParams = this.getBaseParams?.() ?? {};
|             const queryParams = queryParamKeys ? pick(payload, queryParamKeys) : null;
|             const allUrlParamKeys = [...Object.keys(baseParams), ...urlParamKeys];
 @ ./node_modules/@keycloak/keycloak-admin-client/lib/resources/resource.js 1:0-35 10:25-30
 @ ./node_modules/@keycloak/keycloak-admin-client/lib/resources/cache.js
 @ ./node_modules/@keycloak/keycloak-admin-client/lib/client.js
 @ ./node_modules/@keycloak/keycloak-admin-client/lib/index.js

How to Reproduce?

package.json:

{
  ...
  "scripts": {
     ...
  },
  ...
  "devDependencies": {
    "cypress": "9.6.0",
    "cypress-file-upload": "^5.0.8",
    "cypress-multi-reporters": "^1.6.1",
    "mocha-junit-reporter": "^2.0.2"
  },
  ...
  "dependencies": {
    "@keycloak/keycloak-admin-client": "^19.0.0"
  }
}

Run a test that uses @keycloak/keycloak-admin-client.

Anything else?

  • There is no typescript, webpack, babel etc. configuration. The 18.0.2 version works well.
  • I couldn't see any breaking changes related to the new version in the release notes or merged PRs. That's why I created an issue that might help others too if they encounter a similar problem.
@jonkoops
Copy link
Contributor

You're using a version of WebPack that doesn't support optional chaining. You'll have to use a more modern version of WebPack that supports this syntax, or include a transpiler that converts it to an older syntax.

@jonkoops jonkoops closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2022
@yalpertem
Copy link
Author

Thanks a lot for the explanation 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants