Skip to content

Instantly share code, notes, and snippets.

View juanpicado's full-sized avatar
closed for holidays (back in May) only quick replies ...

Juan Picado juanpicado

closed for holidays (back in May) only quick replies ...
View GitHub Profile
@juanpicado
juanpicado / hmr-verdaccio.md
Created March 31, 2023 05:55 — forked from sigma-andex/hmr-verdaccio.md
HMR for verdaccio plugin development

HMR for verdaccio plugin development

Verdaccio doesn't automatically reload plugins when files change, making plugin development a bit painful. So here is my approach for a hot module reload in verdaccio, so that verdaccio restarts whenever your plugin changes.

  1. Create a project folder and a subfolder plugins. Bootstrap the plugin in that folder using the generator so that you end up with something like plugin/verdaccio-my-plugi/ folder structure.

  2. First, let's add a watch mode for your plugin (if you don't have it yet) by adding the following script to you package.json: In plugin/verdaccio-my-plugin/package.json

  "scripts": {
import { spawn } from "child_process";
const child = spawn("node", [
require.resolve("verdaccio/bin/verdaccio"),
"-c",
"./verdaccio.yaml",
]);
child.stdout.on("data", (data) => {
process.stdout.write(data.toString());
@juanpicado
juanpicado / what-forces-layout.md
Created February 21, 2022 09:48 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@juanpicado
juanpicado / index.js
Created February 16, 2020 12:13
Verdaccio and Node API
const fs = require('fs');
const path = require('path');
const verdaccio = require('verdaccio').default;
const YAML = require('js-yaml');
const getConfig = () => {
return YAML.safeLoad(fs.readFileSync(path.join(__dirname, 'config.yaml'), 'utf8'));
}
const cache = path.join(__dirname, 'cache');
@juanpicado
juanpicado / config.yaml
Last active March 11, 2019 19:05
Fetch a package with Verdaccio and Gemfury as Uplink (Bearer Token)
storage: ./storage
plugins: ./plugins
web:
title: Verdaccio
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/

Debugging webpack

"scripts" : {
  "debug:webpack": "node --inspect --inspect-brk ./node_modules/webpack/bin/webpack.js",
  "prod:debug": "npm run debug:webpack -- --mode production",
  "dev:debug": "npm run debug:webpack -- --mode development"
}
@juanpicado
juanpicado / org.verdaccio.launcher.plist
Last active June 7, 2023 19:06
verdaccio on mac as a service
# ~/Library/LaunchAgents/org.verdaccio.launcher.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.verdaccio.launcher</string>
<key>Program</key>
<string>/Users/user/Scripts/verdaccio.sh</string>
<key>RunAtLoad</key>
@juanpicado
juanpicado / node-event-loop-demo.js
Created February 2, 2018 12:02 — forked from ghaiklor/node-event-loop-demo.js
This example shows how you can block event loop in NodeJS
'use strict';
// The purpose of this example is to show
// how you can block the event loop with JavaScript.
// There is 3 routes
// / respond with Hello, World text
// /block uses JavaScript while for 5 seconds
// /non-block uses setTimeout for 5 seconds
// Do the following
$> npm install wd
// execute the test
$> node wd.foo.test.js