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

fix: restore missing exports declarations #3892

Merged
merged 13 commits into from
Jul 28, 2022

Conversation

DamianOsipiuk
Copy link
Contributor

Closes: #3882

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 21, 2022

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 4d6e410:

Sandbox Source
@tanstack/query-example-react-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration

@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2022

Codecov Report

Merging #3892 (e0d5394) into main (eab6e2c) will increase coverage by 0.41%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #3892      +/-   ##
==========================================
+ Coverage   96.36%   96.77%   +0.41%     
==========================================
  Files          45       57      +12     
  Lines        2281     2668     +387     
  Branches      640      784     +144     
==========================================
+ Hits         2198     2582     +384     
- Misses         80       84       +4     
+ Partials        3        2       -1     
Impacted Files Coverage Δ
src/react/useInfiniteQuery.ts
src/core/subscribable.ts
src/react/QueryClientProvider.tsx
src/core/queryCache.ts
src/react/logger.ts
...rc/createWebStoragePersistor-experimental/index.ts
src/react/setBatchUpdatesFn.ts
src/core/utils.ts
src/devtools/useLocalStorage.ts
src/core/onlineManager.ts
... and 92 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c44e53...e0d5394. Read the comment docs.

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 21, 2022

Thanks. Are you sure that this is all we need? According to @sachinraja, there is more work to be done to be fully ESM compliant - e.g. to use the .mjs extension. That's why I've created this issue:

We've also had some problems with useSyncExternalStore and react-native, so I'd rather not rush this issue. Also not sure how we can properly test this with various bundlers before we release 🤔

I would also really like to get the feature back that allowed us to import the devtools in production via a separate entry point

@DamianOsipiuk DamianOsipiuk changed the title fix: restore missing exports declarations WIP: fix: restore missing exports declarations Jul 21, 2022
@DamianOsipiuk
Copy link
Contributor Author

@TkDodo Yup, marked as WIP for now as there are still more things to be moved/refactored.

@DamianOsipiuk
Copy link
Contributor Author

DamianOsipiuk commented Jul 21, 2022

@TkDodo @tannerlinsley So most of the things are covered by this PR to restore EMS compliant exports.

The only thing left is this (#3521):

Types are now emitted into lib instead of a separate types directory. This will help support TypeScript, which will add support for "exports" in the next release.

I'm not entirely sure why some packages are build to cjs with subdirectories, while others are not.
I assume that packages depending on other packages from monorepo have that behavior.
However it's kind of weird that react-query/build/cjs has also query-core build copy.
Is that something to be expected?

Can we remove preserveModules from cjs build?

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

somehow, codesandbox shows that types can't be picked up anymore:
Screenshot 2022-07-26 at 07 19 03

see this preview sandbox: https://codesandbox.io/s/tanstack-query-example-react-basic-typescript-ssd0yy?file=/src/index.tsx

packages/react-query/package.json Show resolved Hide resolved
"default": "./build/lib/index.js"
},
"./package.json": "./package.json"
},
"files": [
"build/*",
Copy link
Collaborator

Choose a reason for hiding this comment

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

the build directory contains things that we probably shouldn't ship, like stats.html etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Picked more granular paths. But this could still change if i find a way to bundle types into lib properly

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 26, 2022

@sachinraja please have a look at this PR if you find the time :)

@DamianOsipiuk DamianOsipiuk changed the title WIP: fix: restore missing exports declarations fix: restore missing exports declarations Jul 26, 2022
@TkDodo TkDodo merged commit 2af9174 into TanStack:beta Jul 28, 2022
TkDodo added a commit that referenced this pull request Sep 10, 2022
* fix: restore missing `exports` declarations (#3892)

* fix: restore missing `exports` declarations

* fix: restore package.json exports[C

* fix: reexport types used by vue-query

* fix: react-native uSES usage

* fix: emit mjs for esm

* fix: uSES build

* fix: devtools exports to allow devtools in prod

* fix: cjs and esm build bundled to lib dir

* fix: sideEffect in react-query, better files paths

* fix: generate declarations to lib

* fix: lint and tests

* fix: use the same ts build method for tests

* fix: change force prod import

* fix: subpackage dependencies (#4013)

* fix: umd-build (#3924)

* - Fix UMD build getting overwritten
- Updating "browser" field for @tanstack/react-query-devtools

* Updating the "browser" field to be the same as "main"

* release: v4.0.11-beta.0

* release: v4.0.11-beta.1

* fix(react-query-devtools): cjs devtools fallback (#4048)

* release: v4.0.11-beta.2

* fix: remove browser entry, fix umd size (#4044)

* fix: remove browser entry, fix umd size

* fix: bundle query-core with react-query for umd

* fix: remove missed browser entry

* chore: remove 'browser' field from package validation

because it doesn't exist anymore

* release: v4.0.11-beta.3

* release: v4.0.11-beta.4

* chore: react-query should be a peerDependency of the devtools

* release: v4.0.11-beta.5

* release: v4.3.0-beta.0

* fix: webpack 4 fallback to cjs (#4069)

* fix: publish script shouldn't check against module anymore

* fix: publish script

I don't think we can have single quotes in commit message when passing them to --notes

* release: v4.3.0-beta.2

* release: v4.3.0-beta.3

* fix: umd build size, force prod devtools (#4074)

* fix: umd build size

* fix: devtools force production

* release: v4.3.0-beta.4

* release: v4.3.0-beta.5

* fix: reintroduce production export (#4090)

* release: v4.3.0-beta.6

* fix(react-query-devtools): always useEffect for the mounted check

no effect runs on the server, and there is no real advantage to useLayoutEffect on the client; somehow, this dynamic check creates problems with the production build of the devtools

* release: v4.3.0-beta.7

* docs: document devtools in production

* docs: document devtools in production

* docs: document devtools in production

nodenext needs 4.7

* fix: support react-native (#4125)

* fix: support react-native

* chore: remove banner from build

Co-authored-by: Damian Osipiuk <osipiukd+git@gmail.com>
Co-authored-by: John Daly <john.daly2@gmail.com>
Co-authored-by: Tanner Linsley <tannerlinsley@users.noreply.github.com>
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.

ESM support
3 participants