This PR addresses an issue encountered on Windows environments where the dynamic import in the resolveTailwindConfig function throws an ERR_UNSUPPORTED_ESM_URL_SCHEME error due to the file path not conforming to the file:// URL scheme expected by Node.js for ESM imports. By utilizing the pathToFileURL function from the url module, this change ensures that file paths are correctly formatted as URLs, making the script compatible across different operating systems, including Windows.
Changes
Used pathToFileURL to convert CONFIGPATH to a valid file:// URL before importing.
This modification ensures the dynamic import function works as expected on Windows by conforming to the required URL scheme.
Motivation
Fixes the ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows, as detailed in Issue #122.
Ensures the script's compatibility and functionality across all platforms, improving developer experience and script robustness.
Testing
Tested on Windows 10 and 11 with Node.js v18.17.0, confirming the absence of the ERR_UNSUPPORTED_ESM_URL_SCHEME error and successful script execution.
Verified that the script continues to function as expected on UNIX-based systems (macOS and Ubuntu).
How to Test
Set the CONFIGPATH environment variable to a local configuration file path.
Run the script on a Windows environment.
Observe that the script completes successfully without throwing the ERR_UNSUPPORTED_ESM_URL_SCHEME error.
This PR brings the script in line with Node.js standards for ESM imports and ensures a more universal, error-free operation across different operating environments.
Description
This PR addresses an issue encountered on Windows environments where the dynamic import in the
resolveTailwindConfig
function throws anERR_UNSUPPORTED_ESM_URL_SCHEME
error due to the file path not conforming to thefile://
URL scheme expected by Node.js for ESM imports. By utilizing the pathToFileURL function from the url module, this change ensures that file paths are correctly formatted as URLs, making the script compatible across different operating systems, including Windows.Changes
pathToFileURL
to convertCONFIGPATH
to a validfile://
URL before importing.Motivation
ERR_UNSUPPORTED_ESM_URL_SCHEME
error on Windows, as detailed in Issue #122.Testing
ERR_UNSUPPORTED_ESM_URL_SCHEME
error and successful script execution.How to Test
CONFIGPATH
environment variable to a local configuration file path.ERR_UNSUPPORTED_ESM_URL_SCHEME
error.This PR brings the script in line with Node.js standards for ESM imports and ensures a more universal, error-free operation across different operating environments.
Resolves #122