Skip to content

Commit

Permalink
transpile node_modules with babel
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-fxpig committed May 14, 2020
1 parent 1e5de96 commit a6a46c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ module.exports = function babelConfig(api) {
[
"@babel/preset-env",
{
useBuiltIns: "usage",
useBuiltIns: "entry",
targets: "cover 95%",
bugfixes: true,
corejs: 3
}
],
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

/* P O L Y F I L L S */
import "whatwg-fetch"; // eslint-disable-line
import "core-js";
import "regenerator-runtime";
/* L I B R A R I E S */
import "react-hot-loader";
import React from "react";
import ReactDOM from "react-dom";
import Select from "react-select/lib/Select";
Expand Down Expand Up @@ -34,9 +37,6 @@ if (!window.NEXTSTRAIN) {window.NEXTSTRAIN = {};}
/* google analytics */
initialiseGoogleAnalyticsIfRequired();

/* Using React Hot Loader 4 https://github.com/gaearon/react-hot-loader */


i18n
.use(initReactI18next)
.init({
Expand Down
11 changes: 7 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
// Pins all react stuff to auspice dir, and uses hot loader's dom (can be used safely in production)
"react": path.join(__dirname, 'node_modules/react'), // eslint-disable-line quote-props
"react-hot-loader": path.join(__dirname, 'node_modules/react-hot-loader'),
'react-dom': path.join(__dirname, 'node_modules/@hot-loader/react-dom')
'react-dom': path.join(__dirname, 'node_modules/@hot-loader/react-dom'),
'regenerator-runtime': path.join(__dirname, 'node_modules/regenerator-runtime'),
'core-js': path.join(__dirname, 'node_modules/core-js')
};

let extensionData;
Expand Down Expand Up @@ -68,7 +70,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
}

const entry = devMode
? ["react-hot-loader/patch", "webpack-hot-middleware/client", "./src/index"]
? ["webpack-hot-middleware/client", "./src/index"]
: ["./src/index"];

/* Where do we want the output to be saved?
Expand All @@ -95,7 +97,6 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
publicPath: "/dist/"
},
resolve: {
mainFields: ['browser', 'main', 'module'],
alias: aliasesToResolve
},
node: {
Expand All @@ -110,7 +111,9 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
{
test: /\.js$/,
loader: 'babel-loader',
include: directoriesToTransform,
exclude: [
/node_modules\/(core-js|regenerator-runtime)/
],
options: {
cwd: path.resolve(__dirname)
}
Expand Down

0 comments on commit a6a46c0

Please sign in to comment.