junobuild / juno-js

JavaScript libraries for interfacing with Juno
MIT License
13 stars 1 forks source link

What is the difference between @junobuild/core and @junobuild/core-peer #155

Closed CodingFu closed 4 weeks ago

CodingFu commented 1 month ago

Hello

I have a question:

what is the difference between

https://www.npmjs.com/package/@junobuild/core

and

https://www.npmjs.com/package/@junobuild/core-peer

peterpeterparker commented 1 month ago

Hi @CodingFu,

Feature-wise, both @junobuild/core and @junobuild/core-peer are identical. In fact, the code of the first is copied into the second at build time.

Originally and in the future, I want to support only @junobuild/core, which pre-packages everything needed by the client.

Unfortunately, because the Agent-js libraries require some NodeJS polyfills, I started noticing issues with certain bundlers and frameworks, for example, SvelteKit. For some reason, even though everything is pre-polyfilled in the core, the library started to face issues with unresolved NodeJS APIs such as Buffer and other components. Despite trying hard to find a solution, I ultimately figured out that there was no way to embed Agent-js for those types of projects. The only solution was to ship the library with everything @dfinity/agent|client|etc. set as peer dependencies. That's why the core-peer library was added to the stack.

Note that it is not directly documented which library should be used with what type of bundler and framework, but all the guides in the documentation and templates of the create CLI are using the appropriate library type.

Let me know if you have more questions on that matter.

peterpeterparker commented 4 weeks ago

I gonna close this question but, if anthing is unclear or requires to be documented in the documentation please let me know @CodingFu. Happy to reopen the issue if useful.