Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

chore: change deno to node with pnpm #55

Merged
merged 42 commits into from
Jun 12, 2023
Merged

chore: change deno to node with pnpm #55

merged 42 commits into from
Jun 12, 2023

Conversation

peetzweg
Copy link
Collaborator

@peetzweg peetzweg commented Apr 20, 2023

Exchanges deno with traditional node tooling.

pnpm is a widely used supported package manager for node, which offers lean monorepo capabilities.

It ships with node>=16 and can be enable with corepack which is part of the node installation.

corepack enable

The pnpm-workspace.yaml defines the path to individual projects of the monorepo.

https://github.com/paritytech/useink/blob/5df27adcf0cc110965a097a77ca9acc04d50e8c3/pnpm-workspace.yaml#L1-L3

Each project can have it's own node setup. As of now we have useink/core and useink/chains under packages and playground contains the useink-kitchen-sink frontend.
Soon we should also add the docs to the repo as well. This way we have everything in a single repo and can create PRs which push changes to all related code in one PR.

Use pnpm install at the root to install all dependencies of defined monorepo projects.

pnpm install

I added some convenience scripts in the root package.json to build a the packages or to start a development environment running the "kitchen-sink" frontend.

https://github.com/paritytech/useink/blob/ac11bff016b4484f8aad71d5294a9e8dd16a8b89/package.json#L6-L9

Build packages:

pnpm build

Run development setup:

pnpm dev

The development setup runs the tsup tooling in watch mode and starts the kitchen sink nextjs setup in development mode for recompilation on file changes.


tsup is a popular choice for bundling ts libraries.
tsup docs


The setup was heavily inspired by the repo setup of wagmi. However, I have great experience using these tools in the past.

Why?

  • I struggled with compiling useink with deno in "watch" mode for speeding up development cycles

  • dnt (Deno Node Transform) was super slow for me and I don't want to invoke it manually all the time.

  • dnt states itself it's under early development and may not be suitable for production: This tool is under active early development and hasn't been tested in a lot of scenarios.

  • we are catering to the node world first and foremost. We are building a frontend library here, deno nor bun are not as widely used for this just yet. IMHO I don't find it worthwhile to drop all the existing mature tooling and struggling with comparability for {insert deno advantage here}. 🤷

@peetzweg
Copy link
Collaborator Author

Hey @DoubleOTheven, can you give this a try and see if this works for you.
Just updated this to your recent changes in kitchen sink and useink as well.

As mentioned in the PR description I think it has some key advantages over the current deno setup. Please let me know what you think, if we go with this monorepo node approach I will adapt the gh actions as well.

Copy link
Contributor

@DoubleOTheven DoubleOTheven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes. Let's get the new Chain config and Notification PRs in first, then update this PR.

@nicolad
Copy link

nicolad commented May 7, 2023

Amazing direction!
At current FT job I've implemented pnpm along turborepo to simplify overall build process:

https://turbo.build/repo

@peetzweg
Copy link
Collaborator Author

peetzweg commented May 8, 2023

Amazing direction! At current FT job I've implemented pnpm along turborepo to simplify overall build process:

https://turbo.build/repo

Yes that would be the next step. Not sure if turborepo or nx. I personally I'm a fan and user of nx but haven't tried turborepo in the last 8 months or so. We got it on our radar for further improvement of the development experience.

@nicolad
Copy link

nicolad commented May 17, 2023

heya 👋
what's the progress on this, I need this to ease my testing regarding to this issue:
#40

if there are any ways I can help with this, let me know

@DoubleOTheven
Copy link
Contributor

Version 1.1.0 has been released. Do you want to look into migrating to node based off of the latest main branch?

@peetzweg
Copy link
Collaborator Author

Yep will give it another go. 👍:)

@peetzweg peetzweg marked this pull request as draft May 30, 2023 13:49
@peetzweg peetzweg changed the title expr: pnpm monorepo feat: change tooling to pnpm monorepo May 30, 2023
@peetzweg peetzweg marked this pull request as ready for review May 30, 2023 14:44
@peetzweg
Copy link
Collaborator Author

peetzweg commented May 30, 2023

Just updated the code in this branch to the most recent useink version.

Fyi it does not have multiple packages as the original deno code doesn't. It's just multiple entry points in a single packages as the deno version did it.

So for this initial switch we only have two projects in this this monorepo workspace, packages/useink as it's working before and the useink-kitchen-sink as playground.

Please give it a try @DoubleOTheven if everything works as expected. Also happy to get some feedback from @nicolad and @felixpolimec (#46).

At best fresh copy of this branch then use pnpm i to install all dependencies and run the playground and bundling of the library with pnpm dev.

Haven't tested it myself as much yet. But one issues still open are these module version errors from pnpm. 🤔

@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
	esm 12.2.1	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/util/
	esm 12.2.1	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/util/
@polkadot/api-contract has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/api-contract/
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/api-contract/
@polkadot/types has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types/
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types/
@polkadot/types-create has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types-create/
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types-create/
@polkadot/types-codec has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types-codec/
	esm 10.7.3	node_modules/.pnpm/@[email protected]/node_modules/@polkadot/types-codec/

Copy link
Contributor

@DoubleOTheven DoubleOTheven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes all look good, but there are a lot of collisions with the main branch. Would you please resolve them and make this PR a single commit with chore: change Deno to node and pnpm (or something similar?)

I tried doing rebasing but there are too many changes. You might be better off converting mod.ts to index.ts as you did the first time.

@peetzweg peetzweg changed the title feat: change tooling to pnpm monorepo chore: change deno to node with pnpm Jun 8, 2023
@peetzweg
Copy link
Collaborator Author

peetzweg commented Jun 8, 2023

@DoubleOTheven

merged with main to resolve conflicts. Fixed lint and spellcheck actions. Had to fix some lint issues so lint ci will succeed. This commit includes the fixes: 071d27c

Release action should work as well 🤞

Copy link
Contributor

@DoubleOTheven DoubleOTheven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that these file changes are out of sync. useEventSubscription was changed to useEvents, but you added it in your commit

@DoubleOTheven DoubleOTheven merged commit 8c78768 into main Jun 12, 2023
@DoubleOTheven DoubleOTheven deleted the pnpm-monorepo branch June 12, 2023 15:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants