Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

 

Articles

Article  ·  Monday, 17 October 2022
Thoughts about sort-package-json v2 pure ESM

Thoughts about sort-package-json v2 pure ESM

The npm package sort-package-jsonopens in a new tab migrated to ES Modules in their v2 release and indirectly broke their named exports which our packages have been consuming. It was a major semver bump, but breaking changes slipped from their changelog and readme radar, so I wanted to explain what actually happened there.

Read article
all posted tagged remixall posted tagged reactall posted tagged meta
a thought  ·  Tuesday, 30 August 2022

How to cause JSDelivr to purge assets

As you know, JSDelivr broadcasts all npm content from its CDNs for free. You can access any file of any package’s version ever published to npm. For example, there are “ever-green” URLs:

https://cdn.jsdelivr.net/npm/detergent/dist/detergent.umd.js

and exact versions:

https://cdn.jsdelivr.net/npm/detergent@3.2.0/dist/detergent.umd.js

Besides this cdn. URL, there’s also a purge URL — replace cdn. with purge.:

https://purge.jsdelivr.net/npm/detergent/dist/detergent.umd.js

Calling that URL will trigger JSDelivr to purge the CDN assets and fetch the latest from npm. That’s handy with ever-green UMDs because they power GUI’s (like these), and it can take up to a day for CDN to fetch the latest.

all posted tagged a thoughtall posted tagged meta
a thought  ·  Saturday, 27 August 2022

Latest typescript-eslint rule prefer-optional-chain is buggy

The typescript-eslintopens in a new tab ESLint plugin’s rule prefer-optional-chain is buggy on 5.35.1, it’s blocking me from bumping all deps in the monorepo. It took me around 4 hours to investigate, extract and raise https://github.com/typescript-eslint/typescript-eslint/issues/5556opens in a new tab

People also raisedopens in a new tab similar issues regarding the latest prefer-optional-chain.

I hope maintainers will fix it soon.

Until it’s fixed, don’t bump it beyond 5.33.1.

all posted tagged tsall posted tagged lintingall posted tagged a thought
a thought  ·  Saturday, 20 August 2022

Manual autoprefixer

Codsen.com runs on Remix, the framework which won’t process anything CSS-related. To scale the styling task, some people use Tailwind; I use good old SASSopens in a new tab on style-dictionaryopens in a new tab design tokens. SASS CLI watches the styles folder with .scss files from outside Remix and places the processed files inside the Remix project folder. From Remix’s point of view, CSS files just magically appear and update themselves.

Enter Autoprefixeropens in a new tab. It doesn’t fit into this workflow! We either need to set up a proper JS-script pipeline (à la Gulp) or, two-level setup with an intermediary folder where Autoprefixer CLI’s watches the output of SASS directory (so two CLI’s watching), or some fancy terminal pipe contraption.

None of the options seem suitable.

The alternative is to run VSCode pluginopens in a new tab manually, on .scss files.

Fig 1. Autoprefixer in VSCode

I’m OK with that, this website needs to be simple.

all posted tagged a thought
Article  ·  Thursday, 18 August 2022
One character in a file “weighs” one byte

One character in a file “weighs” one byte

Few people asked me how I count, how much is any arbitrary text “worth” in kilobytes, how I calculate that in my web apps. The answer is simple.

Read article
all posted tagged meta
a thought  ·  Tuesday, 16 August 2022

Consolidating

Our packages email-comb and html-crush had dedicated GUI websites and considerable amount of people have been using them. Over time, these two websites became hard to maintain; they were coded in vanilla JS without consistent components, tests and styling. Since they were created, a lot has changed; for example, Remix.js appeared and shook up everything. For example, the codsen.com theme toggle detects when a user switches the theme on the OS Preferences panel. There’s also no initial flash either. Those two old websites didn’t have this technology.

It took me a few weeks to recode them on codsen.comopens in a new tab. Five minutes ago, I set up the redirects:

  • https://emailcomb.comopens in a new tab to 301-redirect to https://codsen.com/os/email-comb/playopens in a new tab
  • https://htmlcrush.comopens in a new tab to 301-redirect to https://codsen.com/os/html-crush/playopens in a new tab

Plus, I created a playground for string-strip-htmlopens in a new tab; it didn’t have a domain before.

