Creating a Vue JS 3 Application that can smoothly operate on older versions of Firefox and Chrome

Currently, I am working on developing an application using VueJS 3, and everything seems to be functioning well on my local machine. However, I also need it to work smoothly on older browsers such as Firefox 38 and Chrome 49.

The app utilizes various "fetch" functions for loading content from APIs, authentication, sending commands, etc. After going through the resources provided in the following two links - Fetch API and Babel not Polyfilling Fetch when using babel-preset-env, I suspect there might be compatibility issues (even though it is supposed to work with CH 42). What are your thoughts on this?

In my package.json file, I have set up Babel with the following configurations:

"browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead",
    "Chrome > 48",
 ]

However, I am encountering cryptic errors in Firefox and Chrome, and I'm unsure how to transpile that function properly. My primary focus would be on Chrome 49, and here is some additional context:

It appears that the async function is supported after Chrome version 55, but the conversion process eludes me: Async Function Documentation

For instance, while testing on Chrome 49, I encountered the following console error on a specific page: webpack:///./node_modules/@vue/devtools-api/esm/proxy.js

Uncaught SyntaxError: Unexpected identifier proxy.js:94

The code snippet causing this error reads as follows:

import { HOOK_PLUGIN_SETTINGS_SET } from './const';
// ...remaining code block...

In an attempt to investigate and resolve the issue, I made modifications in different areas like vue.config.js and package.json:

vue.config.js

transpileDependencies: [
    "config",
    "vue",
    "vue-router",
    "vuex",
    "xml2js"
],

package.json

// Dependencies section with relevant libraries and versions
// DevDependencies section with various tools and plugins being used
// browserslist configuration specifying Chrome version 48

babel.config.js

module.exports = {
presets: [
  [
      '@vue/cli-plugin-babel/preset',
      {
          useBuiltIns: "usage",
          forceAllTransforms: true,
          targets: {
              "chrome": "49"
          },
      }
  ]
  ]
};

main.js

import "@babel/polyfill";
import 'core-js/stable';
import 'regenerator-runtime/runtime';
// Further imports and setup statements

Answer №1

After setting up a new Vue 3 project, incorporating async/await and fetch, I successfully built it and verified its functionality in Chrome version 48.

To demonstrate the changes made, I adjusted the hello world component as follows:

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {msg : ""}
  },
  mounted() {

    async function fetchMoviesJSON() {
      const response = await fetch('https://reqbin.com/echo/get/json');
      const movies = await response.json();
      return movies;
    }

    fetchMoviesJSON().then(data => {
      this.msg = data; // fetched movies
    });


  }
}
</script>

I specifically added "Chrome > 47" to the browserslist configuration and ensured that the necessary package was installed.

  1. Following the installation of browserslist, can you execute npx browserslist to confirm the presence of Chrome 47?
  2. Upon reviewing your error through the dev-tools, it seems likely related to the Vue dev tools setup.

Update: In addition to integrating vue router and installing the Vue dev tools, running with serve allowed me to observe the successful compilation of the proxy file without any issues.

Are you currently building in development mode?

My suggestion would be to streamline your babel plugins and attempt a simpler approach. Furthermore, please share details regarding your node/nom versions as they may potentially impact the outcome—consider updating node as suggested here.

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

Utilize Vue Component by assigning a computed property to the data source

Trying to assign a computed property value to a component's data in order to fetch and manipulate localStorage data. After mounting the component, I want to monitor changes in the localStorage. If my key is updated, I need to retrieve the new value, ...

Automatically generate the first user on the Parse Server system

Is it feasible to programmatically create a User on Parse server without the need for sign up? More information can be found at https://github.com/parse-community/parse-server We attempted this using cloud code. var user = Parse.User(); user.setUserna ...

Is the order of query execution being altered when using the MongoClient in Node.js?

I am currently developing a registration API endpoint that utilizes MongoDB to validate two specific conditions: If the username provided already exists in the database, it will return a status of 500 If the email address provided already exists in the da ...

Understanding the fundamental concepts of callbacks with Backbone.js

Currently, I am working with Backbone to send a login form to my server. Once the form is submitted and the database query is successful, a boolean value is flipped to enable GET responses from the server. However, the issue arises when it attempts to fetc ...

