Skip to content

Commit

Permalink
feat(webpack): allow forwarding babel options from webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeekens committed Jun 10, 2021
1 parent b8efba9 commit 19ae413
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const hasJsxRuntime = require('./has-jsx-runtime');
const defaultToggleFlags = {
// Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
generateIndexHtml: true,
// Some environemnts do not require `core-js` and can hence disable
// it explicitely. This will disable `core-js` for `preset-env` and the
// `plugin-transform-runtime`.
disableCoreJs: false,
};
const defaultOptions = {
distPath: paths.distPath,
Expand Down Expand Up @@ -99,7 +103,8 @@ module.exports = function createWebpackConfigForDevelopment(options = {}) {
entry: {
app: [
require.resolve('./application-runtime'),
require.resolve('core-js/stable'),
!mergedOptions.toggleFlags.disableCoreJs &&
require.resolve('core-js/stable'),
// When using the experimental `react-refresh` integration,
// the webpack plugin takes care of injecting the dev client for us.
!hasReactRefresh &&
Expand Down Expand Up @@ -216,6 +221,7 @@ module.exports = function createWebpackConfigForDevelopment(options = {}) {
),
{
runtime: hasJsxRuntime() ? 'automatic' : 'classic',
disableCoreJs: mergedOptions.toggleFlags.disableCoreJs,
},
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const defaultToggleFlags = {
// `false` to disable any paralelism
// `int` for a specific number of CPUs
parallelism: true,
// Some environemnts do not require `core-js` and can hence disable
// it explicitely. This will disable `core-js` for `preset-env` and the
// `plugin-transform-runtime`.
disableCoreJs: false,
};
const defaultOptions = {
distPath: paths.distPath,
Expand Down Expand Up @@ -141,7 +145,8 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
entry: {
app: [
require.resolve('./application-runtime'),
require.resolve('core-js/stable'),
!mergedOptions.toggleFlags.disableCoreJs &&
require.resolve('core-js/stable'),
mergedOptions.entryPoint,
],
},
Expand Down Expand Up @@ -233,6 +238,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
),
{
runtime: hasJsxRuntime() ? 'automatic' : 'classic',
disableCoreJs: mergedOptions.toggleFlags.disableCoreJs,
},
],
],
Expand Down

0 comments on commit 19ae413

Please sign in to comment.