Transpile certain node_modules with Babel at Meteor-Build

So I am currently building my first Meteor/Cordova hybrid app.
I would like to use framework7, but can’t get it to work, as it is not transpiled by default.
–> Meteor, React & F7 4.2.2 - Can’t import anything

Problem is, that I am totally confused on how to tell Meteor/Babel to also transpile certain node_modules.

The following code was extracted from a (working) example of framework7 from its webpack.config.js:

  test: /\.(js|jsx)$/,
  use: 'babel-loader',
  include: [

So I need the “Meteor/Babel” Version of this webpack config so the Meteor bundler also uses Babel for these 5 node_modules and transpiles them at build.

How do I do that?

Thanks, cheers, Patrick

you can make a softlink (ln -s node_modules/framework7 imports/framework7) into your project. Meteor then will transpile these folders. maybe this works in your case

1 Like

I haven’t tried that before. Do we still import it the same way, like import {...} from 'framework7'? Or do we now need to import it from the imports folder, like import {...} from './imports/framework7'?

If you use the symlinks approach, you can import the same way, or from the link. Both will work.

Also worth noting that because this solution was annoying for various reasons (especially git doesn’t create symlinks on windows by default) another method was implemented in Meteor 1.8.2:

  • If you need to import code from node_modules that uses modern syntax beyond module syntax, it is now possible to enable recompilation for specific npm packages using the meteor.nodeModules.recompile option in your application’s package.json file. See PR #10603 for further explanation.

So you can specify the modules that need transpilation in your package.json

1 Like

will babel plugin work with recompile?