npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

check-es5-webpack-plugin

v1.0.13

Published

Checks whether the output js is ES5 compatible

Downloads

145

Readme

CheckES5WebpackPlugin

Introduction

Although most modern browsers supports some ES6 javascript runtime, it's still necessary to support those "old" browsers who DO NO SUPPORT THESE NEW FEATURES.

We are always using babel-loader to transform ES6 code to ES5 in order to make the output bundle js file ES5 compatible

It's recommended to skip babel for files from node_modules in order to make webpack compile faster.

However, more and more npm packages provide ES6 format source from module field from package.json. Meanwhile, some old webpack with old versions or with outdated webpack.config, we may by accident leave some ES6 source code from node_modules untransformed by babel-loader. Then output js may contain some ES6 code.

In other words, THE OUTPUT BUNDLE JS MIGHT NOT BE ES5 COMPATIBLE, WHICH MAY POTTENTIALLY BREAK ON SOME BROWSERS.

What does CheckES5WebpackPlugin do?

With CheckES5WebpackPlugin, every time before webpack emit js files, the plugin first detect whether the output js is ES5 compatible. If not, obvious error logs for each problematic js will be shown in the console and the compilation process will stop immediately, which will notify you something is wrong and need to be fixed.

With CheckES5WebpackPlugin, you can avoid accidentally releasing js files that are not ES5 compatible.

How it works?

Thanks to acorn's ability to parse javascript code with strict limitations, we can simulate an ES5 only parser to parse javascript. In this way, ES6 or modern javascript codes will fail to be parsed, then we know something went wrong.

Install

First Install the package in shell,

npm i check-es5-webpack-plugin -D

Usage

In your webpack config,

add the plugin as followed

const CheckES5WebpackPlugin = require('check-es5-webpack-plugin')


{
	//... other webpack configs

	plugins: [
		//... other webpack plugins

		new CheckES5WebpackPlugin()
	]
}

NOTE: You'd better make sure NO PLUGINS COME AFTER IT in your configuration, otherwise you may miss validation for further changes from other plugins.

Options

Now there is no options for this plugin. In future versions, more custom configs may be provided. Thanks