1.0.13 • Published 7 years ago

check-es5-webpack-plugin v1.0.13

Weekly downloads
46
License
ISC
Repository
github
Last release
7 years ago

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

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.6-beta1

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago