Can I compile a build using browserify/babel for a specific browser version?

After reviewing compatibility tables, like the one found at , it appears that Chrome is on the verge of fully supporting ES6. This leads me to believe that I can omit certain elements during development.

var babelifyOptions = {
    presets: ['es2015', 'stage-0', 'react'],
    extensions: ['.js', '.jsx']
};

For instance, when using browserify:

browserify(browserifyOptions)
    .transform(babelify.configure(babelifyOptions))
    .bundle()
    .pipe(source('app.js'))
    .pipe(buffer())
    .pipe(gulp.dest('./dist/js'));

This adjustment should help expedite build times. Of course, transpilation will still be necessary for production builds.

However, by removing the es2015 presets, issues arise with browserify struggling to comprehend syntax such as .... While this is understandable, is there a way to configure browserify to target only Chrome? (Allowing for features supported by Chrome while excluding those not yet recognized by other browsers).

Answer №1

It seems that the issue may not lie with browserify, but rather with your version of NodeJS. NodeJS 6 was the first version to natively support many ES2015 features, although it does not include support for the new ES module system. To work around this limitation, there are several Babel presets available that can help bridge the gap. Here is a list of some presets I came across in a quick search:

Please note that I have not personally used any of these presets, so I cannot offer a specific recommendation.

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

Capture a screenshot of the icons

I'm curious about displaying specific parts of images in a React Native application. class InstaClone extends Component { render() { return( <View style={{ flex:1, width:100 + "%", height:100 + "%" }}> <View style={st ...

A Guide to Parsing JSON Data in JavaScript

I am facing an issue with the JSON received from an AJAX call. The problem lies in the unexpected '\t' after a bullet point, causing a JavaScript error in the JSON.Parse(data.d) function. Can you provide advice on how to address this situati ...

Troubleshooting problems with AngularJS placeholders on Internet Explorer 9

On my partial page, I've included a placeholder like this: <input name="name" type="text" placeholder="Enter name" ng-class="{'error':form.name.$invalid}" ng-model="Name" required /> I have also set up client side validation for the ...

React does not allow objects as a valid child element. This error occurs when an object with keys {nodeType, data, content} is found

I am encountering an issue with displaying content from Contentful on the server component. Everything is functioning correctly with no runtime errors, but I am receiving this specific error message: "Objects are not valid as a React child (found: object w ...

Ways to verify whether an array contains any of the specified objects and then store all those objects in Supabase

Perhaps the title of my question is not very clear, but I find it difficult to summarize in just one line. To provide context, it would be best to see the JavaScript query I'm making for Supabase and its response. The data: [ { title: 'Th ...

Having trouble getting CSS animations to work in Safari when triggered by JavaScript

By utilizing a basic CSS animation, I've managed to create a fade-in effect that relies on opacity. To kickstart the animation, I use JavaScript to ensure it waits until the browser finishes loading. While this method works seamlessly on Firefox and C ...

What is the best way to ensure the correct resolution order of several promises?

Exploring the realm of modern JS and diving into ECMAScript 6 Promises. Experimenting with a simple test: let slow = new Promise((resolve) => { setTimeout(function() { console.log('slow'); resolve(); }, 2000, 'slow'); }); ...

Angular - Async function does not resolve a rejected promise

Currently, my component utilizes an async method for handling file uploads. Here is an example: //component uploadPhotos = async (event: Event) => { const upload = await this.uploadService.uploadPhotos(event, this.files, this.urls); } The UploadSe ...

How can I make a POST request from one Express.js server to another Express.js server?

I am encountering an issue while trying to send a POST request from an ExpressJS server running on port 3000 to another server running on port 4000. Here is the code snippet I used: var post_options = { url: "http://172.28.49.9:4000/quizResponse", ti ...

Is there a way to divide my time during work hours using Javascript?

This is just a simple example. 9.00 - 18.00 I am looking to modify the schedule as follows: 9.00 - 10.00 10.00 - 11.00 11.00 - 12.00 12.00 - 13.00 13.00 - 14.00 14.00 - 15.00 15.00 - 16.00 16.00 - 17.00 17.00 - 18.00 The current code implementation see ...

Ways to tally the amount of views on a post

Currently, I am in the process of developing a website that features posts. I have included a 'Read more' link which expands the content upon clicking, similar to Quora. However, I am facing an issue - I need to track the total number of times th ...

Material Ui and react-router onClick event latency on handheld devices

My React application is currently using @material-ui/core v.1.2.1 and react-router 3.0.2, which I am unable to update at the moment. Whenever I click a button that handles navigation, there is a noticeable delay of around 2 seconds before it works. https: ...

Getting the Object Id from HTML and passing it back to the Controller in MVC using C#

JQuery: $("#shoppingCart").droppable( { accept: ".block", drop: function (ev, ui) { var droppedItem = $(ui.draggable).clone(); $(this).append(droppedItem); $.ajax({ type: "POST", ...

"The text() or json() methods in Javascript's fetch function never seem to resolve, leaving the operation in a perpetual

In my new nextjs 13 project, I'm attempting to perform a fetch operation (unsure if it's related to JavaScript or nextjs) and using console.logs to monitor the code execution. let url = `${BASE}/${module}/${path}`; url += "?" + ne ...

Building a React Redux project template using Visual Studio 2019 and tackling some JavaScript challenges

Seeking clarification on a JavaScript + TypeScript code snippet from the React Redux Visual Studio template. The specific class requiring explanation can be found here: https://github.com/dotnet/aspnetcore/blob/master/src/ProjectTemplates/Web.Spa.ProjectT ...

How can I execute a task following a callback function in node.js?

Is there a way to run console.log only after the callback function has finished executing? var convertFile = require('convert-file'); var source, options; source = 'Document.pdf'; options = '-f pdf -t txt -o ./Text.txt'; ca ...

What steps should I take to create a .NET/JavaScript login page that works on IE7, Chrome, Mozilla, and Safari browsers?

I am currently dealing with a .NET login page that functions perfectly in Internet Explorer 7. However, my goal is to enhance its compatibility with Chrome, Mozilla, and Safari. The login code behind looks like this: Protected Sub btnLogin_Click(ByVal se ...

The Axios GET request was not functioning properly after attempting to use Axios stream.on("data")

I am working with a backend API that has an endpoint named /subscribe, which gives back a continuous stream of data. Along with this, I have a node process, and I am utilizing axios to send a request to my backend API with a response type of "stream& ...

What is the best way to retrieve a string from a URL?

Is there a way to extract only a specific string from a URL provided by an API? For instance: I'm interested in extracting only: photo_xxx-xxx-xxx.png Any suggestions on how to split the URL starting at photo and ending at png? ...