ESM files not loading properly on Windows #1405
Open
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.
The current strategy for importing files from CLI (e.g.:
jscad ./model.js
) first converts the source path argument to absolute (if not absolute already) and thenawait import()
s itThe issue is that
import()
only accepts URLs and, in Windows, the absolute path of a file is not an URL as it starts with a partition letter (e.g.:c:/path/to/file.js
)The proper way of handling this is with the
file://
protocolThis PR converts the absolute path to a
file://
URL before callingimport()
note:
pnpm test
failed to run with errorBased on your configuration, 7 test files were found, but did not match the CLI arguments:
and, as such, no test was runRegardless, I tested the implementation in Windows and Ubuntu (WSL) and both yielded a proper
.stl
fileAll Submissions: