Colum Ferry
2 min readMay 8, 2018
Photo by Pankaj Patel on Unsplash

I recently encountered a very strange problem after trying out a new feature released in the April 2018 (v1.23) update to Visual Studio Code.

My app is using Ionic 3 with Angular 4. I noticed that one of the new features of VS Code was Run Code Actions on save. The example given in the documentation referred to using it to organise Typescript / JavaScript imports.

Feeling excited to give this a go, I turned on the feature, made a few changes to the app, saved my code and ran ionic serve . Then hell broke loose.

Suddenly I was getting undefined imported by MODULE errors from Angular. I spent roughly 3 hours trying to work out what was going wrong. I looked through all my import statements, all my @NgModule definitions. I couldn’t find any issue. I even ran SonarTS to see if the static analysis might bring up some issue.

Nothing helped. I then decided to stash my changes in git, checkout a new branch, pop the changes and revert one by one, every file where VS Code cleaned up my imports.

After doing this, my app ran again without issue. From what I can tell, the organising of the imports that was done automatically caused an issue where a module was trying to use another module before it had been declared, causing it to become undefined.

TL;DR

Be careful with VS Code auto organise imports on save as it may cause dependency and module resolution issues.

Colum Ferry
Colum Ferry

Written by Colum Ferry

Software Engineer @nrwl . Co-Founder of GrammarGuru. JavaScript Enthusiast. Married with 2 amazing kids. Powered by Coffee. Opinions my own.

No responses yet