Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tree caching in import manager #3498

Merged
merged 1 commit into from
Jun 1, 2020
Merged
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
29 changes: 8 additions & 21 deletions bin/lessc
Original file line number Diff line number Diff line change
@@ -1762,7 +1762,7 @@ contexts.Eval = /** @class */ (function () {
};
Eval.prototype.exitCalc = function () {
this.calcStack.pop();
if (!this.calcStack) {
if (!this.calcStack.length) {
this.inCalc = false;
}
};
@@ -8727,6 +8727,9 @@ var Parser = function Parser(context, imports, fileInfo) {
continue;
}
e = this.addition() || this.entity();
if (e instanceof tree.Comment) {
e = null;
}
if (e) {
entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
@@ -10141,7 +10144,6 @@ var importManager = (function (environment) {
this.context = context;
// Deprecated? Unused outside of here, could be useful.
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
}
/**
* Add an import to be imported
@@ -10163,12 +10165,6 @@ var importManager = (function (environment) {
logger.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
}
else {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root: root, options: importOptions };
}
if (e && !importManager.error) {
importManager.error = e;
}
@@ -10225,18 +10221,9 @@ var importManager = (function (environment) {
fileParsedFunc(null, contents, resolvedFilename);
}
else {
// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {
fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);
}
else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
};
var promise;
@@ -10562,7 +10549,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
* It's not clear what should / must be public and why.
*/
var initial = {
version: [3, 11, 1],
version: [3, 11, 2],
data: data,
tree: tree,
Environment: environment$1,
29 changes: 8 additions & 21 deletions dist/less.cjs.js
Original file line number Diff line number Diff line change
@@ -1758,7 +1758,7 @@ contexts.Eval = /** @class */ (function () {
};
Eval.prototype.exitCalc = function () {
this.calcStack.pop();
if (!this.calcStack) {
if (!this.calcStack.length) {
this.inCalc = false;
}
};
@@ -8723,6 +8723,9 @@ var Parser = function Parser(context, imports, fileInfo) {
continue;
}
e = this.addition() || this.entity();
if (e instanceof tree.Comment) {
e = null;
}
if (e) {
entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
@@ -10137,7 +10140,6 @@ var importManager = (function (environment) {
this.context = context;
// Deprecated? Unused outside of here, could be useful.
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
}
/**
* Add an import to be imported
@@ -10159,12 +10161,6 @@ var importManager = (function (environment) {
logger.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
}
else {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root: root, options: importOptions };
}
if (e && !importManager.error) {
importManager.error = e;
}
@@ -10221,18 +10217,9 @@ var importManager = (function (environment) {
fileParsedFunc(null, contents, resolvedFilename);
}
else {
// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {
fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);
}
else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
};
var promise;
@@ -10558,7 +10545,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
* It's not clear what should / must be public and why.
*/
var initial = {
version: [3, 11, 1],
version: [3, 11, 2],
data: data,
tree: tree,
Environment: environment$1,
31 changes: 9 additions & 22 deletions dist/less.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Less - Leaner CSS v3.11.1
* Less - Leaner CSS v3.11.2
* http://lesscss.org
*
* Copyright (c) 2009-2020, Alexis Sellier <self@cloudhead.net>
@@ -1866,7 +1866,7 @@
};
Eval.prototype.exitCalc = function () {
this.calcStack.pop();
if (!this.calcStack) {
if (!this.calcStack.length) {
this.inCalc = false;
}
};
@@ -8981,6 +8981,9 @@
continue;
}
e = this.addition() || this.entity();
if (e instanceof tree.Comment) {
e = null;
}
if (e) {
entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
@@ -10395,7 +10398,6 @@
this.context = context;
// Deprecated? Unused outside of here, could be useful.
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
}
/**
* Add an import to be imported
@@ -10417,12 +10419,6 @@
logger.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
}
else {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root: root, options: importOptions };
}
if (e && !importManager.error) {
importManager.error = e;
}
@@ -10479,18 +10475,9 @@
fileParsedFunc(null, contents, resolvedFilename);
}
else {
// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {
fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);
}
else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
};
var promise;
@@ -10816,7 +10803,7 @@
* It's not clear what should / must be public and why.
*/
var initial = {
version: [3, 11, 1],
version: [3, 11, 2],
data: data,
tree: tree,
Environment: environment,
4 changes: 2 additions & 2 deletions dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/less.min.js.map

Large diffs are not rendered by default.

24 changes: 3 additions & 21 deletions lib/less/import-manager.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@ export default environment => {
this.context = context;
// Deprecated? Unused outside of here, could be useful.
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
}

/**
@@ -52,12 +51,6 @@ export default environment => {
logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);
}
else {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root, options: importOptions };
}
if (e && !importManager.error) { importManager.error = e; }
callback(e, root, importedEqualsRoot, fullPath);
}
@@ -122,20 +115,9 @@ export default environment => {
} else if (importOptions.inline) {
fileParsedFunc(null, contents, resolvedFilename);
} else {

// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {

fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);
}
else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, (e, root) => {
fileParsedFunc(e, root, resolvedFilename);
});
}
new Parser(newEnv, importManager, newFileInfo).parse(contents, (e, root) => {
fileParsedFunc(e, root, resolvedFilename);
});
}
};
let promise;
2 changes: 1 addition & 1 deletion lib/less/index.js
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ export default (environment, fileManagers) => {
* It's not clear what should / must be public and why.
*/
const initial = {
version: [3, 11, 1],
version: [3, 11, 2],
data,
tree,
Environment,
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "3.11.1",
"version": "3.11.2",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
@@ -43,7 +43,7 @@
"errno": "^0.1.1",
"graceful-fs": "^4.1.2",
"image-size": "~0.5.0",
"make-dir":"^2.1.0",
"make-dir": "^2.1.0",
"mime": "^1.4.1",
"promise": "^7.1.1",
"request": "^2.83.0",