Smoothly animate the position of a THREE.JS Mesh

Can you help me with a question regarding three.js and x position translation of an imported .obj mesh? I'm new to three.js and looking for guidance on how to solve this issue. Basically, I have a mesh at (0,-200,0) and I want to smoothly move it to ...

JavaScript causes iPad and iPhone browsers to crash while loading images

I'm currently working on constructing an image gallery in Safari that mirrors the iPad photo app. Everything is functioning smoothly, but once I exceed around 6MB of images either by adding them to the DOM or creating new Image objects, the loading of ...

serializeArray encounters difficulty in locating certain input elements

I've created this HTML layout: <div class="col-md-12"> <div class="form-group"> <label>Mini description (displaying the latest added destinations and meta description)</label> <textarea class="for ...

Unable to modify the state with a computed setter in VueJS

In my Vue.js project, I am trying to work with a form where the end_saving value needs to be computed based on the values of start_saving and duration. To achieve this, I want to utilize the saving.end_saving property in the v-model for submission via a PO ...

Pass the pre-encoded value through Ajax

Is there a way to prevent AJAX from encoding an already encoded value when passing it through data? I'm facing this issue where my value gets further encoded. Any solutions? This is the AJAX code I'm using: $.ajax({ url: form.attr(" ...

What is the most effective method for utilizing theme colors: utilizing strings, variables, or referencing the theme object?

I recently installed eslint-plugin-sonarjs and it keeps pointing out that I am using the same string - color from palette - repeatedly. It suggests assigning it to a variable for better management. So, what approach do you think is most effective: Should ...

Is RaphaelJS truly a vector-based tool?

Is it possible to position a circle at 50% of the width of the canvas using RaphaelJS without having to calculate the exact pixel value? I am looking for a simple way to place an element at half its container's width, but I'm not sure if this can ...

What is the best way to remove Vuetify and Vue from the build process?

I am developing a custom library using VueCLI and I am looking to optimize the size of the build by excluding vuetify and vue.js from the final bundle. Currently, my final build file (*.umd.min.js) is functioning correctly with the following command: vue ...

The Axios GET call encountered an error with a status code of 404

I am currently working on developing a blog/articles application using vue.js. This app utilizes axios to retrieve data from my db.json file by making a get request. The objective is to display the selected article's content when it is clicked on from ...

Vue.JS enables the seamless addition of rows to a form on the fly

I am currently working on creating a dynamic form using Vue. The concept is that when the user clicks the add button, another row will appear for them to input data. However, I encountered an issue where initially only 1 row was set up, but when I added th ...

"Enhance your website with a dynamic animated background using Bootstrap container

I'm struggling to understand why the Bootstrap container is blocking the particles-js animation behind the text. I want the background surrounding the text to be animated as well... :/ Example Code: .gradient-bg { background: rgba(120, 87, 158, ...

Can you use curly brackets variables within a v-for loop in Vue.js?

In the dataset that I have items: [ { name: "Breakfast", comp: "breakfastItems" }, { name: "Lunch", comp: "lunchItems" }, { name: "Dinner", comp: "dinnerItems" }, { name: "Dessert", comp: "desertItems" } ] The comp p ...

Managing the completion of all processes within a forEach loop before returning the final result in Node.js

I need the forEach function to finish executing before returning the results. Currently, the function returns null values for all results because it does not wait for the forEach loop to complete. How can I resolve this issue? async function processFiles ...

Present a Java-generated JSON object on a JSP page using JavaScript

Hello, I am currently working on creating a Json object in Java and would like to display the same JSON object in JSP using JavaScript. Essentially, I am looking to add two more options in my select box using Ajax. The Ajax is being called and I can see th ...

Patience is key when using Selenium with Node.js - make sure to wait for the

Is there a way to ensure my code waits until the page is fully loaded in Node.js while using selenium-webdriver version 4.0.0? const driver = new Builder().forBrowser("firefox").build(); await driver.get("http://www.tsetmc.com/Loader.a ...

Modifying attributes for individual components in Vue.js classes

Recently, I integrated a reusable component called "LightBox" into my website, which displays images in higher resolution. The LightBox functionality is linked to each element having a thumbnail. However, I encountered an issue. There are multiple elements ...