🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

polyfills-loader

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyfills-loader - npm Package Compare versions

Comparing version

to
1.5.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.5.1](https://github.com/open-wc/open-wc/compare/polyfills-loader@1.5.0...polyfills-loader@1.5.1) (2020-03-15)
### Bug Fixes
* **polyfills-loader:** load fetch and abort controller together ([#1430](https://github.com/open-wc/open-wc/issues/1430)) ([ca29548](https://github.com/open-wc/open-wc/commit/ca2954822440dbb218420be99dfbd2df03760dbd))
# [1.5.0](https://github.com/open-wc/open-wc/compare/polyfills-loader@1.4.2...polyfills-loader@1.5.0) (2020-03-15)

@@ -8,0 +19,0 @@

4

package.json
{
"name": "polyfills-loader",
"version": "1.5.0",
"version": "1.5.1",
"publishConfig": {

@@ -56,3 +56,3 @@ "access": "public"

},
"gitHead": "be62b4a5e590a651df5d5bda4fa3ebd08bd7790c"
"gitHead": "cdf543650c8df312ee07756091faf42899d41268"
}

@@ -81,5 +81,8 @@ # Polyfills loader

fetch: true,
abortController: true,
regeneratorRuntime: true,
dynamicImport: true,
webcomponents: true,
intersectionObserver: true,
resizeObserver: true,
},

@@ -153,3 +156,5 @@ minify: true,

- [fetch](https://github.com/github/fetch)
- [intersectionObserver](https://github.com/w3c/IntersectionObserver)
- [abortController](https://github.com/github/fetch)
- [intersectionObserver](https://github.com/mo/abortcontroller-polyfill)
- [resizeObserver](https://github.com/que-etc/resize-observer-polyfill)
- [systemjs](https://github.com/systemjs/systemjs) (also injected when one of the files is systemjs)

@@ -156,0 +161,0 @@ - [dynamicImport](https://github.com/GoogleChromeLabs/dynamic-import-polyfill)

@@ -22,5 +22,4 @@ /** @typedef {import('./types').PolyfillsLoaderConfig} PolyfillsLoaderConfig */

* @param {PolyfillConfig} polyfillConfig
* @param {string} [pkg]
*/
function addPolyfillConfig(polyfillConfig, pkg) {
function addPolyfillConfig(polyfillConfig) {
try {

@@ -31,4 +30,4 @@ polyfillConfigs.push(polyfillConfig);

throw new Error(
`configured to polyfill ${polyfillConfig.name},` +
` but no polyfills found. Install with "npm i -D ${pkg || polyfillConfig.name}"`,
`[Polyfills loader]: Error resolving polyfill ${polyfillConfig.name}` +
' Are dependencies installed correctly?',
);

@@ -58,24 +57,21 @@ }

if (polyfills.fetch) {
addPolyfillConfig(
{
name: 'fetch',
test: "!('fetch' in window)",
path: require.resolve('whatwg-fetch/dist/fetch.umd.js'),
minify: true,
},
'whatwg-fetch',
);
addPolyfillConfig({
name: 'fetch',
test: `!('fetch' in window)${
polyfills.abortController
? " || !('Request' in window) || !('signal' in window.Request.prototype)"
: ''
}`,
path: polyfills.abortController
? [
require.resolve('whatwg-fetch/dist/fetch.umd.js'),
require.resolve('abortcontroller-polyfill/dist/umd-polyfill.js'),
]
: [require.resolve('whatwg-fetch/dist/fetch.umd.js')],
minify: true,
});
}
if (polyfills.abortController) {
addPolyfillConfig(
{
name: 'abort-controller',
// cannot do 'AbortController' in window, because safari 11 implements it but it's just a stub
test: "!('Request' in window) || !('signal' in window.Request.prototype)",
path: require.resolve('abortcontroller-polyfill/dist/umd-polyfill.js'),
minify: true,
},
'abortcontroller-polyfill',
);
if (polyfills.abortController && !polyfills.fetch) {
throw new Error('Cannot polyfill AbortController without fetch.');
}

@@ -147,33 +143,24 @@

if (polyfills.resizeObserver) {
addPolyfillConfig(
{
name: 'resize-observer',
test: "!('ResizeObserver' in window)",
path: require.resolve('resize-observer-polyfill/dist/ResizeObserver.global.js'),
minify: true,
},
'resize-observer-polyfill',
);
addPolyfillConfig({
name: 'resize-observer',
test: "!('ResizeObserver' in window)",
path: require.resolve('resize-observer-polyfill/dist/ResizeObserver.global.js'),
minify: true,
});
}
if (polyfills.webcomponents && !polyfills.shadyCssCustomStyle) {
addPolyfillConfig(
{
name: 'webcomponents',
test: "!('attachShadow' in Element.prototype) || !('getRootNode' in Element.prototype)",
path: require.resolve('@webcomponents/webcomponentsjs/webcomponents-bundle.js'),
},
'@webcomponents/webcomponentsjs',
);
addPolyfillConfig({
name: 'webcomponents',
test: "!('attachShadow' in Element.prototype) || !('getRootNode' in Element.prototype)",
path: require.resolve('@webcomponents/webcomponentsjs/webcomponents-bundle.js'),
});
// If a browser does not support nomodule attribute, but does support custom elements, we need
// to load the custom elements es5 adapter. This is the case for Safari 10.1
addPolyfillConfig(
{
name: 'custom-elements-es5-adapter',
test: "!('noModule' in HTMLScriptElement.prototype) && 'getRootNode' in Element.prototype",
path: require.resolve('@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'),
},
'@webcomponents/webcomponentsjs',
);
addPolyfillConfig({
name: 'custom-elements-es5-adapter',
test: "!('noModule' in HTMLScriptElement.prototype) && 'getRootNode' in Element.prototype",
path: require.resolve('@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'),
});
}

@@ -180,0 +167,0 @@