forgetti

Solve your hook spaghetti (with more spaghetti). Inspired by React Forget.

MIT License

Downloads
460
Stars
351
Committers
4

Bot releases are visible (Hide)

forgetti - v0.8.0 Latest Release

Published by lxsmnsyc 9 months ago

  • Moved to Biome for better linter/formatter stuff.
  • Fix generated templates to have better dev-only names
forgetti - v0.7.0

Published by lxsmnsyc about 1 year ago

What's Changed

  • Separate $$ref from $$cache by @SukkaW in https://github.com/lxsmnsyc/forgetti/pull/30
    • Pretty big internal change, so I have to make a minor release. This change separates ref handling from cache management (instead of useRef for all, useRef is only now used for refs, the rest uses useMemo). This change is pretty much aligned to React's behavior e.g. Server Components support and proper cache management through useMemo

Full Changelog: https://github.com/lxsmnsyc/forgetti/compare/v0.6.2...v0.7.0

forgetti -

Published by lxsmnsyc over 1 year ago

forgetti - v0.5.0

Published by lxsmnsyc over 1 year ago

This release adds a new optimization process on top of the current memoization process. Forgetti will now run the transform as follows:

  1. Pre-inlining
    Variable declarations that can be inlined are recursively inlined. This allows the memoization step to know the largest possible constant expression and cache it in a single entry.
  2. Expansion
    Assignment expressions and hooks had issues in optimization in 0.4.x. With the expansion step, these expressions are now moved before the parent statement path, and ensures that these expressions are called out of their rules.
  3. Simplify
    Some expressions that are guaranteed to have literal evaluation are evaluated in compile-time.
  4. Memoization
    This is where the old core runs. A major difference compared to 0.4.x now is that the memoization process will test first if the entire expression is a "constant" to save more cache slots. Previously, it would subdivide naively, generating unnecessary amount of caching.
  5. Post-inlining
    Same process as step 1. This allows generated variables to be inlined so that there's less output.

Changes

Full Changelog: https://github.com/lxsmnsyc/forgetti/compare/v0.4.7...v0.5.0

forgetti - v0.3.0

Published by lxsmnsyc over 1 year ago

Full Changelog: https://github.com/lxsmnsyc/forgetti/compare/v0.2.0...v0.3.0

forgetti - v0.2.0

Published by lxsmnsyc over 1 year ago

  • Now auto-memoizes useRef
import { useRef } from 'react';
function Example(props) {
  return useRef(props.value);
}
// Compiles into
import { useMemo as _useMemo } from "react";
import { useRef } from 'react';
function Example(props) {
  let _c = _useMemo(() => new Array(1), []);
  let _v = _c[0] || (_c[0] = {
    current: props.value
  });
  return _v;
}

Full Changelog: https://github.com/lxsmnsyc/forgetti/compare/v0.1.1...v0.2.0

Package Rankings
Top 6.39% on Npmjs.org
Badges
Extracted from project README
NPM JavaScript Style Guide React without memo Open in CodeSandbox Open in CodeSandbox
Related Projects