How to import stuff from babeled module in file executed under pure Node?



I have set of classes in separated files. For example:

export default class Class1 {}

import Class1 from '/imports/file1.js';
export default class Class1 {}

And i have cron-task in file imports/cron.js which runs in separeted Node process:
const Class2 = require('imports/file2.js');

There is error like

SyntaxError: Unexpected token import in file2.js:1
(function (exports, require, module, __filename, __dirname) { import Class1 from 'file1.js';

Problem is that I have pretty big set of modules which imports each other. I don’t like idea to rewrite entire application to “require” notation. What is best choice in such case? Transpile cron.js by Babel?


Is this a Meteor question?

If not, you may get a better response by posting in stackoverflow.


Hi, robfallows. Yep, I trying to organize some cron tasks based on code of meteor application. For example I have class which provides API to some services and I want to use that class in cron task.