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

feat(types): allow typed access to properties added to entry #4814

Merged
merged 2 commits into from
Aug 5, 2021

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jul 20, 2021

Summary

The helpers in the esm entry file were attached to the "prototype" of instantsearch instead of exported, which makes them non-treeshakeable. Removing it now would be a breaking change, but that form can at least already be encouraged.

Result

  • move the code in main.ts to index.ts for consistency with esm entry file
  • deprecate things attached to index.es.ts (for /helpers Overhaul import strategy #4749)

@Haroenv Haroenv requested review from eunjae-lee, a team and tkrugg and removed request for a team July 20, 2021 07:29
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 20, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3517505:

Sandbox Source
InstantSearch.js Configuration

Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

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

This is so much better!

src/index.es.ts Outdated Show resolved Hide resolved
src/index.es.ts Outdated Show resolved Hide resolved
src/index.es.ts Outdated Show resolved Hide resolved
src/index.es.ts Outdated Show resolved Hide resolved
src/__tests__/index-test.ts Outdated Show resolved Hide resolved
src/index.es.ts Show resolved Hide resolved
src/lib/utils/logger.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.es.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@Haroenv Haroenv changed the title feat(main): export helpers from esm feat(main): remove helpers from esm entry point Jul 30, 2021
@Haroenv Haroenv changed the title feat(main): remove helpers from esm entry point feat(main): deprecate helpers from esm entry point Jul 30, 2021
version: string;

// @major remove these in favour of the exports
/** @deprecated */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@francoischalifour suggested not deprecating these yet, as we aren't sure where the export should best be from. At the moment it's /es/helpers, but that could change?

Personally I'm more of the opinion to deprecate them with /es/helpers as a workaround, still leaving the option open for a more thorough review of what's exported where in a major version

wdyt @tkrugg / @shortcuts

Copy link
Member

Choose a reason for hiding this comment

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

As long as we have clear warnings etc., I don't see any issue deprecating them

also removes the file for "main" as it's inconsistent with index.es.ts
@Haroenv Haroenv changed the title feat(main): deprecate helpers from esm entry point feat(types): allow typed access to properties added to entry Aug 4, 2021
@Haroenv Haroenv requested a review from shortcuts August 5, 2021 07:34
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

Really nice!

version: string;

// @major remove these in favour of the exports
/** @deprecated */
Copy link
Member

Choose a reason for hiding this comment

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

As long as we have clear warnings etc., I don't see any issue deprecating them

@francoischalifour
Copy link
Member

The thing is we'll likely update/clean our exports during the React InstantSearch migration, so I'm not sure that's the right time for this change (also definitely an improvement) because it will make it harder to not introduce breaking changes.

@Haroenv
Copy link
Contributor Author

Haroenv commented Aug 5, 2021

Changing exports is always a breaking change @francoischalifour, right? I know for sure that we don't want to continue exposing the helpers as a property on the es entry point (it's not documented), the deprecation message mentions /es/helpers, as I don't think it's useful to discourage use without explaining what a right way of using it is.

This PR mainly focuses on having the right types for something that already is the case, whether it's typed or not, removing those entries is a breaking change :)

@francoischalifour
Copy link
Member

Sorry I got confused and forgot that the PR changed from updating the exports to only updating typings—all good then!

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.

4 participants