-
-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract dynamicImport util for reusing
- Loading branch information
Showing
6 changed files
with
40 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// NOTICE: This file is generated by Rollup. To modify it, | ||
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build). | ||
'use strict'; | ||
|
||
const node_path = require('node:path'); | ||
const node_url = require('node:url'); | ||
|
||
/** | ||
* Dynamic import wrapper for compatibility with absolute paths on Windows | ||
* | ||
* @see https://github.com/stylelint/stylelint/issues/7382 | ||
* | ||
* @param {string} path | ||
*/ | ||
function dynamicImport(path) { | ||
return import(node_path.isAbsolute(path) ? node_url.pathToFileURL(path).toString() : path); | ||
} | ||
|
||
module.exports = dynamicImport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { isAbsolute } from 'node:path'; | ||
import { pathToFileURL } from 'node:url'; | ||
|
||
/** | ||
* Dynamic import wrapper for compatibility with absolute paths on Windows | ||
* | ||
* @see https://github.com/stylelint/stylelint/issues/7382 | ||
* | ||
* @param {string} path | ||
*/ | ||
export default function dynamicImport(path) { | ||
return import(isAbsolute(path) ? pathToFileURL(path).toString() : path); | ||
} |