-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Multi-line ES6 import #2175
Comments
Regex parsing for ES6 modules is causing problems in other areas. I'm going to discuss it at the meeting this afternoon to figure out options. |
@shicks am I remembering correctly that we decided to make this a one-line regex instead of multi-line for simplicity/speed? I think the style guide says not to wrap the line but projects outside of Google are likely not to follow our style guide. |
@shicks Is this just when using the deps package? It looks like the ProcessEs6Modules properly adds the deps information. |
That's right, I only came across this when relying upon the deps package result. It correctly builds providing the deps haven't been dropped. |
TBH, I really don't like the empty import workaround. The issue is indeed
with the referred-based scanning in the deps package, which does need to be
fast, since large projects with many framework dependencies can sometimes
load many thousands of files that need to be pruned without a full parse.
Given those requirements, I'm not sure what the best solution is. As Tyler
mentioned, internally we have a style rule that imports can't break
multiple lines - they're allowed to (and must) be as long as they need to
be.
One option would be to read additional lines if a line starts with import
and doesn't end with a semicolon. It's a little brittle, but so's the whole
thing already. But I'm also not sure how easy that would be given the
JsFileLineParser framework really wants to only operate on one line at a
time. We could also change the latter to just automatically read additional
lines until one ends with `;\s*($|//)`. That would allow things down a
little, but hopefully not a whole lot.
…On Nov 29, 2016 5:51 AM, "Steve Spencer" ***@***.***> wrote:
That's right, I only came across this when relying upon the deps package
result. It correctly builds providing the deps haven't been dropped.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2175 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIyG9R6PA8wE0M7pUWNTYz3bYglgHaAks5rDC35gaJpZM4K-FBw>
.
|
Alternative workaround: import { something, somethingElse, inFactAVeryLongList } from "./MyAllPurposeUtil";
import { ofLotsOfThings, whichIsUglyOnOneLine } from "./MyAllPurposeUtil"; |
Perhaps the deps parser could detect an unclosed import statement and emit a warning. |
To my knowledge, the deps package has little use outside of Google. Changing it is also difficult for an external contributor for all the reasons @shicks listed. I looked into what would be required to change this and don't have the bandwidth to tackle it. Since this doesn't affect full compilations in any way, It's not a priority for me right now. |
I realise this is a stale ticket now, but this worked with Repro:
|
This was fixed by #2641 |
This doesn't get picked up by the regex import scanning in Closure Compiler, because it assumes each statement is one per line:
https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/deps/JsFileParser.java#L41
Probably tough to fix. But also something that can be hard to diagnose.
Easy workaround:
The text was updated successfully, but these errors were encountered: