-
Notifications
You must be signed in to change notification settings - Fork 624
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
loadChildren Regex error with angular-compilers #1956
Comments
Also, this is similar to #1930 and the same fix should solve it. |
The regex does seem to be the problem when trying to flatten to a single line. It's to do with the comma at the end of the loadChildren line. This will work (due to comma at end but tslint will moan [uneccessary trailing comma] ): This won't work (no comma after loadChildren): This will work ( as there is still a comma after loadChildren): I think the fix is a combination of modifying the regex and update the replaceDynamicLoadingCode return value to handle if a comma is present or not. I'm making do with putting loadChildren as the first property for now. |
Fixed in 0.3.2 |
Error
When trying to use AOT with loadChildren I was getting this error:
Issue
When I looked into it, it looks like the issue is with how the
app.js
code is being manipulated in theweb.browser
folder. The loadChildren lines of the code are found through a regex search. This regex result is then replaced with the dynamic loading code. In some cases it seems that this search and replace algorithm outputs something that can no longer be parsed by meteor.Steps to Reproduce
In the lazy-loading example from this project, just switch the order of
data
andloadChildren
. This results in the error that I was seeing in my project.Possible Solution
To solve this on my project I just made a local copy of
angular-compilers
and changed the regex for now. I made the following change:Was:
const LOAD_CHILDREN_REGEX = /loadChildren\s*:(\s*['"
](.*?)'"]\s*([,}]))/gm;
Now:
const LOAD_CHILDREN_REGEX = /loadChildren\s*:(\s*['"
['"]\s*)/gm;
It's a simple enough fix, so I can open up a pull request to put in this change. Before that, I wanted to make sure that everyone else agreed that this change wouldn't break any other situations that I'm not thinking about.
The text was updated successfully, but these errors were encountered: