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 yarn workspaces, update configuration #1

Merged
merged 2 commits into from
Dec 15, 2021

Conversation

alexeagleson
Copy link
Contributor

Instructions for running scripts in the README

@@ -0,0 +1,17 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Launch.json for VSCode for launching the app in debugging mode. You can configure which script you want debugging mode to launch with the "command" value (currently set to yarn dev). Breakpoints and call stack will be available in VSCode when running with this launch config

@@ -1,6 +1,6 @@
{
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 tells Lerna that we are using yarn to manage the project, and that we are using yarn workspaces. Lerna has first class support for workspaces.

@@ -1,8 +1,12 @@
{
"name": "root",
"private": true,
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 is a pattern that tells yarn which folder we are using for workspaces. When you run yarn install in the root it will check the package.json files of each of these workspaces and install the shared modules in the root directory

"scripts": {
"dev": "lerna run dev",
"dev": "lerna run --parallel dev",
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 dev script will run the "dev" scripts for each package (so both Next apps, as well as the new rollup --watch mode for the component library.)

There is also a script to run without the rollup watch since it does require a fair bit of memory and increase hot reload times. using storybook to work on the components is a preferable option

@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@bnayae/wk-lib-playground": "^1.0.45",
"@weknow-network/wk-lib-playground": "^1.0.45",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All references in the project are scoped to this @weknow-network so I updated them from bnayae

This is controlled by the "name" field in the package.json files if you ever need to change it

"core": {
"builder": "webpack5"
}
"framework": "@storybook/react"
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 is what was causing the error and storybook not to build. Unfortunately I don't have the precise reason why. This project is the first time I've ever used storybook in a monorepo, I think it has something to do with issues related to webpack 4 vs 5 when everything is hoisted into a single node modules directory. either way with this removed it works now. if you want to read more this is where I got most of my info:

storybookjs/storybook#5949

"pure": false,
"namespace": "lib-playground"
}]
plugins: [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

each plugin itself needs to be an array (so array inside array)

@@ -18,9 +19,7 @@
"author": "bnaya eshet",
"license": "MIT",
"types": "dist/index.d.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Evidently consumers are looking for types with the "typings" field in package.json. Might be that types is not necessary (I may have to update my blog entry) 😄

@@ -75,7 +74,8 @@
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react-dom": "^17.0.2",
"styled-components": "^5.3.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

styled-components should be a peerDependency in your library like react and react-dom (to indicate to consumer libraries that it needs to be installed, but so that you don't have to package the entire styled-components project in your custom library)

tsconfig.json Outdated
"@weknow-network/wk-lib-playground": ["wk-lib-playground/src"],
"@weknow-network/*": ["*/src"]
}
"baseUrl": "./packages"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not believe paths are not necessary to define in tsconfig here. However if you are looking to consume your components directly from your library workspace ( rather than the dist that contains the compiled library), this might be a way to approach it.

@alexeagleson
Copy link
Contributor Author

I've added some comments with each change explaining the reason for it, hopefully that helps!

@alexeagleson
Copy link
Contributor Author

Updated with the paths back in the tsconfig

@bnayae bnayae merged commit fe9db6b into weknow-network:main Dec 15, 2021
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.

None yet

2 participants