Skip to content

Commit

Permalink
Add Object.assign polyfill support (home-assistant#210)
Browse files Browse the repository at this point in the history
* Add Object.assign polyfill support

* Remove redundant polyfill check

* Use ES6 in compatibility.js
  • Loading branch information
emlove authored and balloob committed Feb 14, 2017
1 parent e570c96 commit 5207629
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions rollup/compatibility.js
Original file line number Diff line number Diff line change
@@ -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' },
],
});
7 changes: 6 additions & 1 deletion script/gen-service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions script/optimize-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 0 deletions src/compatibility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import objAssign from 'es6-object-assign';
objAssign.polyfill();
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5207629

Please sign in to comment.