in a local package to make sure that aldeed:collection2 and aldeed:simple-schema are available to the app. (SimpleSchema is a global in all files. I’m using the old directory structures without imports.)
(I know the imply line is now irrelevant in this scenario.)
and then:
meteor npm install --save simpl-schema
then, when trying to start the app, I get:
ReferenceError: SimpleSchema is not defined
for files used in the same local package. (i.e. later in the local package’s package.json file, there are things like: api.addFiles('collections/groups.js'); and in that file SimpleSchema is being used as if it’s globally available.)
Is there an easy way to make SimpleSchema a global while using aldeed:collection2@3.0.0?
I did try importing (import SimpleSchema from 'simpl-schema';) with exactly that in mind, but it was throwing some error on the server at startup about the import symbol not being recognized. Does the above have to be done within the imports directory?
You have to do an intermediary import/export file. The import as it is does not make the class global. So import simpleschema into another file, then export it under another name (‘mySS’ for eg). THEN import your custom convention for simple schema and attach THAT to the global namespace as SimpleSchema (SimpleSchema = mySS).
I tried that, but SimpleSchema still isn’t available as a global to the other files added later in the package.json. You still have to do the little import/export trick that @rd010 describes above.