Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = (api) => {
targets: {
node: "18.12.0",
},
exclude: ["transform-dynamic-import"],
},
],
],
Expand Down
77 changes: 56 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"fix:js": "npm run lint:js -- --fix",
"fix:prettier": "npm run lint:prettier -- --write",
"fix": "npm-run-all -l fix:js fix:prettier",
"test:only": "cross-env NODE_ENV=test jest",
"test:only": "node --experimental-vm-modules node_modules/jest-cli/bin/jest.js",
"test:watch": "npm run test:only -- --watch",
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
"pretest": "npm run lint",
Expand Down Expand Up @@ -71,7 +71,7 @@
"globals": "^16.3.0",
"husky": "^9.1.3",
"jest": "^30.0.0",
"less": "^4.2.0",
"less": "^4.6.2",
"less-plugin-glob": "^3.0.0",
"lint-staged": "^15.2.7",
"memfs": "^4.9.3",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function lessLoader(source) {
let implementation;

try {
implementation = getLessImplementation(this, options.implementation);
implementation = await getLessImplementation(this, options.implementation);
} catch (error) {
callback(error);

Expand All @@ -38,7 +38,9 @@ async function lessLoader(source) {

if (useSourceMap) {
lessOptions.sourceMap = {
sourceMapBasepath: "",
outputSourceFiles: true,
disableSourcemapAnnotation: true,
};
}

Expand Down Expand Up @@ -123,7 +125,7 @@ async function lessLoader(source) {
typeof result.map === "string" ? JSON.parse(result.map) : result.map;

if (map && useSourceMap) {
map = normalizeSourceMap(map, this.rootContext);
map = normalizeSourceMap(map);
}

callback(null, css, map);
Expand Down
7 changes: 3 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,19 @@ function normalizeSourceMap(map) {

newMap.sourceRoot = "";

// `less` returns POSIX paths, that's why we need to transform them back to native paths.

// `less` (old versions) returns POSIX paths, that's why we need to transform them back to native paths.
newMap.sources = newMap.sources.map((source) => path.normalize(source));

return newMap;
}

function getLessImplementation(loaderContext, implementation) {
async function getLessImplementation(loaderContext, implementation) {
let resolvedImplementation = implementation;

if (!implementation || typeof implementation === "string") {
const lessImplPkg = implementation || "less";

resolvedImplementation = require(lessImplPkg);
resolvedImplementation = (await import(lessImplPkg)).default;
}

return resolvedImplementation;
Expand Down
Loading
Loading