The next one is https://detergent.ioopens in a new tab — the final remaining dedicated library GUI website. I have a few ideas on further improving both the package and its GUI, so I kept them to the last.

2022-SEPT-11 update: detergent.ioopens in a new tab has been migrated to codsen.com playground.

all posted tagged a thought
a thought  ·  Friday, 12 August 2022

Exporting types too

It’s a day off today and I’m adding exports to all unexported-yet TS types and interfaces defined in every program, especially Opts and Res:

Fig 1. Adding type exports

like that⤴, on every single program-package.

PS. I can’t stop thinking about deno and being able to run TS natively. How nice would it be to have the whole monorepo in deno, on rust tooling! Theoretically, we could get rid of: prettier, uvu, c8, esbuild, benchmark, turbo, and (shocker) eslint.

all posted tagged a thought
Article  ·  Monday, 01 August 2022
Sync state with URL params in Remix

Sync state with URL params in Remix

This weekend I was tinkering with string-strip-html GUI; I wanted to sync the state with URL params so that users could bookmark the page and visit later and automatically get those settings restored.

Here’s an MVP based on a forked Remix.js starter template on StackBlitz.

Read article
all posted tagged reactall posted tagged remixall posted tagged ts
Article  ·  Tuesday, 19 July 2022
Observation regarding RTL getby and findby interchangeability

Observation regarding RTL getby and findby interchangeability

At first glance, it seems that React Testing Library (abbreviated RTL) await waitFor + get can be replaced with find everywhere, but it’s not so.

Read article
all posted tagged reactall posted tagged testingall posted tagged jsall posted tagged ts
Article  ·  Monday, 18 July 2022
Styling the react-codemirror instances

Styling the react-codemirror instances

When building the string-strip-html GUI, I wanted: line wrapping, full-screen flexbox layout, with scrollbars on Codemirror box only. That’s a common layout seen on code-oriented sites like Codepen or Stackblitz. I created a minimal proof-of-concept sandbox to prove it works.

Read article
all posted tagged metaall posted tagged reactall posted tagged ts
a thought  ·  Sunday, 17 July 2022

Stripping HTML

Mr Toh posted a good articleopens in a new tab comparing various means to strip tags from HTML, including our npm package string-strip-html.

To add 2p.

It’s not just about speed.

The primary reason why you’d use an npm package, rather than regex, is whitespace management. The string-strip-html ensures the stripped results looks as if a human deleted the tags. Our program can even be used to generate email text versions, placing URLs besides the stripped link labels.

The second reason is string-strip-html can tackle broken HTML, dirty HTML and HTML mixed with other languages.

The third reason is string-strip-html saves you time: writing unit tests, writing correct type definitions (you’re using TypeScript, right?) and tackling edge cases.

all posted tagged a thought
Article  ·  Tuesday, 12 July 2022
New requirements for npm packages in TypeScript 4.7+

New requirements for npm packages in TypeScript 4.7+

The latest TS doesn’t support the types key at the package.json root level. Paul Zaczkiewicz raised an issueopens in a new tab on our GH tracker about it, and together we were able to come up with a reproductionopens in a new tab (later I also discovered a related ticketopens in a new tab on TS issues board). From there on, it was easy to solve; here’s how.

Read article
all posted tagged jsall posted tagged tsall posted tagged infra
a thought  ·  Monday, 04 July 2022

Learning as you lint

Besides pairing, I think the greatest practical learning comes from well-configured linting rules. For example, ESLint plugins for React hooksopens in a new tab or RTLopens in a new tab.

Since you’ll see a suggestion only if you make a mistake, it’s perfectly-relevant.

all posted tagged a thought
Article  ·  Monday, 20 June 2022
Importing SVG in Remix MDX

Importing SVG in Remix MDX

A decade ago, Chris Coyier from CSS-Tricks describedopens in a new tab ways to consume SVG, which can be distilled into two groups: to link and to embed.

Fast forward to 2022, the market has shifted from WordPress+PHP to React+TypeScript, but the same dilemma “to link or to embed?” still applies because, at the bottom of it, we’re still dealing with the same HTML and CSS as we did a decade ago.

So what’s the best way to import SVG in MDX?

