How to test local changes on polkadot.js - Manta-Network/Manta GitHub Wiki
This is aimed for TypeScript/JavaScript newbies, so they don't lose too much time figuring out the development process if they need to submit a PR to one of the repositories of Polkadot.JS
Let's take the example of changing some code in their common repo and integrating it in the extension project
-
Clone both repos and run
yarnandyanr buildto make sure their latest commits actually compile. -
Now make some changes in
commonand it is time to integrate this local version of the module intoextensionThere is a command that is supposed to do just that for us
yarn polkadot-dev-copy-to extensionhowever this command will overwrite all files in our localextension/node-modules/@polkadotdirectory. This includes all the.d.tsfiles that were there, which in turn will not allow us to compile.As a workaround we can write a simple script to build our
commonrepo which generates somejsandcjsfiles. Then copies those files to theextensionrepo without overwriting the.d.tsthere. And finally builds the extension repo itself.For this example consider that we have modified the following file
# Go in the common repo
cd path/to/common/
# Build common repo
yarn build
# Copy all necessary files to extension folders, js and cjs files.
cp \
path/to/common/node_modules/@polkadot/networks/build/index.js \
path/to/extension/node_modules/@polkadot/networks/index.js
cp \
path/to/common/node_modules/@polkadot/networks/build/index.cjs \
path/to/extension/node_modules/@polkadot/networks/index.cjs
# Go to extension repo folder
cd path/to/extension
# Build extension project.
yarn build
-
Install the extension to your browser.
Please follow this very short guide.
-
Keep adding files to the script in section 2.
As you keep working on different
tsfiles in thecommonrepo you will need to include their corresponding.jsand.cjsfiles to the script so they can be copied over accordingly. -
Hopefully soon we will figure out how the Polkadot.JS team does this internally but until then you can iterate sort of fast with this method.
-
Happy coding!