Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unexpected token ." on "})?.classGroupId;" due to no optional chaining operator support in certain node_modules runtimes, via tailwind-merge usage. #128

Closed
nicksergeant opened this issue Nov 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@nicksergeant
Copy link

nicksergeant commented Nov 29, 2023

Describe the bug

Started seeing some Sentries via tailwind-merge originating from tailwind-variants:

  }
  var classRest = classParts.join(CLASS_PART_SEPARATOR);
  return classPartObject.validators.find(function (_ref) {
    var validator = _ref.validator;
    return validator(classRest);
  })?.classGroupId;
}
var arbitraryPropertyRegex = /^\[(.+)\]$/;
function getGroupIdForArbitraryProperty(className) {
  if (arbitraryPropertyRegex.test(className)) {
    var arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];

To Reproduce

Install tailwind-variants in a new Next.js project and run in the app in a browser that doesn't natively support optional chaining operator. Chrome 60.0.3112 on Windows 7 is a good example.

Expected behavior

No errors.

Screenshots

No visual errors.

Potential solution

Via dcastil/tailwind-merge#344 (comment) it seems that we can upgrade tailwind-variant's usage of tailwind-merge by upgrading to v2 and using:

import { twMerge } from 'tailwind-merge/es5'
@nicksergeant nicksergeant added the bug Something isn't working label Nov 29, 2023
@nicksergeant nicksergeant changed the title "Unexpected token ." on "})?.classGroupId;" due to no optional chaining operator support in certain node_modules runtimes. "Unexpected token ." on "})?.classGroupId;" due to no optional chaining operator support in certain node_modules runtimes, via tailwind-merge usage. Nov 29, 2023
@mskelton
Copy link
Collaborator

As discussed in #129, the transpilePackages option in Next.js can solve this for users that need to support very old browsers.

@mskelton mskelton closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants