@bitjourney/check-es-version-webpack-plugin
Advanced tools
Comparing version 1.0.0 to 1.0.1
11
index.js
@@ -38,12 +38,9 @@ const acorn = require("acorn"); | ||
buildError({ err, source, filename }) { | ||
const { line, column } = err.loc; | ||
const sourceLine = source.split(/\n/)[line - 1]; | ||
const marker = new Array(column + 1).fill(' '); | ||
marker[column] = '^'; | ||
return new SyntaxError(`Invalid ES${this.esVersion} at ${filename}: ${err}\n${sourceLine}\n${marker}`) | ||
return new SyntaxError(`Invalid ES${this.esVersion} at ${filename}: ${err}`); | ||
} | ||
} | ||
module.exports = CheckEsVersionPlugin; | ||
module.exports = CheckEsVersionPlugin; // not recommended | ||
// `const { CheckEsVersionPlugin } = require("@bitjourney/check-es-version-webpack-plugin")` is recommended: | ||
module.exports.CheckEsVersionPlugin = CheckEsVersionPlugin; |
{ | ||
"name": "@bitjourney/check-es-version-webpack-plugin", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Webpack plugin to ensure the output results are valid in the specified ES version", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# check-es-version-webpack-plugin [![Build Status](https://travis-ci.org/bitjourney/check-es-version-webpack-plugin.svg?branch=master)](https://travis-ci.org/bitjourney/check-es-version-webpack-plugin) | ||
If your project supports IE11, you have to ensure your JavaScript bundles does not include ES2015+ syntax such as classes, async/await, and so on. | ||
This plugin checks if the ES version of the webpack outputs is compatible with the specified version. | ||
This plugin checks the ES version of the webpack outputs for classic JS engines. | ||
For example, if your project supports IE11, which supports up to ES5, you have to ensure your JavaScript bundles does not include ES2015+ syntax such as classes, async/await, and so on. | ||
@@ -12,3 +12,3 @@ ## SYNOPSIS | ||
const { CheckEsVersionPlugin } = require("check-es-version-webpack-plugin"); | ||
const { CheckEsVersionPlugin } = require("@bitjourneycheck-es-version-webpack-plugin"); | ||
@@ -22,5 +22,7 @@ const config = { | ||
// because webpack wraps the input with eval() in development mode. | ||
config.plugins.push(new CheckEsVersionPlugin({ | ||
esVersion: 5, // optional; 5 by default | ||
}); | ||
config.plugins.push( | ||
new CheckEsVersionPlugin({ | ||
esVersion: 5, | ||
}), | ||
; | ||
} | ||
@@ -35,3 +37,3 @@ | ||
That is, `acorn.parse(source, { ecmaVersion: 5 })` throws `SyntaxError` if the `source` includes ES2015 syntax like classes. | ||
That is, `acorn.parse(source, { ecmaVersion: 5 })` throws `SyntaxError` if the `source` includes ES2015 syntax. | ||
@@ -38,0 +40,0 @@ ## LICENSE |
46
6014
86