-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow as const syntax in tests #2733
Allow as const syntax in tests #2733
Conversation
"modules": process.env.BABEL_MODULES ? process.env.BABEL_MODULES : "commonjs" // babel's default is commonjs | ||
}], | ||
"@babel/typescript", | ||
["@babel/typescript", { isTSX: true, allExtensions: true }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no longer a "good" way to hack this functionality into the ts->proptypes generation.
@@ -14,9 +14,10 @@ module.exports = { | |||
] | |||
}, | |||
"useBuiltIns": process.env.NO_COREJS_POLYFILL ? false : "usage", | |||
"corejs": "2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New requirement for babel's env
preset so they can maintain compatibility in the future when the default version is changed to 3
.
@@ -9,10 +9,10 @@ | |||
"docker_image": "node:10", | |||
"sideEffects": false, | |||
"scripts": { | |||
"start": "webpack-dev-server --port 8030 --inline --hot --config=src-docs/webpack.config.js", | |||
"start": "BABEL_MODULES=false webpack-dev-server --port 8030 --inline --hot --config=src-docs/webpack.config.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the builds require BABEL_MODULES=false
except the lib
target. Babel now converts dynamic import()
statements to commonjs require
statements, which webpack doesn't fully comprehend and is over-eager in what types of files to prepare.
@@ -56,7 +56,7 @@ function handleJSXPath(path) { | |||
function traverseFile(filepath) { | |||
const source = fs.readFileSync(filepath); | |||
const ast = babel.parse( | |||
source, | |||
source.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffers are no longer supported
@@ -41,7 +41,7 @@ const webpackConfig = { | |||
{ | |||
test: /\.(js|tsx?)$/, | |||
loaders: useCache(['babel-loader']), // eslint-disable-line react-hooks/rules-of-hooks | |||
exclude: /node_modules/, | |||
exclude: [/node_modules/, /packages\/react-datepicker/], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without excluding, babel's transform of react-datepicker's commonjs format conflicts with webpack processing files as ES Modules and everything breaks down.
@@ -22,5 +22,5 @@ export function useDependentState<T>( | |||
// eslint-disable-next-line react-hooks/exhaustive-deps | |||
}, deps); | |||
|
|||
return [state, setState]; | |||
return [state, setState] as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole goal of this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for the annotations
Successfully tested this out with a local branch that previously failed the test suite due to as const
use.
looking into why this breaks the build step
Summary
Unblocks #2717
Upgrades the babel packages to their latest versions, allowing for our jest & build setup to support
as const
syntax. Two side effects to the TS->proptypes plugin:isTSX
flag, which broke the TS->proptypesforceTSXParsing
code. Instead, babel is now configured to always treatts
files astsx
.Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation examples- [ ] Checked for accessibility including keyboard-only and screenreader modes- [ ] A changelog entry exists and is marked appropriately