Skip to content

Commit

Permalink
chore: 移除注释等
Browse files Browse the repository at this point in the history
  • Loading branch information
YufJi committed Feb 26, 2025
1 parent 1373dc2 commit f66e1a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
17 changes: 9 additions & 8 deletions packages/mako/src/lessLoader/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import path from 'path';
import EnhancedResolve, { type ResolveFunctionAsync } from 'enhanced-resolve';

/* eslint-disable class-methods-use-this */
const trailingSlash = /[/\\]$/;

// This somewhat changed in Less 3.x. Now the file name comes without the
// automatically added extension whereas the extension is passed in as `options.ext`.
// So, if the file name matches this regexp, we simply ignore the proposed extension.
const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/;

// `[drive_letter]:\` + `\\[server]\[share_name]\`
Expand Down Expand Up @@ -119,18 +116,22 @@ export function createLessPlugin(less: LessStatic): Less.Plugin {

try {
result = await this.resolveFilename(filename, currentDirectory);
} catch (webpackResolveError) {
} catch (_error) {
return Promise.reject(error);
}

// FIXME: need to add dependency
// addDependency(result);

return super.loadFile(result, currentDirectory, options, environment);
}

// const absoluteFilename = path.isAbsolute(result.filename)
// ? result.filename
// : path.resolve(".", result.filename);
// @ts-ignore
const absoluteFilename = path.isAbsolute(result.filename)
? result.filename
: path.resolve('.', result.filename);

// FIXME: need to add dependency
// addDependency(path.normalize(absoluteFilename));

return result;
Expand Down
17 changes: 10 additions & 7 deletions packages/mako/src/sassLoader/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ export function createImporter(
? url.fileURLToPath(context.containingUrl.toString())
: filename;

const resolver = getResolver(implementation?.compileStringAsync);
const resolver = getResolver(
typeof implementation?.compileStringAsync !== 'undefined',
);
try {
const result = await resolver(prev, originalUrl, fromImport);

// FIXME: need to add dependency
// addDependency(path.normalize(result));

return url.pathToFileURL(result) as URL;
} catch (err) {
return null;
Expand Down Expand Up @@ -71,9 +77,7 @@ export function createImporter(
};
}

function getResolver(compileStringAsync: any) {
const isModernSass = typeof compileStringAsync !== 'undefined';

function getResolver(isModernSass: boolean) {
const importResolve = EnhancedResolve.create({
conditionNames: ['sass', 'style', '...'],
mainFields: ['sass', 'style', 'main', '...'],
Expand Down Expand Up @@ -109,12 +113,12 @@ function getResolver(compileStringAsync: any) {

let resolutionMap: any[] = [];

const webpackPossibleRequests = getPossibleRequests(request, fromImport);
const possibleRequests = getPossibleRequests(request, fromImport);

resolutionMap = resolutionMap.concat({
resolve: fromImport ? importResolve : moduleResolve,
context: path.dirname(context),
possibleRequests: webpackPossibleRequests,
possibleRequests: possibleRequests,
});

return startResolving(resolutionMap);
Expand All @@ -136,7 +140,6 @@ const IS_MODULE_IMPORT =
const IS_PKG_SCHEME = /^pkg:/i;

function getPossibleRequests(url: string, fromImport: boolean) {
console.log('getPossibleRequests', url);
let request = url;

if (MODULE_REQUEST_REGEX.test(url)) {
Expand Down

0 comments on commit f66e1a8

Please sign in to comment.