Understand the behavior of `*.mjs` worker files
v4The *.mjs files in the src/utils/tailwindcss-api/worker/ directory are worker scripts designed to run in Node.js worker_threads. Because they execute in a separate thread from the main thread, they have specific constraints:
- Serialization Requirement: You cannot pass or return complex objects. Arguments and return values must be serializable. For example, you cannot return
utils.contextdirectly; you must return specific serializable properties from it. - Logging Limitations:
console.logmay not function as expected when running tests withvitest. - Module Type: The
.mjsextension signifies that these files are ES modules. - Build Process: These files are not compiled; they are copied as-is into the
distpackage by the build script. - Type Checking: While these are not TypeScript files, their syntax is still checked with TypeScript.