@@ -2676,11 +2676,11 @@ const makeLessWorker = (
2676
2676
}
2677
2677
2678
2678
const worker = new WorkerWithFallback (
2679
- ( ) => {
2680
- // eslint-disable-next-line no-restricted-globals -- this function runs inside a cjs worker
2681
- const fsp = require ( 'node:fs/promises' )
2682
- // eslint-disable-next-line no-restricted-globals
2683
- const path = require ( 'node:path' )
2679
+ async ( ) => {
2680
+ const [ fsp , path ] = await Promise . all ( [
2681
+ import ( 'node:fs/promises' ) ,
2682
+ import ( 'node:path' ) ,
2683
+ ] )
2684
2684
2685
2685
let ViteLessManager : any
2686
2686
const createViteLessPlugin = (
@@ -2741,8 +2741,7 @@ const makeLessWorker = (
2741
2741
additionalData : undefined
2742
2742
} ,
2743
2743
) => {
2744
- // eslint-disable-next-line no-restricted-globals -- this function runs inside a cjs worker
2745
- const nodeLess : typeof Less = require ( lessPath )
2744
+ const nodeLess : typeof Less = ( await import ( lessPath ) ) . default
2746
2745
const viteResolverPlugin = createViteLessPlugin (
2747
2746
nodeLess ,
2748
2747
options . filename ,
@@ -2787,7 +2786,9 @@ const lessProcessor = (
2787
2786
worker ?. stop ( )
2788
2787
} ,
2789
2788
async process ( environment , source , root , options , resolvers ) {
2790
- const lessPath = loadPreprocessorPath ( PreprocessLang . less , root )
2789
+ const lessPath = pathToFileURL (
2790
+ loadPreprocessorPath ( PreprocessLang . less , root ) ,
2791
+ ) . href
2791
2792
worker ??= makeLessWorker ( environment , resolvers , maxWorkers )
2792
2793
2793
2794
const { content, map : additionalMap } = await getSource (
@@ -2853,8 +2854,7 @@ const makeStylWorker = (maxWorkers: number | undefined) => {
2853
2854
additionalData : undefined
2854
2855
} ,
2855
2856
) => {
2856
- // eslint-disable-next-line no-restricted-globals -- this function runs inside a cjs worker
2857
- const nodeStylus : typeof Stylus = require ( stylusPath )
2857
+ const nodeStylus : typeof Stylus = ( await import ( stylusPath ) ) . default
2858
2858
2859
2859
const ref = nodeStylus ( content , {
2860
2860
// support @import from node dependencies by default
@@ -2907,7 +2907,9 @@ const stylProcessor = (
2907
2907
worker ?. stop ( )
2908
2908
} ,
2909
2909
async process ( _environment , source , root , options , _resolvers ) {
2910
- const stylusPath = loadPreprocessorPath ( PreprocessLang . stylus , root )
2910
+ const stylusPath = pathToFileURL (
2911
+ loadPreprocessorPath ( PreprocessLang . stylus , root ) ,
2912
+ ) . href
2911
2913
worker ??= makeStylWorker ( maxWorkers )
2912
2914
2913
2915
// Get source with preprocessor options.additionalData. Make sure a new line separator
0 commit comments