Skip to content

Commit

Permalink
enhance: Transform ES standards in node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Mar 22, 2021
1 parent f28d1ed commit 7c2aa68
Show file tree
Hide file tree
Showing 3 changed files with 587 additions and 185 deletions.
2 changes: 2 additions & 0 deletions packages/webpack-config-anansi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"rimraf": "^3.0.2"
},
"dependencies": {
"@babel/plugin-transform-typescript": "^7.13.0",
"@babel/preset-env": "^7.13.10",
"@linaria/webpack-loader": "^3.0.0-beta.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@svgr/webpack": "^5.5.0",
Expand Down
35 changes: 35 additions & 0 deletions packages/webpack-config-anansi/src/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,41 @@ export default function makeBaseConfig({
],
exclude: libraryExclude,
},
// transpile JS outside the app to support standard ES features
{
test: /\.m?js$/,
include: /node_modules/,
exclude: [
// \\ for Windows, \/ for Mac OS and Linux
/node_modules[\\\/](core-js|react)/,
/node_modules[\\\/]webpack[\\\/]buildin/,
/@babel(?:\/|\\{1,2})runtime/,
],
use: {
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
cacheDirectory: true,
// See https://github.com/facebook/create-react-app/issues/6846 for context
cacheCompression: false,
presets: [['@babel/preset-env', { bugfixes: true }]],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: true,
version: require('@babel/runtime/package.json').version,
},
],
],
},
},
},
{
test: /\.(md|txt)$/,
type: 'asset/source',
Expand Down
Loading

0 comments on commit 7c2aa68

Please sign in to comment.