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

@omgovich/firebase-yarn-workspaces

v1.0.1

Published

Copies and links local yarn workspaces into Firebase projects for deployment

Downloads

2,985

Readme

firebase-yarn-workspaces

Yarn workspaces + Firebase deployments made easy.

Problem

Firebase functions does not support deployment of dependencies from a monorepo structure. To use dependencies which are not published to a registry, dependency code must be copied into the functions directory & referenced accordingly, prior to running firebase deploy --functions.

Solution

npx firebase-yarn-workspaces --scope <FIREBASE_FUNCTIONS_WORKSPACE_NAME>

This command, run at the root of your monorepo:

  1. Automatically builds a yarn dependency graph of workspaces used in your firebase functions package.json
  2. Copies all necessary package code into a .firebase-yarn-workspaces tmp folder inside your firebase functions workspace
  3. Modifies package.json in firebase functions workspace and in all nested dependencies to point to file: references

NOTE: Rollback of package.json changes is still TODO. Recommended use is currently only in an ephemeral environment, such as CI or in a pruned Turborepo 'out' folder (see examples)

Options

| Flag | Alias | Default | Required? | Description | | - | - | - | - | - | | --scope | -s | - | ✅ | Firebase functions workspace name. Example: --scope functions | --dir | -d | process.cwd() | ❌ | Path to workspace root Example: --dir ./out | --tmpDir | -t | .firebase-yarn-workspaces | ❌ | Custom tmp directory folder where dependency packages will be placed Example: --tmpDir custom-tmp-folder

Examples

Local pruned Turborepo

A simple shell script, which:

  • Prunes & builds your Turborepo into a clean /out dir
  • Installs dependencies
  • Copies & links packages via relative file path replacement in package.json
  • Deploys to Firebase
#!/bin/sh
cd $PATH_TO_TURBOREPO_ROOT

echo 'Creating a pruned Turborepo'
yarn turbo prune --scope=$FUNCTIONS_PACKAGE_NAME

echo 'Copying Firebase config'
cp ./{.firebaserc,firebase.json} ./out

cd ./out

echo 'Installing dependencies'
yarn

echo 'Running Turbo build'
yarn turbo run build --scope=$FUNCTIONS_PACKAGE_NAME --include-dependencies --no-deps --no-cache

echo 'Running firebase-yarn-workspaces'
npx firebase-yarn-workspaces --scope=$FUNCTIONS_PACKAGE_NAME

echo 'Deploying'
firebase deploy --force --only functions

echo 'Cleaning up ./out folder'
rm -Rf ../out

More examples soon:

  • Vanilla CI via GitHub Actions (Link coming soon)
  • Turborepo CI via GitHub Actions (Link coming soon)s