twind: setup preflight:false doesn't work in Preact wmr dev server

(Twind version 0.15.8)

I am able to merge new values into Tailwind’s default preflight reset (see example below), but preflight: false doesn’t work as intended (just in case, I also tried preflight: 0, preflight: null and preflight: undefined, to no avail).

setup({
		preflight: (preflight) => {
			console.log(preflight);
			return css({
				h1: {
					color: 'red',
				},
			});
		},
});

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (19 by maintainers)

Most upvoted comments

You are right. The twind/shim module is unpure / has side effects.

The problem was hard to diagnose at first because of tree shaking (i.e. an unused import is discarded, but a simple console.log on one of the module exports triggers the inclusion of the module in the bundle / execution context). So I decided to look at Twind’s source code and was glad to see that I could re-implement the shim easily thanks to the public observer methods 😃

Thanks for your work by the way, much appreciated!

…for example, this is the twind/observe “sub”-package: https://unpkg.com/browse/twind@0.15.8/observe/package.json

What is wrong with that? Same as preact. Or did I miss something? I think the difference is the relative import from within sub-package JS file.

My point exactly (sorry, I was writing from my tiny phone keyboard so I probably wasn’t clear enough 😃