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.
There is no longer a "good" way to hack this functionality into the ts->proptypes generation.
| ] | ||
| }, | ||
| "useBuiltIns": process.env.NO_COREJS_POLYFILL ? false : "usage", | ||
| "corejs": "2", |
There was a problem hiding this comment.
New requirement for babel's env preset so they can maintain compatibility in the future when the default version is changed to 3.
| "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.
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.
| const source = fs.readFileSync(filepath); | ||
| const ast = babel.parse( | ||
| source, | ||
| source.toString(), |
There was a problem hiding this comment.
Buffers are no longer supported
| 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.
Without excluding, babel's transform of react-datepicker's commonjs format conflicts with webpack processing files as ES Modules and everything breaks down.
| }, deps); | ||
|
|
||
| return [state, setState]; | ||
| return [state, setState] as const; |
There was a problem hiding this comment.
the whole goal of this PR :)
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 constsyntax. Two side effects to the TS->proptypes plugin:isTSXflag, which broke the TS->proptypesforceTSXParsingcode. Instead, babel is now configured to always treattsfiles 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