Generate import statements?

I’m migrating my codebase from Meteor 1.2 to Meteor 1.3 and in the progress of rewriting all my global variables to nice import statements.

This seems like a very cumbersome process as my IDE (WebStorm) does not automatically recognizes the import paths for Meteor packages. I have to lookup and write basically everything myself.

Is there a quicker/automated process to do this? Surely I can’t be the only one who’s rewriting global variables to import statements for Meteor 1.3.

I use webstorm too and it recognizes both import statement and sources to import from.

Have you set ES6 as your JS version? Have you updated WS?

I’m on linux, what OS are you using?

I really doubt there’s any way to actually know where a module is coming from with any sense of certainty

1 Like

Thanks for your response.

I use the latest version of WebStorm on Mac and I have set my ecmascript version correctly.

When I type for example the keyword “Meteor” without having imported it, and I highlight the keyword Meteor, WebStorm does not give any suggestions for what to import. Not sure why

I think there’s a confusion here.

Webstorm does resolve imports but it does not “suggest” imports as its big brother intellij does with java.

1 Like

Thanks for your answer. I guess I’ll have to lookup all imports myself then.

1 Like

@timw it turns out webstorm does offer automatic imports.

If it cannot resolve a symbol within the file itself and is exported somewhere else, there is a red lightbulb that appears at the beginning of he file with a caret and when you click on it, you’ll see it offering possible imports!

This does not currently work for JSX components, but it is a bug and is on the roadmap for a fix!

I know this is how it works when I have filea.js and fileb.js in the same project, and I try to import a variable from filea.js into fileb.js.

However, this is not how it works for meteor packages. For example, when I write “FlowRouter” in a file, WebStorm does not suggest me to import it from the flow router package. Is there a workaround for this or do I simply wait until this is improved in WebStorm?

Hmm yeah that’s right, meteor packages don’t actually get recognized for import suggestions. Did you post a feature request, even perhaps labeling it a bug report, over at the webstorm tracker?

1 Like

@timw @muaddib @corvid

it would be awesome it you upvoted this one that I just created