HackMD
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • More features Commenting, Suggest edit
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Options
    • Versions and GitHub Sync
    • Transfer ownership
    • Delete this note
    • Note settings
    • Template
    • Save as template
    • Insert from template
    • Export
    • Dropbox
    • Export to Google Drive
    • Gist
    • Import
    • Dropbox
    • Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Transfer ownership Delete this note
Export
Dropbox Export to Google Drive Gist
Import
Dropbox Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
More features Commenting, Suggest edit
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
More features
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Monorepo Roundup ## Steps to Make Libraries Publishable 1. If you're rebuilding, update your nx version to 15. 2. Ensure that you use the publishable tag properly when generating code for the library https://nx.dev/more-concepts/buildable-and-publishable-libraries 3. If the library is a base level dependency (meaning that it needs to generate all dependencies on install, use ``"buildableProjectDepsInPackageJsonType": "dependencies"`` in the project.json build options. I'm thinking that highlevel dependencies that may not have new deps on their own might be able to use ``peerDependencies`` if all their dependencies were already imported in the lower level libs. 4. If we're using css in our libraries make sure to use `extractCss: false` so that the build can inject the CSS directly into the document body. Our old plugins did this automatically for us. The new ones do not. ![](https://i.imgur.com/XN2RqIb.png) 5. For the rebuild team, it is absolutely essential that we keep things minimal. We can layer in our automation over time. Right now we need packages that ship. The root cause of our build problem still isn't 100% known (though I have some ideas). So it's important to build from the ground up and isolate things that could have been the problem as we build. 6. Test everything after every change. Keep a local app build and a external app that pulls from npm. ## Current Test Repo The current test repo is extremely minimal. - there's no versioning (I have to update locally when deploying to NPM). - There's no CI. - I ripped storybook out of UI. - TS is a little bit stricter - but it does allow module interop at the root level. - There's no more apps or libs. Everything exists in one folder called packages (how NX 15 works now). - There's no workspace.json. NX 15 doesn't generate a workspace JSON. Everyone should also read this. It's a breakdown of packaged based repos vs. integrated repos. We're using an integrated repo. https://nx.dev/concepts/integrated-vs-package-based ## Isolating Root Causes Even though I was able to get things working, I was unable to pinpoint the exact cause. This makes me feel a little uneasy, and I feel that in order to be able to use our monorepo well, we should isolate this. Here are some of the potential causes, listed in order of their likelyhood (based on my guess) of being the root cause. However, there's a lot of excess duct-tape in the existing monorepo that deviates far from the way that nx generates a project, so there could be a lot of other potential causes. 1) A combination of 2) and 3). 2) We just weren't using the --publishable tag properly. There's no way to audit this once the code is generated, so it's really hard to discern if that's the case. 3) We weren't building out our base repos to include all dependencies in the package JSON. Some were set to peerDeps (see UI), others it wasn't specified at all. I couldn't find any reasoning for these decisions, and IMO, the dependencies seem to be layered backwards (High level libs should be peerDeps, Low level should be deps). It's worth noting that I tested this earlier, and it still didn't work with switching this config around, which makes me think that this also has something to do with the --publishable tag 4) UMD exports. The new mono compiles to regular js. I'm not sure why we're compiling to umd in the old repo, if this is was by design or some quirk of an older version. 5) Vite stuff. There's no Vite code in the new repo. This could also be the cause. It's worth noting that the both Vite and regular nrwl/react plugins both use Rollup as a bunder, so my initial thinking around rollup being a cause is unlikely. 6) Other bloat. There's a lot of custom config to get libraries that we don't need up and running. There could be some base level config that I couldn't spot that's changing things around on us. ## Plans of attack ### Just rebuild, isolate root causes as we go. This would be an all-hands rebuild of the app. Some folks layer in old deps and test them out. Others build the CI and versioning system. We save everything that's not a TS library for last. Then, if we still haven't identified a reproducible root cause, we send one person to find that while the rest of the team goes back to regular development. Pros: - **Less things to patch together.** NX is very poorly documented and if something goes wrong, you'll be digging through potentially thousands of GH issued to get it working. For example, in order for to get CSS injected in the UI lib, I had to read every issue in their monorepo (open or closed) with the words ``css`` in it. This took at least six hours of reading. Eventually, I found an old issue from years ago where someone mentioned a potential solution that didn't work for them. This fix is necessary for anyone who is making a UI lib (React or otherwise) and importing raw CSS, in other words, anyone who wants to make a publishable component library. Imagine how difficult it would be find something else. - **NX 15.** NX is now using 15. V14 docs are gone and have fun using the wayback machine to try and read them. This can also be a con (see below) - **We know what's going on.** Just by the nature of building from the ground up and testing each change, we can isolate which part isn't working. This allows us to properly search for solutions or fixes. - **Better communication.** If we're all on one team, communicating regularly, there would likely be a faster momentum. - **Better understanding** Everyone gets their hands dirty and can see how this thing comes together. Smaller silo. - **Cleaner code/fresh start** We get to rethink a lot of our earlier decisions that we made early in our journer, when we didn't really know what we were doing. Also, we get to clean out a lot of the config that we don't need. For example, the new repo has one set of TS rules for all the libs and apps. Cons: - We might end up spending more time than we need. - We might lose tooling that we didn't need to cut (ex. Maybe Vite wasn't causing the problems after all) - We lose git history - All or most of the NX video tutorials are using NX 14, so we lose everything there. Its worth mentioning that at least currently, 15 is close enough to 14 at the plugin level (not at the high level) - Some of that duct tape may have been necessary. - Travis has to migrate all GH issues ### Red Team/Blue Team. Take what we've learned and apply it to both repos. Essentially, we split into two teams. One team builds from the ground up. The other tries to get the old mono running. Don't think I need to breakdown pros and cons here. It's basically an inverse of the above list. ## Final thoughts: - I'm leaning towards a new build. Lots of long term benefit there. - I also feel that new build is the surest way of getting up and running, even though it may not be the fastest. Even doing things the slow way, as long as there's no serious edge cases, we can get our libraries reasonably fast while layering in some of our other stuff later on.

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Contacts

Facebook

Twitter

Discord

Feedback

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync

Sign in to link this note to GitHub Learn more
This note is not linked with GitHub Learn more
 
Add badge Pull Push GitHub Link Settings
Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub

      Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

       Sign in to GitHub

      HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully