So this is what I would currently do to find out what I need to specify in the import statement (xxx
below) for an atmosphere package:
import { xxx } from 'meteor/some:package';
Check the README or docs. That didn’t help for this package! But I did see that I could do a meteor add mediumeditor:mediumeditor
. More on that later!
Next, I would normally look at the api.export
statement(s) in the package.js
file in the github repo. Unfortunately, the repo has no package.js
. The README uses the npm install
command, which for Meteor I would replace with meteor npm install medium-editor --save
.
In the case of npm packages I refer to the package docs for the details: if I see var Something = require('packagename');
, I may either use the require
syntax, or replace with import Something from 'packagename';
(no braces around the variable), which I think you are already comfortable with.
Unfortunately (again), in the case of this package, the instructions require you to add script tags to your page, which led me to conclude that it’s going to define (a) global variable(s) itself. Packages like this don’t always fit into import
syntax and you will need to follow ancient rituals to add them to meteor. If you’re interested in doing this (and you should read to the end first!), you should install the package, copy the script file from the appropriate node_modules
folder into a client/compatibility/
folder within your project.
meteor npm install medium-editor --save
mkdir client/compatibility
cp node_modules/medium-editor/dist/js/medium-editor.min.js client/compatibility
That should expose MediumEditor
globally.
However, this package piqued my curiosity, so I did a meteor add mediumeditor:mediumeditor
and then looked at the code which was brought into the cache to see what was going on and I discovered a reference to Meteor’s file-scoped variables and exposing a global MediumEditor
object. That is pretty normal for what I’d expect to see, so I added this to my client/main.js:
import { MediumEditor } from 'meteor/mediumeditor:mediumeditor';
and it worked!