Skip to content

Commit

Permalink
Import fetch-mock package from source to avoid core-js version mismat…
Browse files Browse the repository at this point in the history
…ch errors

Currently fetch-mock ships a transpiled copy of its code for use in the browser. This requires
several Babel runtime and Core JS helpers and polyfills. However the code is transpiled using
an older version of Babel which uses core-js v2 but everything we now use depends on core-js v3.

wheresrhys/fetch-mock#419
  • Loading branch information
i-like-robots authored and fenglish committed Aug 22, 2019
1 parent 3e7751f commit baf7b69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .storybook/build-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { storiesOf } from '@storybook/react';
import * as knobsAddon from '@storybook/addon-knobs';
import { Helmet } from 'react-helmet';
import path from 'path';
import fetchMock from 'fetch-mock';

// HACK: The browser bundle for Fetch Mock implicitly depends on core-js 2.x.
// We no longer use core-js 2.x anywhere so importing the browser bundle will fail.
// </~https://github.com/wheresrhys/fetch-mock/issues/419>
import fetchMock from 'fetch-mock/src/client.js';

const defaultKnobs = () => ({});

Expand Down
3 changes: 2 additions & 1 deletion .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const xEngine = require('../packages/x-engine/src/webpack');
const CopyPlugin = require('copy-webpack-plugin');
const WritePlugin = require('write-file-webpack-plugin');

const excludePaths = [/node_modules/, /dist/];
// HACK: we need to include fetch-mock from source so it must be transpiled
const excludePaths = [/node_modules\/(?!(fetch-mock)\/)/, /dist/];

const cssCopy = fs.readdirSync(path.resolve('components')).reduce((mains, component) => {
const componentPkg = path.resolve('components', component, 'package.json');
Expand Down

0 comments on commit baf7b69

Please sign in to comment.