Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@angular/platform-browser-dynamic": "6.1.0-rc.3",
"@angular/router": "6.1.0-rc.3",
"@angular/service-worker": "6.1.0-rc.3",
"@webcomponents/custom-elements": "^1.0.8",
"@webcomponents/custom-elements": "^1.2.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"rxjs": "6.2.2",
Expand Down
2 changes: 1 addition & 1 deletion aio/scripts/_payload-limits.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uncompressed": {
"runtime": 2768,
"main": 476338,
"polyfills": 38453,
"polyfills": 53922,
"prettify": 14913
}
}
Expand Down
22 changes: 0 additions & 22 deletions aio/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,6 @@

<script nomodule src="generated/ie-polyfills.min.js"></script>

<script>
//load CE polyfill
//HACK: webpack's html plugin mangles the document.write calls if we don't trick it.

//load the ES5 shim for browsers with native CE support
function loadCustomElementsShim(){
document.write('<scri' + 'pt src="assets/js/native-shim.js"><' + '/script>');
}

//load the full custom elements polyfill for browsers without support
function loadCustomElementsPolyfill(){
document.write('<scri' + 'pt src="assets/js/custom-elements.min.js"><' + '/script>');
}
//detect if we have native CE support
if(!window.customElements){
loadCustomElementsPolyfill();
}
else {
loadCustomElementsShim();
}
</script>

</head>
<body>

Expand Down
3 changes: 2 additions & 1 deletion aio/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.

import '@webcomponents/custom-elements'; // Custom Elements Polyfill
import '@webcomponents/custom-elements/src/native-shim';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this result in unnecessarily loading more code in both borwsers that don't support Custom Elements and those that do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the shim is very minimal, and it's a lot less gross than the document.write trick we're doing now. We'll revisit this when we look into shipping modern (esm/es2015) builds from CLI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, the polyfill (which is what I was more worried about) is 15K (minified), so nothing to worry about atm (with our 476K main bundle 😁).



/***************************************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions aio/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@
"@webassemblyjs/wast-parser" "1.4.3"
long "^3.2.0"

"@webcomponents/custom-elements@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@webcomponents/custom-elements/-/custom-elements-1.0.8.tgz#b7b8ef7248f7681d1ad4286a0ada5fe3c2bc7228"
"@webcomponents/custom-elements@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@webcomponents/custom-elements/-/custom-elements-1.2.0.tgz#7fc8da6c8243b15b4f69c74c65dfe2a4996c694c"

JSONStream@^1.2.1:
version "1.3.1"
Expand Down