Automatically transpile modern packages in node_modules.
Available in 3 fun flavours: plugin, loader and loader factory.
Add the plugin to your webpack config, and it should handle everything for you.
worker_threads
Works with ESM and CommonJS.
import greenlet from 'greenlet-node';
const add = greenlet(async (a, b) => {
return a + b;
});
package-lock.json | |
node_modules | |
.cache | |
dist |
Experimental hooks-based bindings for Unistore. Available on npm:
npm i unistore-hooks
Note: this should also work with React, just alias
"preact"
and"preact/hooks"
to"react"
in your bundler.
A tiny zero-dependency compression middleware for polka (& express!) with native Brotli support.
(function(c,b,cs,r,d){ | |
b.frameBorder=0; | |
b.style = 'position:fixed;bottom:0;left:0;width:100%;height:30vh;background:#fff;border-top:4px solid #bbb;box-shadow:0 0 2px #000;z-index:999;cursor:ns-resize;'; | |
b.onpointerdown=function(e){b.setPointerCapture(e.pointerId);b.e=e;b.h=b.offsetHeight-4;b.style.borderTopColor='#59f'} | |
b.onpointermove=function(e){if(b.e)b.style.height=(b.h-e.y+b.e.y)+'px'} | |
b.onpointerup=function(){b.e=null;b.style.borderTopColor='#aaa'} | |
document.documentElement.appendChild(b); | |
(d=b.contentWindow.document).open(); | |
d.write('<style>html,body{width:100%;height:100%;overflow:hidden;font:12px/1.2 system-ui,sans-serif;flex:1;display:flex;flex-direction:column;margin:0;}*{box-sizing:border-box;}button{font:inherit;}pre{margin:0;padding:4px;border-bottom:1px solid #ddd;}</style><div style="background:#ddd;border-bottom:1px solid #ccc;display:flex;padding:3px 5px 4px;align-items:center;"><div style="color:#555;flex:1;">Console</div><button onclick="console.clear()">clear</button></div> |
This is a 1.1kb polyfill for Module Workers.
It adds support for new Worker('..',{type:'module'})
to all modern browsers (those that support fetch).
Copy module-workers-polyfill.js
to your web directory, then load it using an import or a script tag.
It just needs to be loaded before instantiating your Worker.
/** | |
* Write JSX, but make sure you have `import html from 'htm/preact'` in your files. | |
* Run them through this horrid attrocity and get JSX support with basically no overhead. | |
*/ | |
export function transformJsxToHtm(code) { | |
const tokenizer = /(^|)(?:<\/([a-z$_][a-z0-9_.-:]*)>|<([a-z$_][a-z0-9_.-:]*)(\s+[a-z0-9._-]+(?:=(?:".*?"|'.*?'|\{.+?\}))?)*(\s*\/\s*)?>|<(\/?)>)/gi; | |
let out='', index=0, token; | |
let depth = 0; | |
let stacks = []; | |
let shouldPop = false; |