Skip to content

feat(@schematics/angular): add lazy module path fixer #14181

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

Merged
merged 1 commit into from
Apr 16, 2019
Merged

feat(@schematics/angular): add lazy module path fixer #14181

merged 1 commit into from
Apr 16, 2019

Conversation

phenomnomnominal
Copy link
Contributor

Apologies, I messed up my original PR trying to rebase stuff :/

@alexeagle could you please ping the appropriate people for help with the tests?

Sorry again!

@alan-agius4
Copy link
Collaborator

I will try to look into the test issue that you are having.

I am thinking it might be because tslint uses the actual file system. Also I am not entirely use that you can use a TypeScript tslint rule for testing.

Maybe this test can help you https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/tasks/tslint-fix/executor_spec.ts

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Apr 16, 2019

@phenomnomnominal. I did a couple of changes locally to try to get this running but it seems that the actual rule for some reason is throwing an error

[ '/tmp/devkit-host-1555415483626-20046/lazy-route.ts' ]
The 'no-lazy-module-paths' rule threw an error in '/tmp/devkit-host-1555415483626-20046/lazy-route.ts':
SyntaxError: Expected " ", "#", "*", "+", ",", ".", ":", ":first-child", ":has(", ":last-child", ":matches(", ":not(", ":nth-child(", ":nth-last-child(", ">", "[", "~" or [^ [\],():#!=><~+.] but ")" found.

Would you mind if I push the changes to your branch to at least make the lint rule run in the specs? Alternatively, you can take a look at the above link and try to make the test run :)

@phenomnomnominal
Copy link
Contributor Author

Not at all please do! I think I've spotted the bug in the rule - seems like I have an extra ) from when I split it to multiple lines to pass lint 😅

@phenomnomnominal
Copy link
Contributor Author

phenomnomnominal commented Apr 16, 2019

Okay, I think I'm actually getting closer! I have the rule running in a test I think!

@googlebot

This comment has been minimized.

@alan-agius4
Copy link
Collaborator

@phenomnomnominal, just pushed.

Note for later, kindly squash the commits :)

@googlebot

This comment has been minimized.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM.

@alexeagle PTAL

@alexeagle alexeagle added the target: major This PR is targeted for the next major release label Apr 16, 2019
@alexeagle alexeagle merged commit 77f99b5 into angular:master Apr 16, 2019
@phenomnomnominal phenomnomnominal deleted the update-lazy-module-paths-fix branch April 16, 2019 19:44
@filipesilva
Copy link
Contributor

This migration also needs to add "experimentalImportFactories": true to angular.json to make the import syntax supported in VE.

@phenomnomnominal
Copy link
Contributor Author

@filipesilva sure! Excuse my ignorance, but I guess that means a separate PR? Does the migration also need to modify the tsconfig.json file?

@filipesilva
Copy link
Contributor

Heya @phenomnomnominal! Yes that would need a separate PR. Now that I think about it, you raise a good point: the tsconfig also needs to use "module": "esnext" actually, otherwise the import won't work at all when compiling.

I think what we really need is a full e2e test to ensure all these things are happening on update.

@phenomnomnominal
Copy link
Contributor Author

Great, I will have a go at a PR 👍

@filipesilva
Copy link
Contributor

Let me know if you need help with the e2e. It will probably be a very similar to update-1.7.ts, that tests updating from this project.

The project that you want to update should have a lazy module with the string syntax and an e2e, much like this.

Then you update the project, check that import() etc etc is there, run ng e2e and ng e2e --prod, and that makes us pretty sure the update went well.

@filipesilva
Copy link
Contributor

@phenomnomnominal I had some time today and ended up doing the e2e (#14228) and removing the option overall (#14231).

@phenomnomnominal
Copy link
Contributor Author

@filipesilva oh thank you so much! I had a go with the e2e test and got stuff running but couldn't figure out how to run it against the local version of the CLI... but either way, thanks!

And removing the experimental flag seems smart since we're forcing people to use it!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants