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.
// Run `"javascript:$(terser .\preact-checker.js)" > .\preact-checker.min.js` to make it a bookmarklet | |
(function () { | |
var expando = | |
typeof Symbol != "undefined" && Symbol.for && Symbol.for("preactattr"); | |
function isMatch(node) { | |
if ("__k" in node && "props" in node.__k && "type" in node.__k) { | |
return true; | |
} | |
return ( |
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.
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.
🔍 see jay, yes! 🎉 / 👨🏻💻 see, JS! 👾 / ⚓️ sea JS ⛴
If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.
This isn't to support old browsers or Node versions: even in Node 14, using require()
to load a module won't work if it's only available as ESM.
cjyes
is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json
, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes
takes up 500kb of disk space including its two dependencies.
This is a half-baked sketch of compiling HTM expressions into a list of instructions that can be interpreted in runtime with a compact function. The instructions hopefully compress well and the evaluation function should be not-slow. Maybe.
evaluate.js
contains the evaluation function (evaluate(...)
) as well as an example of a compiled HTM call.
babel.js
contains a Babel plugin that transforms HTM calls into the stack language. The build.mjs
file it imports is HTM's src/build.mjs
.
This tweet demonstrates that a minified evaluate()
fits in one tweet: https://twitter.com/jviide/status/1257755526722662405 🙂
title | layout | permalink | oneline |
---|---|---|---|
Creating .d.ts Files from .js files |
docs |
/docs/handbook/declaration-files/dts-from-js.html |
How to add d.ts generation to JavaScript projects |
With TypeScript 3.7, TypeScript added support for generating .d.ts files from JavaScript using JSDoc syntax.
{ | |
"imports": { | |
"htm": "https://unpkg.com/[email protected]/dist/htm.module.js", | |
"htm/preact": "https://unpkg.com/[email protected]/preact/index.module.js", | |
"preact": "https://unpkg.com/[email protected]/dist/preact.module.js", | |
"preact-render-to-string": "https://unpkg.com/[email protected]/dist/index.module.js" | |
} | |
} |