es6-modernizr v0.9.0
ES6 Modernizr - ECMAScript 6 Feature Detection Library
What is the purpose of this project?
The main purpose of this project is to detect the compatibility of your node.js runtime with the new ECMASscript 6 features, bringing new possibilities with current build systems transpilers (see es6-tools for more information about transpilers). This way, you can detect supported (and unsupported) ES6 features in your current environment to prevent the transpilation of the whole project.
It also provides a CLI app to quickly view the compatibility of your node.js runtime and enable all V8 flags to achieve maximum compatibility.
How does it works under the hood?
When you test for a specific ES6 feature the library maps a file inside the features
folder, which usually exports/returns a boolean
. Since most ES6 features include new syntax features, they usually throw a SyntaxException
, during the evaluation process, when there is no support. So, to load the test files a require
hook is used (implemented in misc/js/require-boolean.js
). This hook exports/returns the exported/returned object by the test file, but doubly negated (implying an implicit type cast) and returns false
if an exception is thrown.
How do I install it?
If you want to use the CLI app we recommend you to install the package globally.
$ npm install -g es6-modernizr
If you want to use it as a dependency in your own project and use it at runtime.
$ npm install --save es6-modernizr
If you want to use it as a dev dependency in your own project to use as a build step.
$ npm install --save-dev es6-modernizr
If you want to install it from source.
$ https://github.com/EgaLabs/ES6-Modernizr.git
cd ES6-Modernizr
npm install -g
cd ..
rm -rf ES6-Modernizr
How do I use it? - CLI
When using the CLI app you may see yourself in any of these four situations.
You know nothing about the usage.
You don't even know how to get the typical help information. In that case, if you write something invalid, or nothing at all, after the command $ es6-modernizr
it will show you three possible actions and information to save you time (next time).
You want to see the help.
If you want to see information about the CLI app just add the --help
flag.
$ es6-modernizr --help
You want to view the compatibility of your node.js runtime.
If you want to view the compatibility of your current node.js runtime just type any of the commands below.
$ es6-modernizr view-compatibility
$ es6-modernizr view
$ es6-modernizr compatibility
$ es6-modernizr compat
You want to enable maximum compatibility of your node.js runtime.
To enable maximum compatibility with ES6 features you must source
the CLI app in order to override the node
alias. You can even use the .
(just a dot) instead of source
.
$ source es6-modernizr maximum-compatibility
$ source es6-modernizr enable-harmony
$ source es6-modernizr enable-es6
$ source es6-modernizr enable
Since "use strict"
mode may break some modules (which should not happen if they are well coded; there are some exceptions) the flag --use-strict
is not added by default to the node alias.
If you want to force all modules to run on strict mode, which enables let
and const
support in some node.js versions, you must add the --use-strict
flag to the commands above.
Known bugs.
There is a couple of known bugs in the project. Before saying anything you must better know that they are not really bugs but more like the limitations it has on Microsoft Windows.
Access denied error.
Microsoft Windows always sometimes will give you an Access denied
warning/error when trying to maximize the compatibility of your node
command using $ es6-modernizr maximum-compatibility
. The origin of this issue is the default install location of npm
packages which is under C:\Program Files\nodejs
, C:\Program Files (x86)\nodejs
or one of its subfolders. Since these folders are protected against unauthorized modifications (by non-administrators users) the temporal file used to write the necessary flags to maximize the compatibility can't be created and fails giving the Access denied
warning/error.
The solution is as simple as the issue: change the install location of npm
modules using the prefix
variable of the npmrc
file (since executing the Windows command line as administrator every time is a pain in the ass and even impossible if we are talking about embedded terminals in IDEs).
Windows DOSKEY limitations.
On platforms with an available Bash Shell
the library can be used without limitations thanks to the alias
command, which let us create a temporary node
alias containing all the possible V8
flags to enable maximum compatibility. In Windows there is no alias
command, and on top of that, the only one whose behaviour is quite the same doesn't works inside Batch
scripts (yes, I'm talking about the DOSKEY utility). So, the only way you can use the "alias" in Windows is using the temporary variable %node%
or %__node__%
.
Planning.
Add CLI app.View file here.Add Bash support.View file here.Add Batch support.View file here.Add post-install script.View file here.Add synchronous API to test ES6 features.View file here.- Add asynchronous API to test ES6 features.
- Add API to read/write test results (to know asynchronous test results using synchronous API).
Add featureView file here.Constants
.Add categoryView file here.Scoping
.Add featureView file here.Block-Scoped Variables
.Add featureView file here.Block-Scoped Functions
.Add categoryView file here.Arrow Functions
.Add featureView file here.Expression Bodies
.Add featureView file here.Statement Bodies
.Add featureView file here.Lexical this
.Add categoryView file here.Extended Parameter Handling
.Add featureView file here.Default Parameter Values
.Add featureView file here.Rest Parameters
.Add featureView file here.Spread Operator
.Add categoryView file here.Template Literals
.Add featureView file here.String Interpolation
.Add featureView file here.Custom Interpolation
.Add featureView file here.Raw String Access
.Add categoryView file here.Extended Literals
.Add featureView file here.Binary & Octal Literals
.Add featureView file here.Unicode String & RegExp Literal
.Add categoryView file here.Enhanced Regular Expressions
.- Add feature
Regular Expression Sticky Matching
. Add categoryView file here.Enhanced Object Properties
.Add featureView file here.Property Shorthand
.Add featureView file here.Computed Property Names
.Add featureView file here.Method Properties
.Add categoryView file here.Destructuring Assignment
.Add featureView file here.Array Matching
.Add featureView file here.Object Matching, Shorthand Notation
.Add featureView file here.Object Matching, Deep Matching
.Add featureView file here.Parameter Context Matching
.Add featureView file here.Fail-Soft Destructuring
.Add categoryView file here.Modules
.Add featureView file here.Value Export/Import
.Add featureView file here.Default & Wildcard
.Add categoryView file here.Classes
.Add featureView file here.Class Definition
.Add featureView file here.Class Inheritance
.- Add feature
Class Inheritance, From Expressions
. Add featureView file here.Base Class Access
.Add featureView file here.Static Members
.Add featureView file here.Getter/Setter
.Add categoryView file here.Symbol Types
.Add featureView file here.Symbol Type
.Add featureView file here.Global Symbols
.Add categoryView file here.Iterators
.Add featureView file here.Iterator & For-Of Operator
.Add categoryView file here.Generators
.Add featureView file here.Generator Function
.Add featureView file here.Generator Function, Iterator Protocol
.Add featureView file here.Generator Function, Direct Use
.Add featureView file here.Generator Matching
.- Add feature
Generator Control-Flow
(only asynchronous or read/write API). Add featureView file here.Generator Methods
.Add categoryView file here.Map/Set & WeakMap/WeakSet
.Add featureView file here.Set Data-Structure
.Add featureView file here.Map Data-Structure
.Add featureView file here.Weak-Link Data-Structures
.Add featureView file here.Typed Arrays
.Add categoryView file here.New Built-In Methods
.Add featureView file here.Object Property Assignment
.Add featureView file here.Array Element Finding
.Add featureView file here.String Repeating
.Add featureView file here.String Searching
.Add featureView file here.Number Type Checking
.Add featureView file here.Number Safety Checking
.Add featureView file here.Number Comparison
.Add featureView file here.Number Truncation
.Add featureView file here.Number Sign Determination
.Add categoryView file here.Promises
.Add featureView file here.Promise Usage
.Add featureView file here.Promise Combination
.Add categoryView file here.Meta-Programming
.Add featureView file here.Proxying
.Add featureView file here.Reflection
.Add categoryView file here.Internationalization & Localization
.Add featureView file here.Collation
.Add featureView file here.Number Formatting
.Add featureView file here.Currency Formatting
.Add featureView file here.Date/Time Formatting
.
8 years ago