-
Notifications
You must be signed in to change notification settings - Fork 273
refactor: move translation, connection, query to core #729
refactor: move translation, connection, query to core #729
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/superset/superset-ui/o09ba5wtp |
@@ -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'; |
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.
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 |
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.
Previously disabled in packages/superset-ui/connection/.eslintrc
.
Now that they are combined into one package you could export everything that used to be a top-level export from 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" |
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.
Is the intention to release 0.15 once this is merged?
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.
yes
I'd rather fix this in another PR since there may be export conflicts. |
I don't think there is. The |
7899b08
to
b93631b
Compare
@@ -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'; |
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.
Does this need src
?
It did not need this previously.
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 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.
But this is not the test for that function or package. @superset-ui/core
is only a dependency.
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.
This test the WithLegend
component and only use promiseTimeout
for facilitating the test, not testing promiseTimeout
itself.
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.
This makes sense. I removed src
for other packages.
packages/superset-ui-chart/README.md
Outdated
@@ -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'; |
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.
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'; |
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.
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'; |
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.
remove /src/translation
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.
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
.
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.
But maybe in another PR.
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", |
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.
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'; |
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.
We are not generating esm
files any more, since the content is identical to lib
(checked multiple random files).
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.
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
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.
Just pushed a fix in my branch: 18b05b1
"testEnvironment": "node" | ||
} | ||
] | ||
}; |
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.
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.
@kristw @suddjian I think this is ready for merge. A major update from yesterday is moving away from |
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.
LGTM, thank you for tackling this!
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)
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)
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)
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)
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)
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)
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)
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)
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)
🏠 Internal
Follow up of #728 .
Started with merging
connection
andquery
into core, because they are closely related. Ended up with movingtranslation
as well because it was used intest/setup.js
.