Npm package.json undocumented keys
I see some undocumented keys in package.json in Angular source 2/4:
{
"name": "@angular/platform-browser/animations",
"typings": "../animations.d.ts",
"main": "../bundles/platform-browser-animations.umd.js",
"module": "../@angular/platform-browser/animations.es5.js",
"es2015": "../@angular/platform-browser/animations.js"
}
In particular, "modules" and "es2015". I find them on all Angular packages. I am wondering how they will decide whether to load "main", "modules" or "es2015", in particular because it always loads "module" (instead of "es2015"). Is there a way to get my projects to use the es2015 file from package.json?
+3
source to share
1 answer
About fields
-
typings
- TypeScript type signatures -
module
- according to the original proposal, it should point to a module with module syntaxES2015
, but otherwise only syntax functions supported by target environments. Angular for whatever reason use.es5
notes6
akaES2015
-
ES2015
- untranslated ES6 code. Angular introduced (don't know of any tool that supports it)
More information on unofficial package.json fields
see the repository...
Is there a way to get my projects to use the es2015 file from package.json?
Not sure which package and / or transpiler you are using. If you are using Webpack you can customize it withresolve.mainFields
module.exports = {
resolve: {
mainFields: ['es2015', 'browser', 'module', 'main'],
},
···
};
0
source to share