My solution was to wrap the contents of the JavaScript file in a default function (look for export for ECMAScript 6 if this is unfamiliar), and then import it into Meteor.
In your JavaScript file (we'll call it "test.js"), wrap the entire contents as follows:
export default function() {
Then, at the top of your Meteor file, where you want to use this JavaScript file ("test.js" in our case), write the import at the top of the page as follows:
import test from './test.js'
Then, in the same Meteor file, you can call the entire contents of your JavaScript file using the file name, for example, calling a function:
test();
I use React inside Meteor, but the principle is the same.
source share