In my code, I have a class called AnalyticsService with methods for logging analytics events to Google Analytics and Kentico. When trying to reuse this code in different projects by importing it from an npm package, I encountered a compile error related to the spread syntax.
The specific line causing the issue is:
const data = {
...options,
referrer: options.referrer || document.referrer,
url: options.url || location.href,
};
I attempted to resolve this by adding "babel-plugin-transform-object-rest-spread": "^6.23.0" to the dependencies of the npm package and including it as a plugin in the babel loader options in the webpack config file. However, the error persisted.
If anyone has experience with resolving spread syntax issues when importing npm packages or knows of a workaround to avoid using the spread syntax, particularly in the line:
const { category, action, label, value } = options;
Any insights or suggestions would be greatly appreciated.