Git Product home page Git Product logo

webpacker-pnpm's Introduction

webpacker-pnpm

version status downloads license Buy a tree

webpacker-pnpm replaces Rails' Yarn environment with pnpm, a better, smarter, and more efficient Node.js package manager. As a result, applications become less prone to dependency hell, more functional, more stable, and more flexible. And as an added bonus, dependency resolution times and node_modules folder sizes reduce to within reasonable ranges (not 45 seconds and 10 GiB).

You can read about the philosophy and technology behind pnpm in this convincing blog post by Zoltan Kochan (https://www.kochan.io/nodejs/why-should-we-use-pnpm).

Features

  • Production-ready
  • Drop-in replacement for Yarn
  • Supports Rails' Template API, including existing templates using Yarn
  • Provides code sanity without the migraines
  • Gives you more disk space

Installation

In order to use webpacker-pnpm, you must install pnpm. The official instructions are here.

After installing pnpm, first add webpacker-pnpm to your app's Gemfile.

gem "webpacker-pnpm"

Secondly, add the following line to your ./bin/webpack so it looks like below (the order matters). This step is required as Webpacker spawns a new process isolated from the Rails server (and thus all auto-loaded patches) when compilation happens live.

require "webpacker/webpack_runner"
require "webpacker/pnpm/patches" if ENV["RAILS_ENV"] != "production"

If you know of an automatic way of achieving a similar result, please open an Issue or PR with your suggestion.

License

This software is licensed under the BSD 3-Clause License.

This package is Treeware. If you use it in production, consider buying the world a tree to thank me for my work. By contributing to my forest, you’ll be creating employment for local families and restoring wildlife habitats.

webpacker-pnpm's People

Contributors

hipsterbrown avatar thearchitector avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

webpacker-pnpm's Issues

Webpacker gem version

I think this will boil down to requesting an update to the docs, which say:

There is no need to worry about your official Webpacker gem version, as this gem should be version-agnostic.

I thought, "Great! Because I'm not in a place to update Webpacker." So I simply added gem 'webpacker-pnpm' to my gemfile, which failed saying that I need to worry about my official Webpacker gem version:

% bundle
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Bundler could not find compatible versions for gem "webpacker":
  In snapshot (Gemfile.lock):
    webpacker (= 3.6.0)

  In Gemfile:
    webpacker (~> 3.0)

    webpacker-pnpm was resolved to 1.2.0, which depends on
      webpacker (~> 5.x)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

And for fun:

% bundle update
Fetching https://github.com/looker/looker-sdk-ruby.git
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Bundler could not find compatible versions for gem "webpacker":
  In Gemfile:
    webpacker (~> 3.0)

    webpacker-pnpm was resolved to 1.2.0, which depends on
      webpacker (~> 5.x)

undefined method `resolved_paths_globbed' for #<Webpacker::Configuration:0x0000559d4266ab40>

I consistently get undefined method `resolved_paths_globbed' for #<Webpacker::Configuration:0x0000559d4266ab40> when trying to access routes generated with the rails scaffolding. Possibly webpacker.yml is indicating webpack 4 resolved_paths instead of additions_paths?1 I couldn't work around this one.

Love what you're trying to do with this gem, look forward to dumping yarn for pnpm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.