What is the best way to bundle a .js file containing code with the export default syntax?

I have a single .js file with the following code:

export default (vueInst, obj, events) => {
  for (const eventName of events) {
    ...
  }
}

An issue has occurred:

Error at Function.missingTransform in /node_modules/buble/dist/buble.cjs.js:376:9

This particular file is part of my custom Quasar app extension with a UI kit. However, during the yarn build process, an error occurs due to the lack of a suitable plugin to rollup this specific .js file containing the aforementioned code.

Can you suggest which plugin I should utilize to properly roll up files like this?

Below are the plugins currently included in my rollupPlugins array:

const rollupPlugins = [
  nodeResolve({
    extensions: ['.js'],
    preferBuiltins: false
  }),
  json(),
  VuePlugin(),
  buble({
    objectAssign: 'Object.assign'
  })
]

Answer №1

In my case, the root cause of the issue was located deeper within the output. I discovered that Buble was struggling to process a specific section of my code (a for loop). After rewriting it, the error disappeared.

Here is an example of the modification I made:

for (const [key, value] of Object.entries(obj)) {
    console.log(key, value);
}

Changed to:

Object.entries(obj).forEach(
    ([key, value]) => console.log(key, value)
);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display JSON data using Vue.js

Trying to display JSON file results using Vue.js, with the goal of showing the result in a value. Here is the code snippet: data () { return { fetchData: function () { var self = this; self.$http.get("/api/casetotalactivation", functio ...

Utilize axios-cache-interceptor to enforce caching of responses from axios

Is it possible to configure axios to always return a cached response with the help of axios-cache-interceptor? import axios from 'axios' import { setupCache } from 'axios-cache-interceptor' const axiosInstance = axios.create({ timeou ...

Implement a formatter function to manipulate the JSON data retrieved from a REST API within the BootstrapVue framework

My bootstrap-vue vue.js v2.6 app is receiving JSON data from a REST API. The data structure looks like this: { "fields": [ { "key": "name", "label": "name", & ...

Integrating Firebase into Vue.js 2 application using Vue CLI with webpack configuration

Recently, I started using vue-cli with a webpack template and I'm looking to integrate Firebase as my database for the Vue app. Here's how I imported Firebase into my app: Main.js //imported rest all required packages just dint mention here imp ...

Utilizing Vue3's draggable component to seamlessly incorporate items

My current project involves the use of the vue draggable package, and below you will find the complete component: <template> <div> <button class="btn btn-secondary button" @click="add">Add</button> ...

Unable to locate the root element for mounting the component in Cypress with React

I am currently testing my react app, which was created using create-react-app, with the help of cypress. Unfortunately, I encountered an error that looks like this: https://i.stack.imgur.com/xlwbo.png The error seems to be related to trying to fetch an ...

The instance is referencing the property or method "sendResetMail" during render, but it is not defined

I'm pretty new to Vue and struggling with an error message while trying to get a reset email modal working in my Vue project: The error says that the property or method "sendResetMail" is not defined on the instance but referenced during render. I ...

Flying around in every essential element within a Vue template

Recently, I made the switch to Typescript for Vue and decided to enable the Volar extension. However, after doing so, I noticed that every HTML intrinsic element (such as section and img) is now being flagged as an error: JSX element implicitly has type &a ...

Calculate the number of items displayed using v-for and a function in Vue

Is it possible to render a reactive number of elements filtered by inputs and selects in a loop component controlled by a function? <component-list v-for="(item, index) in itemsFilters()" :key="index" :propId="item.id"></component-list> The i ...

Decrease the length of a pre-authorized link

Looking for solutions to speed up the loading of a list containing pre-signed image urls. Is there a method to reduce the size of the images or accelerate their loading time? Experimented with converting images to canvases in an attempt to decrease file s ...

Add the search outcome to the input field in vue

Within this section, I have implemented an @click event <h2 @click="action(customer.id)">{{ customer.name }}</h2> My goal is to append the clicked result to the input when any result is clicked. Do you have any ideas on how to achieve this? ...

What are effective solutions for addressing the CORS Policy issue in a Vue production build?

When developing my Vue.js app with Vue-CLI, I encountered an issue with CORS Policy errors after deploying the production version on nginx. The project uses a theme with Google fonts and MapBox, and everything works fine in the development server. The C ...

proper way to delete an event listener in vue 3

I have a function that listens for viewport dimensions when the project is first mounted and also after each resize event. However, I am unsure of the correct way to remove this listener. const { createApp, onMounted, ref } = Vue; const app = createA ...

Troubleshooting issue with Chrome Vue devtools integration in WebStorm not functioning properly

The "open in editor" button in Chrome Vue devtools does not function properly with WebStorm IDE on Macbook Air M1. However, it works perfectly fine with VS Code! ...

Executing Function when Vue JS Input Loses Focus

Hey there, I have a quick question regarding Vue JS. So, on my website, I have a shopping cart feature where users can enter any quantity. The issue I'm facing is that every time a user types a digit in the input field, the save method gets triggered. ...

By utilizing custom typeRoots while continuing to export these types alongside the entry point

For my project setup, I employ rollup to bundle an associated index.d.ts (and index.js) for the entrypoint src/index.ts. Within the project structure, there exists a directory named src/types containing multiple .d.ts files. These types are globally acces ...

Uncover the solution to eliminating webpack warnings associated with incorporating the winston logger by utilizing the ContextReplacementPlugin

When running webpack on a project that includes the winston package, several warnings are generated. This is because webpack automatically includes non-javascript files due to a lazy-loading mechanism in a dependency called logform. The issue arises when ...

Incorporating a JavaScript npm module within a TypeScript webpack application

I am interested in incorporating the cesium-navigation JavaScript package into my project. The package can be installed via npm and node. However, my project utilizes webpack and TypeScript instead of plain JavaScript. Unfortunately, the package is not fou ...

Error message received when attempting to remove object in Laravel and Vue framework

My aim is to delete a record in Vue successfully. Although the deletion of records works, I am encountering an error message in the console. 405 (Method Not Allowed) The error appears in the network tab as: "exception": "Symfony\Component\ ...

Demonstrating reactivity: updating an array property based on a window event

One example scenario involves setting specific elements to have an active class by assigning the property "active" as true (using v-bind:class). This property is modified within a foreach loop, after certain conditions are met, through the method "handleSc ...