How do you import an AtmosphereJS package?

266 views Asked by At

Following the instructions found here for using atmosphere packages in my meteor project I still get errors when I run meteor in my meteor project.

For example referencing vsivsi:job-collection like so

import { JobCollection } from 'meteor/vsivsi:job-collection'

results in the error

app.component.ts (14,31): Cannot find module 'meteor/vsivsi:job-collection'.

What am I doing wrong?

1

There are 1 answers

3
Joe Clay On BEST ANSWER

According to the README:

The package exposes a global object JobCollection on both client and server.

In other words, the package doesn't need importing! You can just use JobCollection in your application once you've installed it. This corresponds with the line in the instructions you posted saying:

Sometimes a package will have no exports and simply have side effects when included in your app. In such cases you don’t need to import the package at all after installing.

I don't know enough about the package to know whether there's a specific reason for it using globals, or if it's just being naughty and not using modules properly.

EDIT:

As mentioned in the comments, it seems that this library doesn't include TypeScript definitions. You could write your own (if you do, please submit them as a pull request to the library so we can all use them!), but as a stopgap measure, if you add this somewhere in your application, it'll prevent the errors from occurring.

declare var JobCollection: any;

I like to have a file called definitions.d.ts in all my TypeScript projects to stuff these little bits of definition code into.