Meteor 1.3 "imports/" directory contents always imported


#1

The Meteor guide 1.3 says that : " Any directory named imports/ is not loaded anywhere and files must be imported using import". I just tried putting in “imports/common/” directory a JS file that was previously automatically loaded from another directory. It still remains automatically loaded without import. Is there anything wrong in my understanding ?


#2

It’s difficult to say without seeing your code, but here a few things to check:

  • Make sure you don’t have any typos in your imports directory name (like missing an s for example).
  • Make sure you aren’t still loading the file outside of the imports directory.
  • Make sure you aren’t already loading the file from another imports based import (maybe you’re already importing it somewhere else).
  • Make sure your locally built app isn’t out of synch with your codebase somehow (you might have older eagerly loaded code somewhere within your app’s .meteor/local/build dir); you can try a meteor reset to help with this (warning: will wipe your local DB).

#3

Thanks a lot for your answer. At first glance I don’t see any problem with a qucik check of your points. The problem seems to be the same even after a meteor reset. However, I will check everything again :slight_smile: !


#4

The behaviour I see is that imports are just not run automatically, but they are parsed and loaded into modules.js at runtime. This is all well and good, but it also means you cannot just plop some test code or temporary private JS files with some passwords or sensitive information that you can swap in and out as they are going to be visible when you view source.

In addition the bug I raised at https://github.com/meteor/meteor/issues/6836 indicates that node_modules are also parsed, including devDependencies so watch out for that.