Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fixes to the nextjs project for snarkyjs + typescript #287

Merged
merged 5 commits into from
Oct 27, 2022

Conversation

es92
Copy link
Contributor

@es92 es92 commented Oct 27, 2022

No description provided.

src/lib/project.js Show resolved Hide resolved
src/lib/project.js Show resolved Hide resolved
src/lib/project.js Show resolved Hide resolved
src/lib/project.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@ymekuria ymekuria left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

webpack(config) {
config.resolve.alias = {
...config.resolve.alias,
snarkyjs: require('path').resolve('./node_modules/snarkyjs'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why this is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures that the smart contract's snarkyjs and the ui's snarkyjs are the same - otherwise they get imported multiple times. See here for more, in the context of fixing this for duplicate instances of react

Copy link
Collaborator

@ymekuria ymekuria Oct 27, 2022

Choose a reason for hiding this comment

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

Peer dependancies appeared to fix this issue for contracts imported via npm but not via npm link.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks @es92 this link is a nice resource! another potential trick with npm link is mentioned here (at the bottom): https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react

src/lib/project.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jasongitmail jasongitmail left a comment

Choose a reason for hiding this comment

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

LGTM

@jasongitmail jasongitmail merged commit ddd1e7f into main Oct 27, 2022
@jasongitmail jasongitmail deleted the nextjs-project-fixes branch October 27, 2022 23:10
ymekuria pushed a commit that referenced this pull request Oct 28, 2022
* add fixes to the nextjs project for snarkyjs + typescript

* disable react strict mode in nextjs to prevent double loading useEffects

* fix some thigns per comments

* add ts-watch command to package.json

* update script per comments

Co-authored-by: Evan Shapiro <[email protected]>
ymekuria added a commit that referenced this pull request Nov 3, 2022
* feat: add snarkyjs resolve alias nextconfig

* feat: read ui current index file

* feat: add index file extension from user selection

* feat: add ui index template file

* add ui newindex template

* feat: import contract in template

* feat: add snarkyjs to ui index

* feat: add contract to local ui state

* refactor: remove webpack config

* feat: add SnarkyJS to the ui project package.json dependencies

* fix: use path.join when updating package.json

* fix: use path.join when updating package.json in 2nd place

* add fixes to the nextjs project for snarkyjs + typescript (#287)

* add fixes to the nextjs project for snarkyjs + typescript

* disable react strict mode in nextjs to prevent double loading useEffects

* fix some thigns per comments

* add ts-watch command to package.json

* update script per comments

Co-authored-by: Evan Shapiro <[email protected]>

* fix: add head import to index template

* feat: build template contract to include in ui scaffold

* update: invoke import async function

* feat: create a contract instance in template

* refactor: add commont for strict mode nextjs config option

* refactor: add jsx extension to next index file

* refactor: rename next index file

* fix: remove redundant code

* refactor: remove local state and update comments in ui template

* feat: add snarkyjs resolve alias nextconfig

* feat: read ui current index file

* feat: add index file extension from user selection

* feat: import contract in template

* refactor: remove webpack config

* refactor: add custom index to scaffold before ghp config

* fix: remove duplicate code

* update: change template zkapp address

* update: change deployed example contract public key

* feat: show console message to add a zkapp public key

* feat: change emtpy zkapp address error message

* fix: NextJs config snarkyjs require path for Windows

Co-authored-by: Jason <[email protected]>
Co-authored-by: Evan <[email protected]>
Co-authored-by: Evan Shapiro <[email protected]>
Co-authored-by: Martin Minkov <[email protected]>
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.

4 participants