Skip to content

Commit

Permalink
fix(polyfills): Ensure polyfills are loaded first (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
hscgavin committed May 17, 2018
1 parent ac0909b commit 93f0b7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions config/webpack/webpack.config.js
Expand Up @@ -130,10 +130,7 @@ const buildWebpackConfigs = builds.map(
.value();

const internalJs = [paths.src, ...paths.compilePackages];
const resolvedPolyfills = polyfills.map(polyfill => {
return require.resolve(polyfill, { paths: [process.cwd()] });
});
const entry = [...resolvedPolyfills, paths.clientEntry];
const entry = [paths.clientEntry];
const devServerEntries = [
`${require.resolve(
'webpack-dev-server/client'
Expand All @@ -144,6 +141,11 @@ const buildWebpackConfigs = builds.map(
entry.unshift(...devServerEntries);
}

const resolvedPolyfills = polyfills.map(polyfill => {
return require.resolve(polyfill, { paths: [process.cwd()] });
});
entry.unshift(...resolvedPolyfills);

const publicPath = args.script === 'start' ? '/' : paths.publicPath;

return [
Expand Down
11 changes: 6 additions & 5 deletions config/webpack/webpack.config.ssr.js
Expand Up @@ -136,11 +136,7 @@ const buildWebpackConfigs = builds.map(

const isStartScript = args.script === 'start-ssr';

const resolvedPolyfills = polyfills.map(polyfill => {
return require.resolve(polyfill, { paths: [process.cwd()] });
});

const clientEntry = [...resolvedPolyfills, paths.clientEntry];
const clientEntry = [paths.clientEntry];
const clientDevServerEntries = [
'react-hot-loader/patch',
`${require.resolve('webpack-dev-server/client')}?http://localhost:${
Expand All @@ -164,6 +160,11 @@ const buildWebpackConfigs = builds.map(
serverEntry.unshift(...serverDevServerEntries);
}

const resolvedPolyfills = polyfills.map(polyfill => {
return require.resolve(polyfill, { paths: [process.cwd()] });
});
clientEntry.unshift(...resolvedPolyfills);

return [
{
entry: clientEntry,
Expand Down

0 comments on commit 93f0b7b

Please sign in to comment.