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.

Incompatibility due to the nullish coalescing operator

See original GitHub issue

Hi,

Thank you for the polyfill, it works in latest environments but when dealing with older node versions, babel versions… it may fail to compile due to 1 nullish coalescing operator.

https://github.com/kenchris/urlpattern-polyfill/blob/main/src/url-pattern.ts#L159

I get this kind of error:

  const defaultPattern = `[^${escapeString(options.delimiter ?? "/#?")}]+?`;
                                                              ^

SyntaxError: Unexpected token '?'

I browsed a lot of topics posted across years I saw like 4-5 fixes to solve this issue. But in my case, since I have a Babel project I just had to update to:

    "core-js": "^3.22.8",

And in my babel.config.js:

module.exports = {
  presets: ['@babel/preset-env'],
};

In case you don’t have Babel and no easy way to add it you will have to investigate 😄 …

It’s not really an issue, much more something to help in case it happens to someone else (I spent hours on this to find the minimal settings to tweak to make it working).

Thank you,

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SanderEliascommented, Sep 5, 2022

@kenchris @sneko Fair point. See #104

0reactions
kenchriscommented, Sep 5, 2022

This is a minor change with little to no impact on maintenance, so if it helps someone, I am OK with it. If it had an impact on maintenance, I would probably feel different

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nullish coalescing operator makes package incompatible with ...
In conclusion, this means that this package is currently not compatible with webpack 4 without additional configuration because it includes the ...
Read more >
Nullish coalescing operator (??) - JavaScript - MDN Web Docs
The nullish coalescing (??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null ...
Read more >
Use of nullish coalescing javascript operator makes this ...
Problem/Motivation Use of nullish coalescing javascript operator makes this module incompatible with IE11 and old browser versions Steps to ...
Read more >
Nullish coalescing javascript operator not working in edge
As I said, this works Chrome and Firefox but results in a syntax error in Edge. Any ideas what I'm doing wrong? MDN...
Read more >
JavaScript Tips: Nullish Coalescing (??) - Mike Bifulco
JavaScript's Nullish Coalescing operator is two question mark characters next to one another ( ?? ). It takes a left-hand and right-hand operand ......
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