Read article
all posted tagged jsall posted tagged tsall posted tagged remixall posted tagged mdx
a thought  ·  Sunday, 19 June 2022

Arguments against Eleventy

Codsen.com was previously on Eleventy, pure static HTML+CSS, served from the Edge via Cloudflare workers.

The problems with that setup were:

  1. Flashing when navigating between pages
  2. Components written in Nunjucks — not as universal as JSX
  3. Absence of MDX
  4. A poorer DX in general, stemming from Nunjucks itself — for example, compare the Nunjucks and TS linting
  5. Cloudflare Workers can be fragile, the wrangler program which serves the sites is buggy
  6. Being on edge, without a server, doesn’t mean you spend any less than using a server + CDN
  7. Unable to share Nunjucks components in tester web apps driven by Vue

I’m sure most of that could be solved one way or another. But I just outgrew the 11ty baby shirt.

all posted tagged a thought
Article  ·  Saturday, 18 June 2022
CSS Styling via breadcrumb classes

CSS Styling via breadcrumb classes

Frameworks come and go — Remix, Next, Gatsby, WordPress, Hugo, Hexo, TextPattern — but the “classic” CSS styling tactics stay. If you still use SASS and embrace the CSS inheritance — you’re probably already using this technique.

Read article
all posted tagged metaall posted tagged htmlall posted tagged cssall posted tagged remix
a thought  ·  Thursday, 16 June 2022

string-truncator in action

We’ve just published a new npm package, string-truncator. First and foremost, it’s for our own use. A picture is worth a thousand words; here’s our <aside>, before and after:

Fig 1. The aside titles, before and after implementing the string-truncator

The string truncation is optimised to fit in as much letters as possible within “X line length across Y lines”.Check it out!

all posted tagged a thoughtall posted tagged meta
Article  ·  Sunday, 12 June 2022
Syntax highlighting in Remix

Syntax highlighting in Remix

Syntax highlighting is done using either highlight.jsopens in a new tab or prism.jsopens in a new tab. Once you’ve picked one, you’ll have to set it up for code blocks: 1. within MDX and 2. outside MDX. That’s how it works on all kinds of frameworks, not just Remix, although I’ll post examples for Remix.

This setup is mostly a trivial task; however, there are a few niggles worth mentioning.

Read article
all posted tagged jsall posted tagged tsall posted tagged reactall posted tagged remixall posted tagged metaall posted tagged mdx
Article  ·  Saturday, 04 June 2022
Against UK keyboard layout

Against UK keyboard layout

When you look closely at UK keyboard layout, it does not make sense: 1) useless keys… 2) …at located at strategic places; 3) plus weird key shape.

Read article
all posted tagged tooling
Article  ·  Saturday, 21 May 2022
Better npm packages

Better npm packages

Maintaining npm packages is hard, and writing Open Source is already an achievement. But let’s not get complacent. Here I tried to compile a list of a few ideas to improve further. I haven’t implemented some of them yet. Few entries at the bottom are so novel that I think nobody in the world has either.

Read article
all posted tagged infraall posted tagged open source
Article  ·  Thursday, 19 May 2022
rollup vs esbuild: iife is not umd

rollup vs esbuild: iife is not umd

Back in the day, before native ES Modules, UMD builds were superior to IIFE because we could unit test them.

And while Rollup and Webpack can produce UMD, esbuild can only make IIFE, so that was an argument against using the esbuild.

Read article
all posted tagged jsall posted tagged ts
a thought  ·  Tuesday, 17 May 2022

Mastering the tooling

Don’t know if you noticed but many extraordinary developers mastered their code editors to such level, that they started teaching productivity, editor plugins and, heck, in some cases, writing code editors.

The first two quick examples that pop to my mind:

  • Wes Bos (online educator) has once published a Sublime Text Power User bookopens in a new tab
  • Steve Francia (creator of Hugo the static site generator and many famous Golang libraries) has his Vimopens in a new tab

It does not matter what code editor you use but it’s imperative to master all keyboard shortcuts and tricks of the one you picked.

all posted tagged a thought
Article  ·  Monday, 16 May 2022
Our dark mode setup

Our dark mode setup

I used to believe that three-theme UI toggle (auto-dark-light) was superior to the two-theme, dark-light. But I don’t think that way anymore.

