npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@suns/react-monorepo-nx

v0.0.5

Published

To evaluate and compare the bundled and unbundled builds on large codebase.

Downloads

431

Readme

ReactMonorepoNx Vite + Nx monorepo

To evaluate and compare the bundled and unbundled builds on large codebase.

Based on Nx and ViteJs based monorepo build toolchain.

In this project only React stack is evaluated with the goal of mixing TypeScript and Rust sources and targets.

CDN live demo

The page immediate dependencies load are meant only for bundle splitting samples.

To see the difference between unbundled and bundled distributions, within the odd or even, click on toggle lorem tree to trigger the 3Mb of components loaded.

Quick start

yarn # will take a while as 5K source lorem files generated
yarn dev # to run in dev mode
yarn prod # run bundled production build
yarn esm # run unbundled CDN build

Directory

Projects

2 main independent apps, frontend and react-monorepo-nx.

App sub-routes and ui sub-sets would include 4 big dependencies to assure the bundler would place each into separate sub-bundle.

  • front-end app/frontend as app with 2 routes (odd,even) to loaded on demand sub-apps.
  • frontend-odd /app/frontend/odd with lazy load of PdfView and 1st Lorem tree
  • frontend-even /app/frontend/even with lazy load of 2nd Lorem tree
  • shared /shared with lazy load of 3rd Lorem tree

Generated files

To make the files content different, the module name and lorem ipsum generator are going to be shown by the React component.

The TS build, Eslint, IDE load time performance on large monorepo is essential, hence generating the source volume during yarn install.

The sources are generated after yarn command by postinstall script. 4,370 lorem*.ts* files, 30Mb generated in folders:

  • app/odd
  • app/even
  • shared

To change the number of sources and file size change environment variables

  • LOREM_DEPTH for dependency tree depth. 4 as default it would generate 4,370 files
  • LOREM_PARAGRAPHS for number of paragraphs in generated component file. With 20 the average size is about 7Kb, 30Mb total

To manual experiment change vars ^^ like export LOREM_DEPTH=2; export LOREM_PARAGRAPHS=5; yarn lorem

Build process

The yarn lorem is executed only once with the output generated excluded from git repo.

The monorepo is ready for build and run yarn test yarn dev # development run for frontend app yarn build # prod build yarn serve # run the prod build

This workspace has been generated by Nx, a Smart, fast and extensible build system.

Start the app

To start the development server run nx serve react-monorepo-nx. Open your browser and navigate to http://localhost:4200/. Happy coding!

Generate code

If you happen to use Nx plugins, you can leverage code generators that might come with it.

Run nx list to get a list of available plugins and whether they have generators. Then run nx list <plugin-name> to see what generators are available.

Learn more about Nx generators on the docs.

Running tasks

To execute tasks with Nx use the following syntax:

nx <target> <project> <...options>

You can also run multiple targets:

nx run-many -t <target1> <target2>

..or add -p to filter specific projects

nx run-many -t <target1> <target2> -p <proj1> <proj2>

Targets can be defined in the package.json or projects.json. Learn more in the docs.

Want better Editor Integration?

Have a look at the Nx Console extensions. It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

Ready to deploy?

Just run nx build demoapp to build the application. The build artifacts will be stored in the dist/ directory, ready to be deployed.

Set up CI!

Nx comes with local caching already built-in (check your nx.json). On CI you might want to go a step further.

Connect with us!