Meteor package fails to import or not supporting ES6


Hello, I’m trying to compile my own Meteor package that was forked from NPM and I’m getting SyntaxError: Unexpected reserved word

/.meteor/local/build/programs/server/packages/my_package.js:294 W20161010-07:48:30.041(2)? (STDERR) import React from 'react';

It points to the first line of one of the files that reads import React from 'react';

And I have this on the package.js

Package.onUse(function(api) {

Shouldn’t this transpile ES6 to JS? Do I need to transpile the code myself?


Based on this snippet it should work, how are you importing the npm code?


I’m trying to convert an NPM package into a Meteor package, I forked the repo from github and made changes to it.

Now I’m trying to port it, it depends on, and uses other NPM packages.

Full stack trace for the first file throwing the SyntaxError, if I comment the import it picks a different file that also has an import statement, maths is an external NPM package defined as a requirement in my root meteor’s app package.json

    (STDERR) in the root directory of your application.
    (STDERR) /Users/octohedron/Documents/App/.meteor/local/build/programs/server/packages/my_package.js:1924
    (STDERR) import { MyClass } from 'maths/dist/edit';
    (STDERR) ^^^^^^    
    (STDERR) SyntaxError: Unexpected reserved word
    (STDERR)     at Object.exports.runInThisContext (vm.js:53:16)
    (STDERR)     at /Users/octohedron/Documents/App/.meteor/local/build/programs/server/boot.js:287:30
    (STDERR)     at Array.forEach (native)
    (STDERR)     at Function._.each._.forEach (/Users/octohedron/.meteor/packages/meteor-tool/.1.4.1_1.ge5qu0++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
    (STDERR)     at /Users/octohedron/Documents/App/.meteor/local/build/programs/server/boot.js:128:5

import { MyClass } from 'maths/dist/edit'; => maths is an npm package specified in my package.json at the root of my meteor project.

Do I have to manually transpile all this code to vanilla jS to be able to use it?


Meteor doesn’t transpile anything inside node_modules so it will probably work if you just put the code directly inside the meteor package or app.


It works in /App/packages/my_package/lib/ but not in /App/packages/my_package/lib/client/.

Could it be that all folders named /client/ in meteor are treated differently even if they are in a package?

Affirmative, that was the issue.