Skip to content

Conversation

@Sebobo
Copy link

@Sebobo Sebobo commented Mar 6, 2023

When I try to include the library in a web pack build I get the following error due to the optional chaining character:

Module parse failed: Unexpected token (666:21)
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
|                               for (let ti = 0; ti < terms2.length; ti++) {
|                                       // no haystack item contained all terms
>                                       if (preFiltered?.length == 0)

@Sebobo
Copy link
Author

Sebobo commented Mar 6, 2023

Hm I see now that the library is compiled to ES2020 standards which includes the operator.
I have to target some older version, therefore I need to find a different way to build this.

@Sebobo Sebobo closed this Mar 6, 2023
@leeoniya
Copy link
Owner

leeoniya commented Mar 6, 2023

specifically, it's Webpack 4 :(

Webpack 5 (released in 2020) and all modern tools and browsers should have no problem.

https://caniuse.com/mdn-javascript_operators_optional_chaining

@Sebobo
Copy link
Author

Sebobo commented Mar 6, 2023

Yes sadly I can't update the web pack version as it's a plugin for a framework that provides the web pack config but I created a patch for now with yarn in my app to adjust the ?? ?. operators and got it working this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants