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 Apr 14, 2021
1 parent ae464d8 commit cbd4851
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 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 @@ -56,6 +56,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.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@svgr/webpack": "^5.5.0",
Expand Down
50 changes: 50 additions & 0 deletions packages/webpack-config-anansi/src/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,56 @@ 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)/,
/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,
// Babel assumes ES Modules, which isn't safe until CommonJS
// dies. This changes the behavior to assume CommonJS unless
// an `import` or `export` is present in the file.
// https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
sourceType: 'unambiguous',
presets: [
[
'@babel/preset-env',
{
bugfixes: true,
useBuiltIns: 'entry',
corejs: 3,
exclude: ['transform-typeof-symbol'],
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: true,
version: require('@babel/runtime/package.json').version,
},
],
],
},
},
},
{
test: /\.html$/,
use: [{ loader: require.resolve('html-loader') }],
Expand Down
21 changes: 17 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@
"@babel/helper-create-regexp-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13"

"@babel/preset-env@>=7", "@babel/preset-env@^7.12.1", "@babel/preset-env@^7.12.11", "@babel/preset-env@^7.13.15":
"@babel/preset-env@>=7", "@babel/preset-env@^7.12.1", "@babel/preset-env@^7.12.11", "@babel/preset-env@^7.13.10", "@babel/preset-env@^7.13.15":
version "7.13.15"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.13.15.tgz#c8a6eb584f96ecba183d3d414a83553a599f478f"
integrity sha512-D4JAPMXcxk69PKe81jRJ21/fP/uYdcTZ3hJDF5QX2HSI9bBxxYw/dumdR6dGumhjxlprHPE4XWoPaqzZUVy2MA==
Expand Down Expand Up @@ -1817,7 +1817,6 @@

"@lerna/conventional-commits@4.0.0", "@lerna/conventional-commits@https://github.com/ntucker/lerna-conventional-commits.git":
version "3.16.4"
uid "7ecf8c762aa9cfd2aeb504683ace8b12d5b3717f"
resolved "https://github.com/ntucker/lerna-conventional-commits.git#7ecf8c762aa9cfd2aeb504683ace8b12d5b3717f"
dependencies:
"@lerna/validation-error" "^3.13"
Expand Down Expand Up @@ -5882,7 +5881,16 @@ camelcase-keys@^4.0.0:
map-obj "^2.0.0"
quick-lru "^1.0.0"

camelcase-keys@^6.0.0, camelcase-keys@^6.2.2:
camelcase-keys@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.0.0.tgz#12a07a6f50189213c3e8626c4069e28b997d01d1"
integrity sha512-NW1C7M9/uDZlfDP0+pWv0yAtgni7AZ9bYKtWgIfJylNXUFfis2BxsX3lCVuZE12wtRePEfJjnG6T9CnMohEybw==
dependencies:
camelcase "^5.3.1"
map-obj "^4.0.0"
quick-lru "^4.0.1"

camelcase-keys@^6.2.2:
version "6.2.2"
resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0"
integrity sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==
Expand Down Expand Up @@ -12104,7 +12112,12 @@ lodash.uniq@4.5.0, lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.2.1, lodash@~4.17.10:
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@~4.17.10:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

lodash@^4.17.21, lodash@^4.2.1:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down

0 comments on commit cbd4851

Please sign in to comment.