less / less/less.js

Importing less files from a third party library crashes the build.

Open
#3,750 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

To reproduce:

  1. Create a new project folder.
  2. Run npm init -y.
  3. Install less and swiper.
  4. Create a main.less file in the root/src folder.
  5. Create a build script that runs lessc (src/)main.less output/styles.css.

Add these lines in the main.less file.

@import (less) 'swiper/less';
@import (less) 'swiper/less/navigation';
@import (less) 'swiper/less/pagination';

Current behavior:
The build script fails with the following error.

FileError: 'swiper/less' wasn't found. Tried - path\swiper-package\swiper\less.less,path\swiper-package\swiper\less.less,npm://swiper\less,npm://swiper\less.less,swiper\less.less in path\swiper-package\main.less on line 1, column 1:
1 @import (less) 'swiper/less';

Expected behavior:

Should have outputted the CSS. Not sure if this is because swiper is using exports in their package.json file.
From reports I heard at work, this works fine on Mac.

Environment information:

  • less version: 4.1.3
  • nodejs version: 16.15.0
  • operating system: Windows 10/11 x64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the npm project, src/main.less, the listed swiper imports, and the build script on Windows. Check how the import resolves the swiper package and its package.json exports, then run the build again. Done means the command emits output/styles.css containing the imported styles.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.