Add Object.assign polyfill support (#210)

* Add Object.assign polyfill support

* Remove redundant polyfill check

* Use ES6 in compatibility.js
This commit is contained in:
Adam Mills 2017-02-14 15:01:32 -05:00 committed by Paulus Schoutsen
parent e570c961e8
commit 5207629e87
6 changed files with 29 additions and 3 deletions

View File

@ -15,11 +15,13 @@
"frontend_html": "script/vulcanize.js",
"frontend_prod": "npm run js_prod && npm run frontend_html",
"frontend_demo": "npm run js_demo && npm run frontend_html",
"ru_all": "npm run ru_core && npm run ru_demo",
"ru_all": "npm run ru_core && npm run ru_compatibility && npm run ru_demo",
"ru_core": "rollup --config rollup/core.js",
"ru_compatibility": "rollup --config rollup/compatibility.js",
"ru_demo": "rollup --config rollup/demo.js",
"watch_ru_all": "npm run watch_ru_core && npm run watch_ru_demo",
"watch_ru_all": "(npm run watch_ru_core & npm run watch_ru_compatibility & npm run watch_ru_demo) && wait",
"watch_ru_core": "rollup --config rollup/core.js --watch --sourcemap inline",
"watch_ru_compatibility": "rollup --config rollup/compatibility.js --watch --sourcemap inline",
"watch_ru_demo": "rollup --config rollup/demo.js --watch --sourcemap inline",
"lint_js": "eslint src panels --ext html",
"lint_html": "ls -1 src/home-assistant.html panels/**/ha-panel-*.html | xargs polymer lint --input",
@ -32,6 +34,7 @@
},
"devDependencies": {
"bower": "^1.8.0",
"es6-object-assign": "^1.0.3",
"eslint": "^3.14.0",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-html": "^1.7.0",

8
rollup/compatibility.js Normal file
View File

@ -0,0 +1,8 @@
import config from './base-config';
export default Object.assign({}, config, {
entry: 'src/compatibility.js',
targets: [
{ dest: 'build/compatibility.js', format: 'iife' },
],
});

View File

@ -21,13 +21,18 @@ var rootDir = '..';
var panelDir = rootDir + '/panels';
var dynamicUrlToDependencies = {
'/': [rootDir + '/frontend.html', rootDir + '/core.js'],
'/': [
rootDir + '/frontend.html',
rootDir + '/core.js',
rootDir + '/compatibility.js',
],
};
var staticFingerprinted = [
'frontend.html',
'mdi.html',
'core.js',
'compatibility.js',
];
// These panels will always be registered inside HA and thus can

View File

@ -6,3 +6,7 @@ var optimizeJs = require('optimize-js');
var core = fs.readFileSync('build/core.js', 'utf-8');
core = optimizeJs(core);
fs.writeFileSync('build/core.js', core);
var compatibility = fs.readFileSync('build/compatibility.js', 'utf-8');
compatibility = optimizeJs(compatibility);
fs.writeFileSync('build/compatibility.js', compatibility);

2
src/compatibility.js Normal file
View File

@ -0,0 +1,2 @@
import objAssign from 'es6-object-assign';
objAssign.polyfill();

View File

@ -1762,6 +1762,10 @@ es6-map@^0.1.3:
es6-symbol "~3.1.0"
event-emitter "~0.3.4"
es6-object-assign@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.0.3.tgz#40a192e0fda5ee44ee8cf6f5b5d9b47cd0f69b14"
es6-promise@^2.1.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-2.3.0.tgz#96edb9f2fdb01995822b263dd8aadab6748181bc"