Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

refactor: move translation, connection, query to core #729

Merged
merged 9 commits into from
Aug 11, 2020

Conversation

ktmud
Copy link
Contributor

@ktmud ktmud commented Aug 10, 2020

🏠 Internal

Follow up of #728 .

Started with merging connection and query into core, because they are closely related. Ended up with moving translation as well because it was used in test/setup.js.

@ktmud ktmud requested a review from a team as a code owner August 10, 2020 19:37
@vercel
Copy link

vercel bot commented Aug 10, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/superset/superset-ui/o09ba5wtp
✅ Preview: https://superset-ui-git-fork-ktmud-monopackage-move-connection.superset.vercel.app

@@ -18,7 +18,7 @@
* under the License.
*/
import React, { ReactNode, ReactText, ReactElement } from 'react';
import { QueryFormData } from '@superset-ui/query';
import { QueryFormData } from '@superset-ui/core/lib/query';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test files uses src/, cross-package references use lib/.

@@ -3,6 +3,7 @@ export default function rejectAfterTimeout<T>(timeout: number) {
return new Promise<T>((resolve, reject) => {
setTimeout(
() =>
// eslint-disable-next-line prefer-promise-reject-errors
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously disabled in packages/superset-ui/connection/.eslintrc.

docs/debugging.md Outdated Show resolved Hide resolved
@kristw
Copy link
Contributor

kristw commented Aug 10, 2020

Now that they are combined into one package you could export everything that used to be a top-level export from query and connection as top-level export from @superset-ui/core so there is no need for the deep import (/lib/xxx).

export * from './query`
export * from './connection`

@@ -35,6 +35,6 @@
"peerDependencies": {
"@superset-ui/chart": "^0.14.0",
"@superset-ui/color": "^0.14.0",
"@superset-ui/translation": "^0.14.0"
"@superset-ui/core": "^0.15.0"
Copy link
Member

Choose a reason for hiding this comment

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

Is the intention to release 0.15 once this is merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@ktmud
Copy link
Contributor Author

ktmud commented Aug 10, 2020

Now that they are combined into one package you could export everything that used to be a top-level export from query and connection as top-level export from @superset-ui/core so there is no need for the deep import (/lib/xxx).

export * from './query`
export * from './connection`

I'd rather fix this in another PR since there may be export conflicts.

@kristw
Copy link
Contributor

kristw commented Aug 10, 2020

I'd rather fix this in another PR since there may be export conflicts.

I don't think there is. The @superset-ui/superset-ui package already did this and there was no naming conflict. (vscode will also warn if you did multiple export * and there are naming conflicts) Then you can remove all the import lib/ changes too.

@@ -5,7 +5,7 @@ import { mount, shallow } from 'enzyme';
jest.mock('resize-observer-polyfill');
// @ts-ignore
import { triggerResizeObserver } from 'resize-observer-polyfill';
import { promiseTimeout } from '@superset-ui/core';
import { promiseTimeout } from '@superset-ui/core/src';
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 need src?
It did not need this previously.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

But this is not the test for that function or package. @superset-ui/core is only a dependency.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test the WithLegend component and only use promiseTimeout for facilitating the test, not testing promiseTimeout itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense. I removed src for other packages.

@@ -44,7 +44,7 @@ requests from domains outside your `Apache Superset` instance:
configuration in the `@superset-ui` storybook.

```javascript
import { SupersetClient } from '@superset-ui/connection';
import { SupersetClient } from '@superset-ui/core/src';
Copy link
Contributor

Choose a reason for hiding this comment

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

remove /src

@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file */
import React from 'react';
import { QueryFormData } from '@superset-ui/query';
import { QueryFormData } from '@superset-ui/core/src';
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto. /src probably not needed?

test/setup.ts Outdated
@@ -1,4 +1,4 @@
import { configure } from '@superset-ui/translation';
import { configure } from '@superset-ui/core/src/translation';
Copy link
Contributor

Choose a reason for hiding this comment

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

remove /src/translation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

import { configure } from '@superset-ui' feels unclear to me. It's not clear what does it configure. Might change it to use the same pattern as connection/SupersetClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But maybe in another PR.

@kristw
Copy link
Contributor

kristw commented Aug 10, 2020

Thank you for doing the massive work

package.json Outdated
@@ -24,7 +24,7 @@
"prettier": "nimbus prettier",
"test": "yarn jest",
"test:watch": "yarn lint:fix && yarn jest --watch",
"type": "nimbus typescript --build --reference-workspaces",
"type": "yarn build \"*\" --type-only",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very nice change here. See build.js for details.

import { configure } from '@superset-ui/translation';
import categoricalD3 from '@superset-ui/color/lib/colorSchemes/categorical/d3';
import sequentialCommon from '@superset-ui/color/lib/colorSchemes/sequential/common';
import sequentialD3 from '@superset-ui/color/lib/colorSchemes/sequential/d3';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not generating esm files any more, since the content is identical to lib (checked multiple random files).

Copy link
Contributor

@kristw kristw Aug 11, 2020

Choose a reason for hiding this comment

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

I dig a bit deeper and found that last time I modified babel config there was a mistake so both esm building and commonjs (lib) ended up pointing to same babel config so the esm output now is not correctly built.

We should fix this (not in this PR, but just don't drop esm) so the esm output will be different from lib and using import/export instead of exports.xxx. The esm output should be more preferred for webpack than lib.

So, what we've learned is that in order to take advantage of tree shaking, you must...

  • Use ES2015 module syntax (i.e. import and export).
  • Ensure no compilers transform your ES2015 module syntax into CommonJS modules (this is the default behavior > of the popular Babel preset @babel/preset-env - see the documentation for more details).
  • Add a "sideEffects" property to your project's package.json file.

from webpack doc https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects

Example of esm vs lib output

Pasted_Image_8_11_20__3_09_PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a fix in my branch: 18b05b1

"testEnvironment": "node"
}
]
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Configs still generated by nimbus, we just don't re-generate it every time CI needs to run.

Missing EOF new line is from nimbus, decided not to reformat since this file may be overridden again anyway.

@ktmud
Copy link
Contributor Author

ktmud commented Aug 11, 2020

@kristw @suddjian I think this is ready for merge. A major update from yesterday is moving away from nimbus test/build runners and the updated build script. Please take another look if you have time.

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for tackling this!

@ktmud ktmud merged commit 618235f into apache-superset:monopackage Aug 11, 2020
ktmud added a commit to ktmud/superset-ui that referenced this pull request Aug 26, 2020
ktmud added a commit to ktmud/superset-ui that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (apache-superset#729)
2. update encodable to remove formatter inter-dependency (apache-superset#744)
3. move number-format and time-format to core (apache-superset#730)
ktmud added a commit to ktmud/superset-ui that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (apache-superset#729)
2. update encodable to remove formatter inter-dependency (apache-superset#744)
3. move number-format and time-format to core (apache-superset#730)
ktmud added a commit to ktmud/superset-ui that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (apache-superset#729)
2. update encodable to remove formatter inter-dependency (apache-superset#744)
3. move number-format and time-format to core (apache-superset#730)
ktmud added a commit that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
ktmud added a commit that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4: move superset-ui/dimension to core (#732)
ktmud added a commit that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4: move superset-ui/dimension to core (#732)
5: move superset-ui/color to core (#755)
ktmud added a commit that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
ktmud added a commit that referenced this pull request Aug 26, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
ktmud added a commit that referenced this pull request Sep 2, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
8: move superset-ui/chart-composition to core (#759)
ktmud added a commit that referenced this pull request Sep 2, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
8: move superset-ui/chart-composition to core (#759)
ktmud added a commit that referenced this pull request Sep 3, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
8: move superset-ui/chart-composition to core (#759)
9: move superset-ui/chart to core (#760)
ktmud added a commit that referenced this pull request Sep 3, 2020
1. move translation, connection, query to core (#729)
2. update encodable to remove formatter inter-dependency (#744)
3. move number-format and time-format to core (#730)
4. move superset-ui/dimension to core (#732)
5. move superset-ui/color to core (#755)
6. move superset-ui/style to core (#756)
7. move superset-ui/validator to core (#757)
8. move superset-ui/chart-composition to core (#759)
9. move superset-ui/chart to core (#760)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants