You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Salsa - should not attempt to digest minified .js files #6675
Zhengbo Li (@zhengbli) Let's not add any more flags to the compiler unless we need to - there's plenty already.
First question is how to detect if a file is minified. One is very consistent and clear - the file ends in .min.js, the other is more a heuristic - such as the ratio of newlines to characters.
Personally I'd prefer not to go via heuristics where possible. Is detecting based on filename sufficient (i.e. how common is it to have minified JavaScript files that don't end in .min.js)?
On a second thought, this with the previous suggestion that node_modules folder should be excluded by default, might potentially contribute to some obscure behavior that the user can't understand if the settings were put in the config file. For example, for a mixed project with both js files and ts files, tsconfig.json with allowJs: true might compile to different results from jsconfig.json. Therefore even though some heuristics are true most of the time, it might be better to expose them somehow so that it is easy to identify.
Per further discussion, lets just go with ignoring files with ".min." in the name, and we can consider other heuristics if this is not sufficient.
Some examples of possible heuristics and where they might give incorrect results:
No line breaks: included license comments or preserved multi-line strings may break this.
Average line length: Small modules with a few very long lines would break this (e.g. (x == 10 || x == 100 || ...) type patterns in char unicode category checking).
Minimal use of space chars: Embedded string literals (e.g. error messages) could break this.
Perhaps if we're running it through the parser anyway we could count newlines and spaces outside of comments and strings? A more involved change, but maybe an option if the naive name check isn't sufficient.
It is probably better to do the filtering in the language service. Otherwise the project is different when editing in the editor and compiling from tsc, which might have side effects.
Bill Ticehurst (@billti) starting with the ".min.js" pattern makes sense. It doesn't cover webpack archives that look like this static/dist/main-10964a0d0cd7d21c2c2e.js one hint here for a minified file is that there is a corresponding sourcemap file: static/dist/main-10964a0d0cd7d21c2c2e.js.map (this is from the project mentioned in this comment).
I've just tested a project with webpacks and the good news is that Salsa can digest a 1.5MB webpack file, which has caused a crash with our existing JS language service.
This change also adds a default node_modules and whatever the current outDir value is (if any) to the exclude array if there is no value provides in the config file.
❓ does this change also apply to the tsconfig.json?
Activity
zhengbli commentedon Jan 27, 2016
Maybe we should have a flag like
ignoreMinifiedJsFilesfor jsconfig.json, and by default set that to true.billti commentedon Jan 28, 2016
Zhengbo Li (@zhengbli) Let's not add any more flags to the compiler unless we need to - there's plenty already.
First question is how to detect if a file is minified. One is very consistent and clear - the file ends in
.min.js, the other is more a heuristic - such as the ratio of newlines to characters.Personally I'd prefer not to go via heuristics where possible. Is detecting based on filename sufficient (i.e. how common is it to have minified JavaScript files that don't end in
.min.js)?zhengbli commentedon Jan 28, 2016
On a second thought, this with the previous suggestion that
node_modulesfolder should be excluded by default, might potentially contribute to some obscure behavior that the user can't understand if the settings were put in the config file. For example, for a mixed project with bothjsfiles andtsfiles,tsconfig.jsonwithallowJs: truemight compile to different results fromjsconfig.json. Therefore even though some heuristics are true most of the time, it might be better to expose them somehow so that it is easy to identify.billti commentedon Feb 2, 2016
Per further discussion, lets just go with ignoring files with ".min." in the name, and we can consider other heuristics if this is not sufficient.
Some examples of possible heuristics and where they might give incorrect results:
(x == 10 || x == 100 || ...)type patterns in char unicode category checking).Perhaps if we're running it through the parser anyway we could count newlines and spaces outside of comments and strings? A more involved change, but maybe an option if the naive name check isn't sufficient.
mhegazy commentedon Feb 2, 2016
who will be doing the filtering? the compiler or the server host?
zhengbli commentedon Feb 3, 2016
It is probably better to do the filtering in the language service. Otherwise the project is different when editing in the editor and compiling from
tsc, which might have side effects.mhegazy commentedon Feb 3, 2016
fair.
egamma commentedon Feb 3, 2016
Bill Ticehurst (@billti) starting with the ".min.js" pattern makes sense. It doesn't cover webpack archives that look like this
static/dist/main-10964a0d0cd7d21c2c2e.jsone hint here for a minified file is that there is a corresponding sourcemap file:static/dist/main-10964a0d0cd7d21c2c2e.js.map(this is from the project mentioned in this comment).I've just tested a project with webpacks and the good news is that Salsa can digest a 1.5MB webpack file, which has caused a crash with our existing JS language service.
billti commentedon Feb 11, 2016
Fixed in #7016.
egamma commentedon Feb 12, 2016
Bill Ticehurst (@billti) Great thanks!
We will update our docs to address.
❓ does this change also apply to the tsconfig.json?
mhegazy commentedon Feb 12, 2016
yes.