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

Update rollup bundling config #33

Merged
merged 3 commits into from
Dec 14, 2022
Merged

Conversation

kevinwcyu
Copy link
Contributor

Fixes: #30

Update rollup config to take advantage of treeshaking and esm builds.

As an example, see the config for @grafana/ui which is supposed to be an up-to-date config for bundling libraries.

Quick manual tests with Cloudwatch, Athena, Redshift, Timestream, and X-Ray by checking the config editor and the query editor and everything still works.

@kevinwcyu kevinwcyu requested a review from a team as a code owner December 9, 2022 19:36
@kevinwcyu kevinwcyu requested review from iwysiu and sarahzinger and removed request for a team December 9, 2022 19:36
@@ -70,7 +70,6 @@ export function ConfigSelect(props: ConfigSelectProps) {
allowCustomValue={props.allowCustomValue}
autoFocus={props.autoFocus}
backspaceRemovesValue={props.backspaceRemovesValue}
className={props.className}
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 removed passing the className prop down as the current behaviour is already overriding the className (see commonProps on line 43).

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we still be passing 'width-30' as the className?

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's still being passed by commonProps.

Copy link
Contributor

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

The comments are less critique and more questions. I hadn't heard of some of these concepts before, so someone else should probably also review it

@@ -24,6 +24,10 @@ describe('ResourceSelector', () => {
render(<ResourceSelector {...props} default="foo" value={defaultKey} fetch={fetch} onChange={onChange} />);
expect(screen.queryByText('default (foo)')).toBeInTheDocument();

// TODO ResourceSelectorProps should be updated to make `label` required
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 todo for in this pr or a reminder for a follow up issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reminder for a follow up, could potentially be done in this PR though, just have to go through the places where this component is used and make sure it can be changed to a required prop.

Copy link
Contributor Author

@kevinwcyu kevinwcyu Dec 14, 2022

Choose a reason for hiding this comment

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

Actually, going to leave the prop as optional to match the InlineField component's label prop. I'll remove this TODO comment and close the other PR.

@@ -70,7 +70,6 @@ export function ConfigSelect(props: ConfigSelectProps) {
allowCustomValue={props.allowCustomValue}
autoFocus={props.autoFocus}
backspaceRemovesValue={props.backspaceRemovesValue}
className={props.className}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we still be passing 'width-30' as the className?

@@ -1,8 +1,8 @@
export { ConnectionConfig, ConnectionConfigProps } from './ConnectionConfig';
export { ConnectionConfig, type ConnectionConfigProps } from './ConnectionConfig';
Copy link
Contributor

Choose a reason for hiding this comment

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

What does adding type here do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Typescript, types are erased because js doesn't actually have the same runtime concept of types like ts. But when code is being transpiled, this export statement is actually trying to find something exported from the ConnectionConfig module, but since it's erased, it doesn't actually find anything. Adding type here indicates that it's just importing a type and there's nothing actually exported.

Copy link
Contributor

@sunker sunker left a comment

Choose a reason for hiding this comment

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

Nice! And thanks for switching to Rollup's watcher. It's so much faster now.

How come we don't generate one index file for development and one for production anymore?

Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

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

I'm not a rollup/bundling expert but this looks cool to me! Yay tree shaking!

There are a couple of neat new(ish?) things here that I didn't know about like importing just types or this React.DependencyList thing, might be cool to do a little lightning talk or something at a frontend weekly to share in case other people are interested :) I bet I'm not the only one new to it!

"dist"
],
"repository": "github:grafana/grafana-aws-sdk-react",
"author": "Grafana Labs <[email protected]> (https://grafanap.com)",
Copy link
Member

Choose a reason for hiding this comment

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

😴

@@ -1,4 +1,4 @@
import React from 'react';
import React, { DependencyList } from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

👀 I don't think I've heard of this one!

Copy link
Contributor

Choose a reason for hiding this comment

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

👆🏻

@kevinwcyu
Copy link
Contributor Author

How come we don't generate one index file for development and one for production anymore?

@sunker I was following the reasoning from the @grafana/ui config

We currently bundle index.development.js and index.production.js files for all packages. This PR removes them in favour of a single build (packaged as CJS and ESM) without minification and includes sourcemaps. Reasoning for this change is that if a consumer wants to use this package their app build tooling can minify the package. Likewise for plugin developers these packages are only used in test environments making a minified production build a bit redundant IMHO.

grafana/grafana#51517 (comment)

Copy link
Contributor

@sunker sunker left a comment

Choose a reason for hiding this comment

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

@sunker I was following the reasoning from the @grafana/ui config

Makes sense! Thanks

@kevinwcyu kevinwcyu force-pushed the kevinwcyu/update-rollup-config branch from 9780eb1 to 87715d7 Compare December 14, 2022 19:37
@kevinwcyu kevinwcyu merged commit 9d2b0c1 into main Dec 14, 2022
@kevinwcyu kevinwcyu deleted the kevinwcyu/update-rollup-config branch December 14, 2022 19:59
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.

Update rollup config
5 participants