import { forwardRef } from 'preact-forwardref';
const Foo = forwardRef((props, ref) => {
return <div ref={ref} />
});
render( console.log(div)} />, document.body);| { | |
| "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.83 Safari/537.36", | |
| "environment": { | |
| "networkUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Safari/537.36 Chrome-Lighthouse", | |
| "hostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.83 Safari/537.36", | |
| "benchmarkIndex": 1176 | |
| }, | |
| "lighthouseVersion": "5.7.0", | |
| "fetchTime": "2020-04-03T19:12:14.230Z", | |
| "requestedUrl": "https://ride.lyft.com/riderweb?origin=42.381531%2C-71.098173&originName=46+Bow+St", |
| module.exports = function (babel) { | |
| const t = babel.types; | |
| const importTpl = babel.template('const SPECIFIERS = require(SOURCE)'); | |
| const exportTpl = babel.template('module.exports = EXPORT'); | |
| return { | |
| name: 'transform-modules-commonjs-simplified', | |
| visitor: { | |
| ImportDeclaration(path) { | |
| const specs = path.node.specifiers; | |
| let specifiers; |
| { | |
| "name": "react-ssr-prepass", | |
| "version": "0.0.1", | |
| "main": "react-ssr-prepass.js", | |
| "peerDependencies": { | |
| "preact-ssr-prepass": "*" | |
| } | |
| } |
| export default (function create(options = {}) { | |
| const client = { | |
| headers: options.headers || {}, | |
| create | |
| }; | |
| const events = {}; | |
| client.emit = (type, e) => { | |
| events[type] && | |
| events[type].slice().map(fn => { |
| module.exports = { | |
| env: { | |
| browser: true | |
| }, | |
| extends: [ | |
| 'plugin:react/recommended', | |
| 'plugin:@typescript-eslint/recommended', | |
| 'prettier/@typescript-eslint', | |
| 'plugin:prettier/recommended' | |
| ], |
🔍 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.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Preact App with Microbundle</title> | |
| <link rel="stylesheet" href="/style.css"> | |
| </head> | |
| <body> | |
| <div id="preact_root"></div> | |
| <script type="module" src="bundle.js"></script> | |
| </body> |
| /** | |
| * 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; |
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.