Skip to content
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

Upgrade build tools to latest versions #1350

Merged
merged 19 commits into from
Nov 15, 2018
Merged

Upgrade build tools to latest versions #1350

merged 19 commits into from
Nov 15, 2018

Conversation

malonecj
Copy link
Contributor

@malonecj malonecj commented Oct 30, 2018

Description

Build tools upgrade

  • Upgrade to Webpack 4
  • Upgrade to Babel 7
    • Auto upgrade using Babel upgrade tool
    • Added browserlist file to specify targetted browsers
    • Replace babelrc file with babel.config.js file to work with monorepo structure
    • Replace es2015 and stage2 presets with preset-env
  • Upgrade to Karma 3
  • Remove rewire from tests after upgrading to Babel 7
  • Fix tests

@malonecj malonecj changed the title Babel 7 upgrade Upgrade build tools to latest versions Oct 31, 2018
@malonecj malonecj removed the WIP label Nov 5, 2018
Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not do an extensive review but looks good in general. A few comments and questions

expect(value).toBe('autocomplete');
});
});

describe('With different props', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these tests add any value or can they be safely deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think can be deleted

babel.config.js Outdated
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-property-literals',
'@babel/plugin-transform-member-expression-literals'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that in now

]
},
{
test: /\.css$/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,6 @@
ie 11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the examples page load fine on IE11 and do the polyfills load correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do

@@ -23,45 +23,12 @@ describe('ContainerEditorWrapper', () => {
it('should create a new ContainerEditorWrapper instance wrapping the passed in component', () => {
// ACT
let ConnectedContainerEditorWrapper = ContainerEditorWrapper(FakeContainer);
const renderedComp = Enzyme.mount(<ConnectedContainerEditorWrapper />);
const renderedComp = mount(<ConnectedContainerEditorWrapper />);

// ASSERT
expect(renderedComp).toBeDefined();
Copy link
Contributor

@amanmahajan7 amanmahajan7 Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(renderedComp).toBeDefined(); can deleted as it will always be true

@@ -1,6 +1,5 @@
import getScrollbarSize from '../getScrollbarSize';
const rewire = require('rewire');
const ColumnMetrics = rewire('../ColumnMetrics');
const ColumnMetrics = require('../ColumnMetrics');
const Immutable = window.Immutable = require('immutable');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think const Immutable = window.Immutable = require('immutable'); can be deleted because of this change.

@@ -352,7 +352,7 @@ class InteractionMasks extends React.Component {
const next = this.getNextSelectedCellPositionForKeyNavAction(keyNavAction, currentPosition, cellNavigationMode);
this.checkIsAtGridBoundary(keyNavAction, next);

const { changeRowOrColumn, ...nextPos } = next;
const { ...nextPos } = next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? If this needs to be cloned then this.selectCell({ ...next}) be used directly

expect(selectedRange.bottomRight).toEqual({ idx: 3, rowIdx: 2 });
expect(selectedRange.cursorCell).toEqual({ idx: 3, rowIdx: 2 });
expect(selectedRange.startCell).toEqual({ idx: 2, rowIdx: 2 });
expect(selectedRange.topLeft).toEqual(objectMatching({ idx: 2, rowIdx: 2 }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the object being tested changed? Just figuring out the need for objectMatching

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now has a changeRowOrColumn property that it is expecting. Not sure why the tests didnt fail before. Since I'm only interested in the cell position I used objectContaining

@@ -363,7 +363,7 @@ class InteractionMasks extends React.Component {
const next = this.getNextSelectedCellPositionForKeyNavAction(keyNavAction, currentPosition, cellNavigationMode);
this.checkIsAtGridBoundary(keyNavAction, next);

const { changeRowOrColumn, ...nextPos } = next;
const { ...nextPos } = next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@@ -0,0 +1,10202 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file need to be checked it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Committed by mistake. Have removed now

@malonecj malonecj changed the base branch from master to next November 13, 2018 10:45
@malonecj malonecj changed the base branch from next to master November 14, 2018 14:47
Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Just needs catchup. Once this is merged we can look into migrating to ES modules so we can set modules: false so webpack can treeshake. One more thing I noticed, when debug is set to true in babel env, I get the following warning message

`import '@babel/polyfill'` was not found.

Not sure if it needs to be imported or not but we can work on it in a separate PR

module.exports = {
presets: [
['@babel/env', {
useBuiltIns: 'entry'}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default behavior of modules property is auto. I did not find a good explanation but seems like auto defaults to false https://github.com/babel/website/pull/1856/files

I think in our case it defaults to CJS as we still have commonjs code along with ES code. When it is set to false then webpack complains so we are good it seems but something to be aware of

'react-data-grid/dist/react-data-grid.min': ['./packages/react-data-grid/src'],
'react-data-grid-addons/dist/react-data-grid-addons.min': ['./packages/react-data-grid-addons/src'],
'react-data-grid-examples/dist/index': './packages/react-data-grid-examples/src'
'react-data-grid/dist/react-data-grid': [path.resolve('packages/react-data-grid/src')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like both react-data-grid and react-data-grid.min.js are minified.

image

@amanmahajan7 amanmahajan7 merged commit d9a4cb9 into master Nov 15, 2018
@amanmahajan7 amanmahajan7 deleted the cm-babel-7 branch November 15, 2018 15:14
rossjp pushed a commit to rossjp/react-data-grid that referenced this pull request Dec 14, 2018
* Babel 7 upgrade

* Fix lint error

* fix lint error

* Upgrade to Webpack 4

* Fix tests after Webpack and karma upgrade

* Fix tests failing in production mode

* import local

* Fix failing IE tests

* Fix lint errors

* Add babel polyfill to tests

* Add babel ployfill to dependencies

* corejs dependency

* Adress PR comments

* Fix Data.Selectors to export correct module name

* remove package.json

* Commit package0lock.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants