Skip to content

Commit

Permalink
Fix config import() path with Windows drive letters
Browse files Browse the repository at this point in the history
Compatible cross-platform “path to file URL” changes must use `pathToFileURL()`

```
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
```
  • Loading branch information
colinrotherham committed Jul 24, 2023
1 parent fbf2828 commit 63afd26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shared/tasks/configs.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { join } from 'path'
import { pathToFileURL } from 'url'

import { files } from './index.mjs'

Expand All @@ -11,7 +11,7 @@ import { files } from './index.mjs'
* @returns {Promise<void>}
*/
export async function compile (modulePath, options) {
const { default: configFn } = await import(join(options.srcPath, modulePath))
const { default: configFn } = await import(pathToFileURL(join(options.srcPath, modulePath)).toString())

// Write to destination
return files.write(modulePath, {
Expand Down

0 comments on commit 63afd26

Please sign in to comment.