-
Notifications
You must be signed in to change notification settings - Fork 522
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
fix: yarn notifier
#149
fix: yarn notifier
#149
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/solana-labs/governance-ui/7Jt7NPr9CnanVQMmfDdUEWZaY1LZ |
It's better here, I think store is inherently related to UI and connection is more basic concept Thank you for all that cleanup work, the project needs it !!! |
was able to be simplified after solana-labs#149 was merged
was able to be simplified after solana-labs#149 was merged
was able to be simplified after solana-labs#149 was merged
was able to be simplified after solana-labs#149 was merged
was able to be simplified after solana-labs#149 was merged
was able to be simplified after solana-labs#149 was merged
* remove unused testUtils * update jest, rename .babelrc to babel.config.js renaming babel config is required for jest to be able to transform es6 libs (like solana/wallet-adapter-phantom) https://stackoverflow.com/a/54656593 * test: update jest to handle tsconfig baseUrl/paths settings * test: set jest testEnvironment to jsdom (rather than node) * test: let `babel-jest` handle js(x) as well as ts(x) files * test: add simple test to verify test settings * test: simplify jest/babel setup was able to be simplified after #149 was merged * test: faster tests with swc/jest vs babel-jest * test: use `next/jest` - remove manual file mocks as they're handled by next/jest - create test/setup.js file - remove target config https://nextjs.org/docs/messages/deprecated-target-config * test: test homepage redirects
was able to be simplified after solana-labs#149 was merged
Problem
yarn notifier
was unable to run for me locally.issue 1 - tsconfig baseUrl/paths
I was getting an error that it cannot find module
stores/useWalletStore
![Screenshot 2021-12-17 at 7 19 03 PM](https://user-images.githubusercontent.com/601961/146596711-b9404222-d04c-470f-b1e6-53cdf26aab3a.png)
I fixed this by adding `tsconfig-paths` into the tsconfig"ts-node": { + "require": ["tsconfig-paths/register"], "compilerOptions": { "module": "commonjs" } }
I also removed
tsconfig.commonjs.json
and merged it into thets-node
field intsconfig.json
issue 2 - unexpected token '<'
After fixing the paths I got new errors because there is JSX in the one of the imports used by the notifier
I added
react-jsx
so that the JSX would be compiled rather than preserved. I didn't love this solution because I don't think there should be JSX loaded in a headless script that's called from node."compilerOptions": { + "jsx": "react-jsx", "module": "commonjs" }
issue 3 -
@solana/wallet-adapter-phantom
is not cjsThe next error was because
@solana/wallet-adapter-phantom
is only exported as esmodulesI went down various rabbitholes trying to fix this (type: module in package.json, babel presets, swc, esbuild)
Solution 🎉
By far the simplest approach was to move
ConnectionContext
andgetConnectionContext
into their own file, this way the notifier script doesn't import any JSX or the esm@solana/wallet-adapter-phantom
code.utils/connection.ts
is the best place for this file, or if it would be better to leave it in the store file and move the JSX and wallet-adapter code out of the store file instead?But this works for now and fixes the immediate problem.
Finally
I also upgraded all
eslint*
dependencies because I got a warning fromyarn test-all
but I can revert that commit if it's problematic.