mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
commit
61ff1a70f2
@ -82,6 +82,7 @@
|
||||
"shelljs": "^0.8.3",
|
||||
"style-loader": "^0.23.1",
|
||||
"terser-webpack-plugin": "^1.2.4",
|
||||
"unfetch": "^4.1.0",
|
||||
"url-loader": "^2.0.1",
|
||||
"util-deprecate": "^1.0.2",
|
||||
"webpack": "^4.33.0",
|
||||
|
17
lib/core/src/client/manager/conditional-polyfills.js
Normal file
17
lib/core/src/client/manager/conditional-polyfills.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { window } from 'global';
|
||||
|
||||
export const importPolyfills = () => {
|
||||
const polyfills = [];
|
||||
|
||||
if (!window.fetch) {
|
||||
// manually patch window.fetch;
|
||||
// see issue: <https://github.com/developit/unfetch/issues/101#issuecomment-454451035>
|
||||
const patch = ({ default: fetch }) => {
|
||||
window.fetch = fetch;
|
||||
};
|
||||
|
||||
polyfills.push(import('unfetch/dist/unfetch').then(patch));
|
||||
}
|
||||
|
||||
return Promise.all(polyfills);
|
||||
};
|
@ -1,6 +1,9 @@
|
||||
import { document } from 'global';
|
||||
import renderStorybookUI from '@storybook/ui';
|
||||
import Provider from './provider';
|
||||
import { importPolyfills } from './conditional-polyfills';
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
renderStorybookUI(rootEl, new Provider());
|
||||
importPolyfills().then(() => {
|
||||
const rootEl = document.getElementById('root');
|
||||
renderStorybookUI(rootEl, new Provider());
|
||||
});
|
||||
|
@ -29105,6 +29105,11 @@ undertaker@^1.2.1:
|
||||
object.reduce "^1.0.0"
|
||||
undertaker-registry "^1.0.0"
|
||||
|
||||
unfetch@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db"
|
||||
integrity sha512-crP/n3eAPUJxZXM9T80/yv0YhkTEx2K1D3h7D1AJM6fzsWZrxdyRuLN0JH/dkZh1LNH8LxCnBzoPFCPbb2iGpg==
|
||||
|
||||
unherit@^1.0.4:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.2.tgz#14f1f397253ee4ec95cec167762e77df83678449"
|
||||
|
Loading…
x
Reference in New Issue
Block a user