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

[Client] Critical dependency error #208

Closed
kyranjamie opened this issue Aug 27, 2020 · 7 comments
Closed

[Client] Critical dependency error #208

kyranjamie opened this issue Aug 27, 2020 · 7 comments
Labels

Comments

@kyranjamie
Copy link
Contributor

Describe the bug

Browser bundle emits the following error, when importing and using the client

../stacks-blockchain-api/client/node_modules/jsonrpc-lite/jsonrpc.js 16:24-31
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

See this PR, which references the same issue: teambition/jsonrpc-lite#17

Supposedly it's fixed in that PR, but hasn't been spoken of in 12 months.

@zone117x
Copy link
Member

We may need to fork, merge that PR and publish an updated package. Or inline the code we use from it.

@zensh
Copy link

zensh commented Aug 28, 2020

https://github.com/teambition/jsonrpc-lite/blob/master/jsonrpc.js#L16
the jsonrpc.js is generated by tsc with optionmodule=UMD, and require function do not need by jsonrpc.

could you close the warning message in webpack?

@kyranjamie
Copy link
Contributor Author

@zensh I tried setting the stats property to none and errors-only, but that doesn't remove the error.

Can the issue be fixed in the jsonrpc package by bundling it differently, or perhaps merging the PR with the fix?

@zensh
Copy link

zensh commented Sep 1, 2020

@kyranjamie change the code https://github.com/teambition/jsonrpc-lite/blob/master/jsonrpc.js#L16 to

var v = factory(null, exports);

will work?

@zone117x
Copy link
Member

zone117x commented Sep 1, 2020

@zensh The library should be bundled in a more friendly way. UMD format for package.js main field is problematic. Typically libraries should use a cjs file output for main, and use a esm file output for the module field. UMD is useful for CDNs like unpkg which have their own package.json field.

Something like a package.json with:

{
  "main": "dist/lib.cjs.js",
  "module": "dist/lib.esm.js",
  "unpkg": "dist/lib.umd.js",
}

Would it be helpful if I made a PR for this? It shouldn't require as many changes as the existing PR.

@zensh
Copy link

zensh commented Sep 2, 2020

v2.2.0 released, https://github.com/teambition/jsonrpc-lite/blob/master/package.json#L8

kyranjamie added a commit that referenced this issue Sep 2, 2020
blockstack-devops pushed a commit that referenced this issue Sep 2, 2020
# [0.12.0](v0.11.3...v0.12.0) (2020-09-02)

### Features

* update jsonrc package—thanks [@zensh](https://github.com/zensh), closes [#208](#208) ([86b575d](86b575d))
@blockstack-devops
Copy link

🎉 This issue has been resolved in version 0.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants