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
The Regex which is used to detect "import"-statements will detect import-statements within multiline-comments #1408
Comments
Yes this is the way module format detection works in SystemJS. I've added a more useful error message here in bac2cc5. |
I am getting this error in the browser : But I don't see any block comments or import statements in this file! How do I resolve this? |
@RohitRane but there is |
I faced a similar issue with comments on the import section. |
This was a particularly nasty bug and cost me a few hours. It was due to block comments around 'export' lines. I guess since all of the tickets I've found related to this seem to be closed as roughly "working as designed" the best recourse is to use a different tool. |
PRs are welcome to handle these edge cases better. Note that explicitly defining the module format for folders by meta configuration is encouraged as well. |
var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/;
This regex will detect statements like:
import { SomeThing } from "./myfile"
even in case they are wihtin a multiline-comment-block
/*
import { Something } from "./myfile"
*/
This behaviour can lead to very-hard-to-debug errors like these documented on Stackoverflow:
http://stackoverflow.com/questions/37179236/angular2-error-at-startup-of-the-app-http-localhost3000-traceur-404-not-fo/37181985#37181985
and
http://stackoverflow.com/questions/37022526/angular-2-404-traceur-not-found
EDIT:
Here a short description how this causes errors:
While working on a typescript-file wihtin an angular-project I commented out some lines of import-statements. The typescript-compiler then just copied these multiline-comments into the compiled js-files. When loading the app in the browser, systemjs would identify these import-statements in those comment-blocks and try to act on them. This leads to a hard-to-understand error-message: "404 traceur not found"
The text was updated successfully, but these errors were encountered: