Skip to content
This repository was archived by the owner on Jan 4, 2018. It is now read-only.
This repository was archived by the owner on Jan 4, 2018. It is now read-only.

leverage @webcomponents polyfills and lazy-loading #48

@Hotell

Description

@Hotell

So as I've mentioned, I've tested out skate 5.x with stable release of https://github.com/webcomponents/webcomponentsjs 1.x

It works with skate but there are few critical issues:

  • their loader is non bundling/async compliant
  • user has to use /node_modules/@webomponents/webcomponentsjs/webcomponents-loader.js within html -> big issue is that their loader relies that there will be always node_modules folder even in dist bundle ( huh ) - relative paths ehm
  • so you cannot use hashes for modules/chunks names for proper cache busting 👎
  • also in non native browsers huge HTML Imports shim is always loaded which is really unnecessary for users of skate which are using modern tools and lang features ( es6 modules -> tree shaking )

But fortunately for us, varial heelflip is a no brainer , so I wrote custom loader which we can include within this project.

If you're ok with this @treshugart I'll add it here -> so no Breaking changes, we can publish it under subpath so user can use it like : import { lazyLoadPolyfills } from '@skate/web-components/loader

here is implementation:

https://github.com/Hotell/skate-starter/pull/1/files#diff-576f47b45fccf9ab3b7a0a75876182e1

usage:

yarn add @webcomponents/webcomponentsjs
yarn add @skatejs/web-components
// polyfills.js
import { lazyLoadPolyfills } from '@skatejs/web-components/loader'

lazyLoadPolyfills().then(bootstrap);

 // app bootstrap
 function bootstrap() {
   return System.import('./main');
 }

main.jsx

import { h, render } from 'preact'
import 'custom-wc-library'

const App = ({content}) => (
  <div>
     <wc-menu/>
     <wc-content>
        {content}
      </wc-content>
     <wc-footer/>
   </div>
)

render( <App/>, root )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions