Skip to content

Commit

Permalink
update deps and config
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar committed Jul 21, 2022
1 parent 6cea272 commit d56a769
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 91 deletions.
95 changes: 31 additions & 64 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,43 @@
const path = require('path')

const packageJSON = require(path.join(__dirname, 'package.json'))

// RedwoodJS targets Node.js 12.x because this is the default version
// for Netlify's functions.
const TARGETS_NODE = '12.16'

// Run `npx browserslist "defaults, not IE 11, not IE_Mob 11"` to see a list
// of target browsers.
const TARGETS_BROWSERS = ['defaults', 'not IE 11', 'not IE_Mob 11']

// Warning! Recommended to specify used minor core-js version, like corejs: '3.6',
// instead of corejs: '3', since with '3' it will not be injected modules
// which were added in minor core-js releases.
// https://github.com/zloirock/core-js/blob/master/README.md#babelpreset-env
const CORE_JS_VERSION = packageJSON.devDependencies['core-js']
.split('.')
.slice(0, 2)
.join('.') // Produces: 3.12, instead of 3.12.1

// We use the recommended babel configuration for monorepos, which is a base directory
// `babel.config.js` file, but then use a per-project `.babelrc.js` file.
// Learn more: https://babeljs.io/docs/en/config-files#monorepos

/** @type {import('@babel/core').TransformOptions} */
module.exports = {
targets: {
node: '16.16'
},
presets: [
[
'@babel/preset-env',
{
targets: { node: TARGETS_NODE },
useBuiltIns: 'usage',
corejs: {
version: CORE_JS_VERSION,
// List of supported proposals: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#ecmascript-proposals
proposals: true,
},
},
],
'@babel/preset-env',
'@babel/preset-react',
'@babel/typescript',
],
plugins: [
/**
* NOTE
* Experimental decorators are used in `@redwoodjs/structure`.
* https://github.com/tc39/proposal-decorators
**/
['@babel/plugin-proposal-decorators', { legacy: true }],
// The "loose" option must be the same for all three of these plugins.
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
'@babel/plugin-transform-runtime',
[
'@babel/plugin-transform-runtime',
'babel-plugin-polyfill-corejs3',
{
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#core-js-aliasing
// Setting the version here also requires `@babel/runtime-corejs3`
corejs: { version: 3, proposals: true },
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#version
// Transform-runtime assumes that @babel/runtime@7.0.0 is installed.
// Specifying the version can result in a smaller bundle size.
version: packageJSON.devDependencies['@babel/runtime-corejs3'],
method: 'usage-pure',
proposals: true,
},
],
],
overrides: [
// ** STRUCTURE PACKAGE **
{
test: [
'./packages/structure'
],
plugins: [
[
// https://github.com/tc39/proposal-decorators
'@babel/plugin-proposal-decorators',
{
legacy: true
}
]
]
},
// ** WEB PACKAGES **
{
test: [
Expand All @@ -74,16 +46,15 @@ module.exports = {
'./packages/forms/',
'./packages/web/',
],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: TARGETS_BROWSERS,
},
},
// Run `npx browserslist "defaults, not IE 11, not IE_Mob 11"` to see a list
// of target browsers.
targets: {
browsers: [
'defaults',
'not IE 11',
'not IE_Mob 11'
],
],
},
plugins: [
[
'babel-plugin-auto-import',
Expand All @@ -102,10 +73,6 @@ module.exports = {
],
},
],
// normally provided through preset-env detecting TARGET_BROWSER
// but webpack 4 has an issue with this
// see https://github.com/PaulLeCam/react-leaflet/issues/883
['@babel/plugin-proposal-nullish-coalescing-operator'],
],
},
],
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
"@babel/cli": "7.18.9",
"@babel/core": "7.18.9",
"@babel/node": "7.18.9",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.18.9",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-private-methods": "7.18.6",
"@babel/plugin-proposal-private-property-in-object": "7.18.6",
"@babel/plugin-transform-runtime": "7.18.9",
"@babel/preset-env": "7.18.9",
"@babel/preset-react": "7.18.6",
Expand All @@ -71,7 +67,7 @@
"ansi-colors": "4.1.3",
"babel-jest": "27.5.1",
"babel-plugin-auto-import": "1.1.0",
"babel-plugin-remove-code": "0.0.6",
"babel-plugin-polyfill-corejs3": "0.5.2",
"boxen": "5.1.2",
"core-js": "3.23.5",
"cypress": "9.7.0",
Expand Down
33 changes: 11 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-proposal-nullish-coalescing-operator@npm:7.18.6, @babel/plugin-proposal-nullish-coalescing-operator@npm:^7.12.1, @babel/plugin-proposal-nullish-coalescing-operator@npm:^7.13.8, @babel/plugin-proposal-nullish-coalescing-operator@npm:^7.18.6":
"@babel/plugin-proposal-nullish-coalescing-operator@npm:^7.12.1, @babel/plugin-proposal-nullish-coalescing-operator@npm:^7.13.8, @babel/plugin-proposal-nullish-coalescing-operator@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-proposal-nullish-coalescing-operator@npm:7.18.6"
dependencies:
Expand Down Expand Up @@ -11083,13 +11083,6 @@ __metadata:
languageName: node
linkType: hard

"babel-plugin-remove-code@npm:0.0.6":
version: 0.0.6
resolution: "babel-plugin-remove-code@npm:0.0.6"
checksum: e77c44d727331cfef548d1e4ea747b6afbd05e1f439addc8d81f8ec9a4766be6d2d6fa638426f9dca811a032ee24be2b691468e21ebbf08406972c9f4f77bbac
languageName: node
linkType: hard

"babel-plugin-syntax-trailing-function-commas@npm:^7.0.0-beta.0":
version: 7.0.0-beta.0
resolution: "babel-plugin-syntax-trailing-function-commas@npm:7.0.0-beta.0"
Expand Down Expand Up @@ -27280,19 +27273,15 @@ __metadata:
dependencies:
"@actions/core": 1.9.0
"@actions/exec": 1.1.1
"@babel/cli": 7.16.7
"@babel/core": 7.16.7
"@babel/node": 7.16.7
"@babel/plugin-proposal-class-properties": 7.16.7
"@babel/plugin-proposal-decorators": 7.16.7
"@babel/plugin-proposal-nullish-coalescing-operator": 7.16.7
"@babel/plugin-proposal-private-methods": 7.16.7
"@babel/plugin-proposal-private-property-in-object": 7.16.7
"@babel/plugin-transform-runtime": 7.16.7
"@babel/preset-env": 7.16.7
"@babel/preset-react": 7.16.7
"@babel/preset-typescript": 7.16.7
"@babel/runtime-corejs3": 7.16.7
"@babel/cli": 7.18.9
"@babel/core": 7.18.9
"@babel/node": 7.18.9
"@babel/plugin-proposal-decorators": 7.18.9
"@babel/plugin-transform-runtime": 7.18.9
"@babel/preset-env": 7.18.9
"@babel/preset-react": 7.18.6
"@babel/preset-typescript": 7.18.6
"@babel/runtime-corejs3": 7.18.9
"@nrwl/nx-cloud": 14.2.0
"@playwright/test": 1.23.4
"@testing-library/jest-dom": 5.16.4
Expand All @@ -27309,7 +27298,7 @@ __metadata:
ansi-colors: 4.1.3
babel-jest: 27.5.1
babel-plugin-auto-import: 1.1.0
babel-plugin-remove-code: 0.0.6
babel-plugin-polyfill-corejs3: 0.5.2
boxen: 5.1.2
core-js: 3.23.5
cypress: 9.7.0
Expand Down

0 comments on commit d56a769

Please sign in to comment.