You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running the script on a Windows environment, the dynamic import statement in the resolveTailwindConfig function throws an ERR_UNSUPPORTED_ESM_URL_SCHEME error. This issue arises because the path provided to the import() function does not conform to the file:// URL scheme expected by Node.js for ESM imports on Windows platforms.
To Reproduce
Steps to reproduce the behavior:
Set up the project on a Windows environment.
Run the script php artisan blast:publish.
See the ERR_UNSUPPORTED_ESM_URL_SCHEME error related to the dynamic import statement.
Expected behavior
The script should dynamically import the Tailwind configuration file without throwing any errors, regardless of the operating system.
Error Output
Error Output:
================
node:internal/errors:496
ErrorCaptureStackTrace(err);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data,
and node are supported by the default ESM loader. On Windows, absolute paths must
be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:405:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:131:11)
at defaultLoad (node:internal/modules/esm/load:82:3)
at nextLoad (node:internal/modules/esm/loader:163:28)
at ESMLoader.load (node:internal/modules/esm/loader:603:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
at new ModuleJob (node:internal/modules/esm/module_job:64:26)
at #createModuleJob (node:internal/modules/esm/loader:480:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Node.js v18.17.0
Proposed Solution
To resolve this issue, we suggest modifying the resolveTailwindConfig() function to use the pathToFileURL function from Node.js's url module. This change will correctly convert the file path to a file:// URL, ensuring compatibility across operating systems, including Windows.
Here's the suggested change:
// ./src/resolveTailwindConfig.jsasyncfunctionresolveTailwindConfig(){constfs=awaitimport('fs');const{default: resolveConfig}=awaitimport('tailwindcss/resolveConfig.js')const{ pathToFileURL }=awaitimport('url');// Convert CONFIGPATH to a file URLconstconfigPath=pathToFileURL(process.env.CONFIGPATH).href;const{default: config}=awaitimport(configPath)constfullConfig=resolveConfig(config);try{if(!fs.existsSync(TEMP_DIR)){fs.mkdirSync(TEMP_DIR);}fs.writeFileSync(OUTPUT_PATH,`<?php return ${parseConfig(fullConfig)};`);}catch(err){console.error(err);}}
This update will automatically handle the conversion of the configuration file path into a valid file:// URL, resolving the ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows platforms.
Additional context
This error was encountered using Node.js version 18.17.0 on a Windows environment.
We have tested a successful outcome on the Windows environment in question after the suggested change.
The issue does not appear on UNIX-based systems due to differences in file path handling.
We have tested the continued successful outcome on UNIX-based systems after the suggested change.
The text was updated successfully, but these errors were encountered:
* 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.
* Resolvesarea17#122
#123)
* 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#122
Bug Description
When running the script on a Windows environment, the dynamic import statement in the
resolveTailwindConfig
function throws anERR_UNSUPPORTED_ESM_URL_SCHEME
error. This issue arises because the path provided to theimport()
function does not conform to thefile://
URL scheme expected by Node.js for ESM imports on Windows platforms.To Reproduce
Steps to reproduce the behavior:
php artisan blast:publish
.ERR_UNSUPPORTED_ESM_URL_SCHEME
error related to the dynamic import statement.Expected behavior
The script should dynamically import the Tailwind configuration file without throwing any errors, regardless of the operating system.
Error Output
Proposed Solution
To resolve this issue, we suggest modifying the
resolveTailwindConfig()
function to use thepathToFileURL
function from Node.js'surl
module. This change will correctly convert the file path to afile://
URL, ensuring compatibility across operating systems, including Windows.Here's the suggested change:
This update will automatically handle the conversion of the configuration file path into a valid
file://
URL, resolving theERR_UNSUPPORTED_ESM_URL_SCHEME
error on Windows platforms.Additional context
The text was updated successfully, but these errors were encountered: