Skip to content

Instantly share code, notes, and snippets.

View arcanis's full-sized avatar
:octocat:

Maël Nison arcanis

:octocat:
View GitHub Profile
for (let type in types)
doSomething(type); // should be indented
for (let type of types)
doSomething(type); // should be indented
if (a)
if (b)
if (c) // wrong indent
; // wrong indent
let refCount = 0;
let resolvers = [];
function resolveAll() {
for (let resolve of resolvers)
resolve();
resolvers = [];
class EfficientPrinter {
constructor() {
this.lines = null;
}
render(text) {

Getting Started With Plug'n'Play

If you use create-react-app, #5136 (released with the 2.0) implements a --use-pnp option that allows you to easily create a new project using PnP! In this case, just use create-react-app --use-pnp together with Yarn 1.12, and you're good to go! 👍

Plug'n'Play is a new initiative from Yarn that aims to remove the need for node_modules. It's already available, and has proved being effective even on large-scale infrastructures. This document describes in a few steps how to quickly get started with it. Spoiler alert: it's quite easy 🙂

First, download a package manager that supports it. Yarn 1.12 already does, so that's what we're going to use! To install it, just follow the instructions on our website: https://yarnpkg.com/en/docs/install

If everything is ok, running yarn --version should give you v1.12.1 or higher. If you don't get this result maybe a

resolveModuleNames: (moduleNames, containingFile) => {
try {
const pnpModuleNames = moduleNames.map(moduleName => {
const [, prefix, rest] = moduleName.match(/^((?:!.*!)?)(.*)/);
const unqualified = require('pnpapi').resolveToUnqualified(rest, containingFile);
return unqualified !== null ? prefix + unqualified : moduleName;
});
const tsResolutions = resolveModuleNames(resolveSync, moduleResolutionHost, appendTsSuffixTo, appendTsxSuffixTo, scriptRegex, instance, pnpModuleNames, containingFile, getResolutionStrategy);
for (let t = 0; t < tsResolutions.length; ++t)
module.exports = {
name: `berry-plugin-is-yarn`,
factory: () => ({
default: {
hooks: {
setupScriptEnvironment(project, env, makePathWrapper) {
env.IS_YARN = `1`;
},
},
},
const locator = structUtils.makeLocator(`debug`, `npm:1.0.0`);
for (const pkg of project.storedPackages) {
const dependencies = Array.from(pkg.dependencies.values());
const isDependent = dependencies.some(dependency => {
const resolution = project.storedResolutions.get(dependency.descriptorHash)!;
return resolution === locator.locatorHash;
});
diff --git a/yarn.lock b/yarn.lock
index 391dbc4..7204d18 100644
--- a/yarn.lock
+++ b/yarn.lock
"rc-align@npm:^2.4.0, rc-align@npm:^2.4.1":
version: 2.4.5
resolution: "rc-align@npm:2.4.5"
dependencies:
babel-runtime: "npm:^6.26.0"
dom-align: "npm:^1.7.0"