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

apollo-cache-inmemory: the new release seems to break the build #4332

Closed
surbina opened this issue Jan 18, 2019 · 3 comments · Fixed by #4334
Closed

apollo-cache-inmemory: the new release seems to break the build #4332

surbina opened this issue Jan 18, 2019 · 3 comments · Fixed by #4334
Assignees

Comments

@surbina
Copy link

surbina commented Jan 18, 2019

Intended outcome:
Installing apollo-cache-inmemory and using it in a project should work without problems.

Actual outcome:
Installing apollo-cache-inmemory and using it in a project breaks and shows the following error:
Module not found: Error: Can't resolve 'tslib'

It seems that the compiled version of apollo-cache-inmemory includes an import of tslib. But tslib does not appear in the apollo-cache-inmemory dependencies.

screen shot 2019-01-18 at 5 31 18 pm

How to reproduce the issue:
Install apollo-cache-inmemory in a project where you are not using TypeScript and build the project using Webpack.

Versions
System:
OS: macOS High Sierra 10.13.6
Binaries:
Node: 8.5.0 - ~/.nvm/versions/node/v8.5.0/bin/node
Yarn: 1.6.0 - ~/.nvm/versions/node/v8.5.0/bin/yarn
npm: 5.8.0 - ~/.nvm/versions/node/v8.5.0/bin/npm
Browsers:
Chrome: 71.0.3578.98
Firefox: 60.0
Safari: 12.0.2

@benjamn benjamn self-assigned this Jan 18, 2019
@benjamn
Copy link
Member

benjamn commented Jan 18, 2019

Thanks for reporting this!

The idea was supposed to be that the client packages would import tslib from the root apollo-client project directory, and Rollup would inline the imports at build time, so there would be no runtime import from tslib. This was important to make sure we only imported the tslib helpers that we actually used, instead of depending on the whole library.

Not sure yet why that isn't working as intended, but I will find out!

benjamn added a commit that referenced this issue Jan 18, 2019
948706f

The commit linked above attempted to inline tslib helpers into our UMD
bundles, but accidentally left actual tslib imports in the ESM files
exposed through the `module` field in `package.json`, without installing
tslib as a dependency.

Since we're not currently bundling all of our ESM modules together into
one bundle, inlining the helpers doesn't make sense, because they would be
inlined at the top of every module where they were used, instead of being
shared across all modules. However, importing tslib the normal way should
work just fine, and tree-shaking bundlers can take care of pruning the
unused helpers from the tslib package.

Should fix #4332.
@surbina
Copy link
Author

surbina commented Jan 18, 2019

Thanks a lot!

@vjpr
Copy link

vjpr commented Jan 18, 2019

apollo-client/2.4.10/node_modules/apollo-client/ApolloClient.js uses tslib but its not declared in the dependencies.

Should it be a peer dep?

This is not working with pnpm.


Ah I see its fixed. When will this be released?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants