Fix ESM import path for Windows compatibility in resolveTailwindConfig #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 Fix ESM Import Path Error on Windows inresolveTailwindConfig()
Function #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