Issue with babel compilation of NPM package

I’m currently trying to use the survey-analytics package. When Meteor builds the app I’m getting the following error.

   While building for web.browser:
   node_modules/survey-analytics/fesm/survey.analytics.mjs:
   When using '@babel/plugin-transform-parameters', it's not possible to compile
   `super()` in an arrow function with default or rest parameters without
   compiling classes.
   Please add '@babel/plugin-transform-classes' to your Babel configuration. (This
   is an error on an internal node. Probably an internal error.)

I’ve installed and added the @bable/plugin-transform-classes package to my .babelrc file, but that didn’t change anything.

Any help here is appreciated.

1 Like

I don’t think Meteor supports .mjs yet. Perhaps you could get the repo and build the library for cjs: survey-analytics/rollup.config.js at 7200c59cc3bde887687f7d899bb49a4b105c862a · surveyjs/survey-analytics · GitHub

1 Like

I think is somewhat related to React Router v7 not working with Meteor

The library is actually built for both, using rollup. The main field of the package.json specifies the cjs version file path, but it has a module field that specifies the mjs version which is apparently what is being used. Changing the module key to point to the cjs file fixes that particular issue. I’m not very familiar with how choosing which to use works under the hood, but I think that if Meteor doesn’t yet support mjs, finding a way to load the main instead of the module could be helpful for a lot of libraries that transpile both. Now that the issue with survey-analytics is fixed though, I now have a new self is not defined error in one of the peer dependencies, but it’s transpiled, minified, and crashes any editor I try to open it with, so I’m not sure how to address that one. The library as a whole works when loaded into a Nextjs project.

The compatibility with the outside ecosystem is becoming an issue for Meteor which is increasingly pushing me to build with other frameworks. I have a main client that requires Next, but I have a Non-profit charity case that I use Meteor for, and take on several other smaller projects a year for which I generally push for Meteor, but it’s getting hard to justify the extra time spent finding work arounds for these kinds of issues.

2 Likes