-
Notifications
You must be signed in to change notification settings - Fork 4
native-shim has to be ES6 #46
Comments
@robdodson it's not CSP compliant, but we have a Webpack plugin that moves it into a conditional A big motivation here is that the barrier to entry with the polyfills is quite large in the number of polyfills, implicit depenencies (on other polyfills) and the conditional inclusion of the native shim. This requires a significant amount of domain knowledge. You and I know the reasoning behind it, but many don't, and web components don't have the best reputation in the greater communities right now. This can be attributed to spec churn, browser support and the time it's taken to get to where we are today. Complexity here would just be another thing against them. A better way might be to conditionally include the native shim, but I think we'd have to make assumptions about the path to the native shim relative to the parent it's loaded from, which can change depending on how consumers are loading or building it. Thoughts? |
yeah I agree with all the points listed here. I was actually looking into this package because I'm trying to use web components in a different framework and want to avoid as much polyfill loading complexity as possible :) It looks like the Polymer folks inject a snippet into the page https://github.com/Polymer/polymer-build/blob/master/src/custom-elements-es5-adapter.ts#L112. So they always include the shim, then that snippet decides if it's needed. If it's not, the shim is removed. But this gets away from having a simple |
You can do conditional imports. At that time we were using Webpack 1, but it might be simpler using 2. Worth a try anyway! Would be good to try this with the standard fills so they're only loaded if necessary. I'm optimistic. Once the polyfills are on NPM, we can add |
Can you point me to a conditional import example? My module skillz are weaksauce :P |
https://webpack.js.org/guides/code-splitting-async/ The only issue is that it's async, which means we might need to expose an API to do something after the polyfills are finished loading so that definitions can be registered. |
Looking at https://github.com/skatejs/web-components/blob/master/src/index.js#L16 it seems like
native-shim.js
is always required, but (as I understand it) this file must remain ES6 or it won't work in Chrome. How do you deal with a situation where the user wants to transpile these polyfills to ES5 but selectively excludenative-shim.js
?The text was updated successfully, but these errors were encountered: