@@ -616,4 +616,55 @@ describe('loader', () => {
616
616
expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
617
617
expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
618
618
} ) ;
619
+
620
+ it ( 'should not add to dependencies imports with URLs' , async ( ) => {
621
+ const testId = './import-url-deps.less' ;
622
+ const compiler = getCompiler ( testId ) ;
623
+ const stats = await compile ( compiler ) ;
624
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
625
+ const codeFromLess = await getCodeFromLess ( testId ) ;
626
+ const { fileDependencies } = stats . compilation ;
627
+
628
+ validateDependencies ( fileDependencies ) ;
629
+
630
+ Array . from ( fileDependencies ) . forEach ( ( item ) => {
631
+ [ 'http' , 'https' ] . forEach ( ( protocol ) => {
632
+ expect ( item . includes ( protocol ) ) . toBe ( false ) ;
633
+ } ) ;
634
+ } ) ;
635
+
636
+ expect ( codeFromBundle . css ) . toBe ( codeFromLess . css ) ;
637
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
638
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
639
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
640
+ } ) ;
641
+
642
+ it ( 'should add path to dependencies' , async ( ) => {
643
+ // Create the file with absolute path
644
+ const file = path . resolve ( __dirname , 'fixtures' , 'generated-3.less' ) ;
645
+ const absolutePath = path . resolve ( __dirname , 'fixtures' , 'basic.less' ) ;
646
+
647
+ fs . writeFileSync ( file , `@import "${ absolutePath } ";` ) ;
648
+
649
+ const testId = './generated-3.less' ;
650
+ const compiler = getCompiler ( testId ) ;
651
+ const stats = await compile ( compiler ) ;
652
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
653
+ const { fileDependencies } = stats . compilation ;
654
+
655
+ validateDependencies ( fileDependencies ) ;
656
+
657
+ let isAddedToDependensies = false ;
658
+
659
+ Array . from ( fileDependencies ) . forEach ( ( item ) => {
660
+ if ( item === absolutePath ) {
661
+ isAddedToDependensies = true ;
662
+ }
663
+ } ) ;
664
+
665
+ expect ( isAddedToDependensies ) . toBe ( true ) ;
666
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
667
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
668
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
669
+ } ) ;
619
670
} ) ;
0 commit comments