Skip to content

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Sep 25, 2025

Motivation

While we can technically continue to import modules from AgentJS using the legacy libraries - inherited as peer dependencies of @icp-sdk/core - we want to fully migrate to the new subentry-paths library. That is why this PR adapts all imports. Basically a search and replace.

Notes

This PR does not migrate the imports in the DID files and the scripts that generates those. This will be resolve separately and partially - for the huge part - automatically.

Changes

  • Search @dfinity/agent and replace by @icp-sdk/core/agent
  • Search @dfinity/identity and replace by @icp-sdk/core/identity
  • Search @dfinity/candid and replace by @icp-sdk/core/candid
  • Search @dfinity/principal and replace by @icp-sdk/core/principal

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Copy link
Contributor

github-actions bot commented Sep 25, 2025

size-limit report 📦

Path Size
@dfinity/ckbtc 8.15 KB (0%)
@dfinity/cketh 3.7 KB (0%)
@dfinity/cmc 1.42 KB (0%)
@dfinity/ledger-icrc 4.7 KB (+0.23% 🔺)
@dfinity/ledger-icp 7.13 KB (+0.14% 🔺)
@dfinity/nns 27.69 KB (+0.05% 🔺)
@dfinity/nns-proto 140.99 KB (0%)
@dfinity/sns 19.59 KB (0%)
@dfinity/utils 5.11 KB (+0.08% 🔺)
@dfinity/zod-schemas 628 B (+0.81% 🔺)
@dfinity/ic-management 4.42 KB (+0.25% 🔺)

peterpeterparker and others added 14 commits September 25, 2025 08:20
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
peterpeterparker added a commit that referenced this pull request Oct 15, 2025
# Motivation

Migrating to the `@icp-sdk` (#1044) requires importing modules (agent,
identity etc.) from sub-entries - e.g. `@icp-sdk/core/agent` instead of
`@dfinity/agent`.

Our current `moduleResolution: node` set in `tsconfig.json` cannot
resolve those kind of path. Without any changes, it leads to issue at
build time like:

> src/utils/governance.utils.ts:7:32 - error TS2307: Cannot find module
'@icp-sdk/core/principal' or its corresponding type declarations.
> There are types at
'/Users/daviddalbusco/projects/dfinity/ic-js/node_modules/@icp-sdk/core/lib/esm/principal/index.d.ts',
but this result could not be resolved under your current
'moduleResolution' setting. Consider updating to 'node16', 'nodenext',
or 'bundler'.

That is why we are switching to a more modern [module
resolution](https://www.typescriptlang.org/tsconfig/#moduleResolution)
approach, `bundler`.

# Notes

We switch to `bundler` because we are generating JS with a tool -
esbuild - and not TSC itself.

# Changes

- Set `moduleResolution: bundler`.

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
peterpeterparker added a commit that referenced this pull request Oct 15, 2025
# Motivation

We want to migrate agent-js to `@icp-sdk/core`. Since this library
currently re-export all underlying libraries - e.g. `@dfinity/agent` and
`@dfinity/principal` - we are using, in this first step we can solely
switch the dependencies.

# Temporary "Workaround"

Without migrating all imports to their corresponding sub-paths (will be
resolved in #1044), the generate bundles end including the code of the
agent which per extension lead the library to become more heavy. As
temporary workaroung, we add an explicit exclude in the bundler script
which we can remove afterwards.

# Notes

Announcement:
https://forum.dfinity.org/t/icp-javascript-sdk-v4-0-0-is-released/55915

# Changes

- Update helper script that handles lib upgrades.
- Replace `@dfinity/*` peer dependencies by `@icp-sdk/core`.
- Exclude `@icp-sdk/core` from `size-limit` checker (similarly to the
`@dfinity/...` libs).
- Temporary manually list `@dfinity/...` as peer dependencies for the
build (see workaround above).

---------

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
@peterpeterparker peterpeterparker changed the title feat: migrate agent-js to icp-sdk feat(core): migrate agent-js to icp-sdk Oct 15, 2025
@peterpeterparker peterpeterparker marked this pull request as ready for review October 15, 2025 14:13
@peterpeterparker peterpeterparker requested review from a team as code owners October 15, 2025 14:13
@peterpeterparker peterpeterparker merged commit 15213eb into main Oct 15, 2025
17 checks passed
@peterpeterparker peterpeterparker deleted the feat/migrate-icp-sdk branch October 15, 2025 15:02
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.

2 participants