Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings

Hi,

I got on browser console the message bellow:

Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings.
See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions

After searching around this message, I tried it from a dfx new project

I realized that the message also appears so I tried to open the same url using other browsers and the message does not appear.

In conclusion this message appears with the Brave browser but not with Firefox and Chromium (using linux) ???

it comforts me a little that it’s not necessarily related to my code but it’s a strange behavior

I usually use dfx deploy

But I also deleted .dfx ./src/declarations ./dist and rebuilt step by step without change.

Check that your imports are not from .dfx folder, but the src/declarations folder. The declarations folder is created using dfx generate

Thanks for the answer,

In my code I checked that I had not made this error. Moreover, I came back to the base from a project generated with dfx new without modification so I did not introduce any error and finally this log line appears only if I use Brave

I also uninstalled dfx then reinstalled and not just did an upgrade I delete the caches directories auto generated.

What DFX version are you running?

I am using 0.12.1, I did some more tests.

It seems that this problem happens only with a javascript version and not with typescript. This message comes from the createActor function. The order of the build steps influences the problem; using dfx deploy generating this error.

The message is not clear because it suggests that the developer made a faulty import. When this depends on the build process order.

Browsers have nothing to do with the issue. My new tests were done on a new installed machine.

It maybe has to do with the new npm run generate target and the way the declarations files are generated. Maybe have a look to a fresh sample repo and compare the script in package.json, then generate the declarations. Not 100%, just a feeling.

cc @NathanosDev who work on this generate command, just in case

I’m unable to reproduce this, so I would also encourage checking out a fresh repo, or perhaps sharing a repo that can reproduce the issue, then it would be easier for someone to identify the issue.

Hello,

The repo is

The file with the source code is:

Your NPM scripts are out of date: package.json · main · ʕʘ̅͜ʘ̅ʔ / dfx_skeleton · GitLab
You can check the expected approach for the latest version of DFX here: sdk/package.json at master · dfinity/sdk · GitHub

2 Likes

Hi!
Yes :+1: I thought I had done the updates… :flushed:
Everything is working fine

Thank you