Read article
all posted tagged remixall posted tagged reactall posted tagged metaall posted tagged css
a thought  ·  Tuesday, 11 May 2021

“Renowned obsession”

“Our obsession with quality is renowned as every Jaeger‑LeCoultre watch undergoes strict “1,000 Hour Control” testing.”

—official websiteopens in a new tab

I wonder, what would be the Software Engineering field equivalent of that?

all posted tagged a thought
a thought  ·  Tuesday, 11 May 2021

Stripping MDX tags

Interestingly, the non-parsing algorithm of string-strip-html is paying off. It strips JSX tags from MDX! I’m using it myself, on this website, to build the fuse.js search indexes.

all posted tagged a thoughtall posted tagged meta
Article  ·  Friday, 02 April 2021
html-crush bug fixed

html-crush bug fixed

One line in Babel config, env preset’s loose set to true was causing a spread operator to disappear on only CommonJS builds (not ES Modules or UMD), which led to broken logic (program could not calculate opts.breakToTheLeftOf correctly any more), program inserted extra blank lines. A crazy bug, isn’t it?

Read article
all posted tagged js
Article  ·  Thursday, 11 March 2021
An observation regarding TypeScript and type safety

An observation regarding TypeScript and type safety

Consider a function written in TS, which multiplies two numbers…

Read article
all posted tagged jsall posted tagged ts
Article  ·  Wednesday, 03 March 2021
codsen-parser vs. hyntax

codsen-parser vs. hyntax

Imagine the HTML: <a></b>.

Parser-wise, how would you design the AST architecture, considering cases like that?

Read article
all posted tagged js
Article  ·  Sunday, 28 February 2021
chalk vs. colorette

chalk vs. colorette

Tooling choices are a subjective matter. Lately, I’ve been observing coloretteopens in a new tab taking over eroding chalkopens in a new tab, and I have few thoughts on this subject.

Read article
all posted tagged js
Article  ·  Wednesday, 30 September 2020
Automated Vercel redirect maintenance on Eleventy

Automated Vercel redirect maintenance on Eleventy

Vercel, our static website hosting service, makes it easy to set up page redirects, you can have up to 1024 redirects. It’s all controlled from a single JSON file. Many things can go wrong in that file, stakes are quite high (starting with SEO) and any redirect mistakes can be hard to spot.

Here’s our automated checking setup.

Read article
all posted tagged vercelall posted tagged metaall posted tagged eleventy
Article  ·  Wednesday, 16 September 2020
Why object-path package is great

Why object-path package is great

The npm package object-pathopens in a new tab is a getter/setter for nested arrays and plain objects. Here we use it directly and also align our API’s to it. Here’s why.

Read article
all posted tagged apiall posted tagged js
Article  ·  Monday, 31 August 2020
ESLint uses similar thing to Ranges

ESLint uses similar thing to Ranges

Well, sort of.

Read article
all posted tagged rangesall posted tagged linting
Article  ·  Wednesday, 19 August 2020
Evolution of our npm Packages, from a README perspective

Evolution of our npm Packages, from a README perspective

As our npm package count grows, the README automation becomes more and more an issue. Installation instructions, badges, contribution guidelines can be automatically generated, but many other chapters can’t.

Here’s our story from a README perspective.

Read article
all posted tagged monorepoall posted tagged indieweb
Article  ·  Tuesday, 18 August 2020
string-strip-html v.5 and lessons learned

string-strip-html v.5 and lessons learned

For an exported function, string-in, string-out API is awesome because it’s simple. The problem happens later when you want to add more to the output, for example, a log with time spent. Or an alternative output, like locations of string indexes. Or the version from package.json.

Read article
all posted tagged api
a thought  ·  Saturday, 01 June 2019

In favour of BYOD

Few arguments in favour to BYOD company policies:

  1. Passwords
  2. Notes
  3. Snippets
  4. ZSH aliases
  5. Time wasting syncing all above
  6. Money wasting on two sets of licences
all posted tagged a thought

RSS feed

Subscribe to articles RSS feed

to select, click or tap the input above once

All Tags

a thoughttoolinginfraopen sourcemetahtmlcssremixjsrangeslintingmonorepoindiewebtsmdxapireactverceleleventytesting

   

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab