Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESM import path for Windows compatibility in resolveTailwindConfig #123

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

jeramyhing
Copy link
Contributor

Description

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

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.

Resolves #122

* 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.
* Resolves area17#122
@mrtimbrook mrtimbrook merged commit df2a783 into area17:1.x Apr 2, 2024
3 checks passed
@mrtimbrook
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix ESM Import Path Error on Windows in resolveTailwindConfig() Function
2 participants