Issue: Encounter of an unexpected token (Please ensure that plugins are installed to import files that are not JavaScript) while using the rollup vue package

I am working on creating a Vue component library, but I encountered an error with my type checking. I attempted to update TypeScript as mentioned here, but it did not resolve the issue. Here is a snippet of my code and `package.json` file. My component code has been exported as a `Button`

 <template>
  button
    >{{ children }}</button>
</template>

<script lang="tsx">

declare type IconMode =
  | {
      iconMode?: "without-icon";
    }
  | {
      iconMode: "with-icon" | "icon-only";
      iconName: string;
    };
 ...
 </script>

The rollup.config.js setup is:

import commonjs from "@rollup/plugin-commonjs"; 
import vue from "rollup-plugin-vue"; 
import buble from "@rollup/plugin-buble"; 
import typescript from "@rollup/plugin-typescript";


export default {
  input: "src/index.ts",
  output: {
    name: "Button",
    exports: "named"
  },
  plugins: [
    typescript(),
    vue({
      css: true, 
      compileTemplate: true 
    }),
    commonjs()
  ]
};

Unfortunately, when running this setup, I received the following error in the terminal:

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/Components/Button.vue?vue&type=script&lang.tsx (18:8)

18  declare type IconMode =
            ^ 
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

I would greatly appreciate any assistance with resolving this issue.

Answer №1

The issue lies with the @rollup/plugin-typescript package. I recommend uninstalling @rollup/plugin-typescript and replacing it with rollup-plugin-typescript2.

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

Troubleshooting React and NodeJs Fetch Problem

I am currently working on retrieving data from my API, which is functioning properly. The API endpoint I am trying to fetch results from is http://localhost:5000/api/continents. {"data":[{"continentId":3,"CName":"Atlantis"},{"continentId":2,"CName":"Devia ...

Retrieve the value of the specific element I have entered in the ngFor loop

I've hit a wall after trying numerous solutions. Here is the code I'm working with: HTML: import { Component } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styl ...

Transferring files and folders to the Electron Distribution directory

In short: I'm looking for a way to automate the process of copying files/directories from my src folder to dist/resources when packaging using Electron-packager. This need arose because I have JSON files in folders that need to be transferred to a sp ...

A new module is unable to load Angular Material

Recently, I developed an Angular material module similar to a core module. import { NgModule} from '@angular import {MatCheckboxModule} from '@angular/material/checkbox'; @NgModule({ imports: [ MatCheckboxModule ], exports: [ ...

What is the method for showcasing an image before it has been uploaded?

I must start by apologizing for my English, as I am not the most fluent speaker. Here's where I'm facing a dilemma: I have created an application that allows users to edit questions for a game. These questions are stored on a server and can be ...

What is the best way to make a Modal triggered by a loop embedded within a table function properly on mobile devices?

While the modal is functioning properly on desktop, it seems to be encountering issues on mobile devices. The modal appears behind the background and is confined by the boundaries of the table (tbody). Below is the code snippet for triggering the modal: ...

Creating a Node.JS environment with Express and Socket.IO: A beginner's guide

Trying to set up a Node.JS server on port 3800 of my CentOS server and encountering difficulties: var app = require('express')(); var http = require('http').Server(app); app.get('/', function(req, res){ res.send('&l ...

It is not possible to submit two forms at once with only one button click without relying on JQuery

I need to figure out a way to submit two forms using a single button in next.js without relying on document.getElementById. The approach I've taken involves having two form tags and then capturing their data in two separate objects. My goal is to hav ...

Employing Isotope/jQuery for organizing posts on Tumblr in columns with the ability to infinitely scroll

Alright so, here we have the classic dilemma where scripts are running before images load. And to make matters more complicated, on Tumblr, there's no way to access image dimensions before they're loaded into the DOM... $('#thumbnails&apos ...

What is the significance of :: in AngularJS?

When reviewing certain Angular JS files, I often come across the following syntax. What is the significance of a double colon "::" in this context? <span>{{::x}}</span> <div>{{::y.z()}}</div> ...

AngularJS Alert: [$injector:unpr] Provider Not Recognized

After setting up the URL routes for the sportsStore app from an AngularJS book to learn, I'm encountering the following errors: Error: [$injector:unpr] Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirect ...

Using Vue.js: Passing an object from data() to a mounted() function

I'm facing an issue while attempting to pass the grid array to the createGridChart. An error message stating "grid is not defined" keeps popping up: “grid is not defined”. export default { data() { return { grid: [], } ...

Using the Grails asset-pipeline with an external JavaScript library

In transitioning from Grails 2 to Grails 3, I am facing the challenge of managing my JavaScript files with the asset-pipeline plugin. The issue lies in using external libraries such as globalize and ajax-solr, which are large and consist of multiple interd ...

Techniques for animating background image using jQuery

Hello there! I'm currently experimenting with animating a background image using jQuery. Despite following a tutorial, I haven't been successful in getting my test page to work as intended. The blue Facebook icon displays, but it doesn't ani ...

Trouble getting proper alignment displayed with JavaScript and CSS

If anyone has a solution for printing content in a div using JavaScript and CSS, please help. The main div with the id 'preview' contains content taken from a database using PHP and MySQL. However, the data on the print page appears vertically an ...

Encountering a high volume of requests error while attempting to retrieve data from the API using the NodeJS backend, yet functioning properly on the React

While attempting to retrieve data from https://api.solscan.io/chaininfo using a NodeJS backend application, I encountered an error stating 429: Too many requests. Interestingly, the same API functions without any issues when utilized in a React frontend a ...

What is the best way to perform an action in the database using JavaScript without needing to refresh the page

I have written a code that retrieves data from a table, with each row containing two buttons for updating the database with a fixed value and deleting the row. I am looking to perform these actions without reloading the page. Below is the table code: &l ...

JSONP callback function enables cross-domain communication by allowing a

After delving into the world of JSONP callback functions, I decided to familiarize myself with the concept by researching articles. To further understand JSONP, I uploaded a JSON file onto the server - json file Below is the JavaScript code I used to fet ...

Tips for showing or hiding the router-link button in a particular Vue.js component

Currently, I have implemented router-link as a button to switch between various components. However, I am interested in exploring ways to hide a specific component. <router-link :to="{path: prevPage }" tag="button" class="btn btn-primary"> ...

AngularJs can manipulate the visibility of elements by showing or hiding them based

I wanted to create a simple hover effect where only the child element of each <li> is displayed when I hover over it. Initially, I set up a ng-show value of false for all elements and tried to change it to true on hover. However, this caused all chil ...