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

Fixed RegExp in filter-adapter.ts and sort-context.ts to work in Safari #1279

Merged
merged 6 commits into from
Jan 22, 2024

Conversation

papaIOprog
Copy link
Contributor

Pull Request

Related issue

Fixes #1277

What does this PR do?

  • Replaces regular expressions that use lookbehind.
  • Resolves a bug specifically affecting Safari.

Copy link

changeset-bot bot commented Jan 9, 2024

🦋 Changeset detected

Latest commit: aeb1b4a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@meilisearch/instant-meilisearch Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@curquiza curquiza added the bug Something isn't working label Jan 10, 2024
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @papaIOprog
Thanks for the PR
Since your PR impacts the library, can you follow the step in the CONTRIBUTING.md regarding changeset?
https://github.com/meilisearch/meilisearch-js-plugins/blob/main/CONTRIBUTING.md#versioning-with-changesets

Also, can you ensure the PR passes the tests? I see some tests in the CI failing.

@curquiza
Copy link
Member

Also, can you add tests please? 😊

@papaIOprog papaIOprog marked this pull request as draft January 10, 2024 14:24
@papaIOprog papaIOprog requested a review from curquiza January 10, 2024 15:30
@papaIOprog papaIOprog marked this pull request as ready for review January 10, 2024 15:48
@papaIOprog papaIOprog marked this pull request as draft January 10, 2024 21:44
@papaIOprog
Copy link
Contributor Author

I think I created the changeset incorrectly. I'm going to fix this.

@papaIOprog papaIOprog marked this pull request as ready for review January 10, 2024 21:55
@papaIOprog
Copy link
Contributor Author

Also, can you add tests please? 😊

Did you mean to add tests for these methods?

@curquiza
Copy link
Member

Did you mean to add tests for these methods?

Yes please, sorry maybe we already have and you did not have to change them
I'm not an expert in this repo, trying to do my best with the review 😊

@papaIOprog
Copy link
Contributor Author

Did you mean to add tests for these methods?

Yes please, sorry maybe we already have and you did not have to change them I'm not an expert in this repo, trying to do my best with the review 😊

I checked the repository and there are tests for these methods, but I'll add one corner case soon.

@papaIOprog
Copy link
Contributor Author

Here are links to tests that already exist.

For splitSortString:

For splitNumericFilter:

@papaIOprog
Copy link
Contributor Author

@curquiza I added 1 test that checks the case when an unusual sorting rule (_geoPoint, for example) is not in the first place in the list.

@papaIOprog
Copy link
Contributor Author

@curquiza Hi! I just want to check if everything is ok. Do I need to do anything else?

@curquiza
Copy link
Member

curquiza commented Jan 17, 2024

Sorry @papaIOprog for the delay, working on a lot of things at the same time

@flevi29 if you are around, I would love to have your opinion on this one before reviewing or merging 🙏

@brunoocasali and I (meili maintainers for all the integrations like this one) are not JS expert at all

@flevi29
Copy link
Collaborator

flevi29 commented Jan 17, 2024

I'm pretty sure Babel should be transforming this stuff. Babel is misconfigured.

{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}

It's targeting ... just node? Even at that current? That's at minimum ES2022. In my opinion it should be targeting the last 2 versions of the more popular browsers (Chrome, Firefox, Edge, Safari) (but my opinion might not be the most educated, see browserlists), but since meilisearch-js at the current moment targets IE11, let's just do that. It looks like this:
https://github.com/meilisearch/meilisearch-js/blob/177947ddaf5b9363152cb3a139b0d4572d7b5ab6/rollup.config.js#L46-L60

@papaIOprog Can you please fiddle with Babel, maybe even update the version that's used, and see if that transforms the RegExp properly? We shouldn't write code for older browsers, we should transform/transpile it for them.

This is not to say that the other changes are bad, I might've not considered every possible combination when I wrote that.

@papaIOprog
Copy link
Contributor Author

@flevi29 Hello! I can test this, but I found that Babel members said that it cannot be polyfilled.
babel/babel#11086 (comment)
babel/babel#10699 (comment)

@flevi29
Copy link
Collaborator

flevi29 commented Jan 18, 2024

Oh, okay, that's unfortunate. Then I don't have any objections to this PR.

@flevi29
Copy link
Collaborator

flevi29 commented Jan 18, 2024

It would be nice if Babel at least could warn you about unsupported features, but I can't even find any real discussion about it.
https://stackoverflow.com/questions/76135819/babeljs-does-not-warn-for-unsupported-regex-syntax-with-older-safari-version

We'll just have to wait for people to report these issues :\ .

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @papaIOprog and @flevi29 for your work on this! Really apprecidated

bors merge

@meili-bors meili-bors bot merged commit efb57ec into meilisearch:main Jan 22, 2024
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
Development

Successfully merging this pull request may close these issues.

Sarafi webkit: SyntaxError: Invalid regular expression: invalid group specifier name (js-regexp-lookbehind)
3 participants