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

chore(rollup): upgrade rollup deps, migrate to mjs config file, enforce linting on mjs files #5830

Merged
merged 10 commits into from
Sep 26, 2024

Conversation

calebpollman
Copy link
Member

@calebpollman calebpollman commented Sep 24, 2024

Description of changes

Upgrade rollup from ^2.70.0 to ^4.22.4 (ref). The approach taken by this PR configures rollup to emit a bundled output that aligns as closely as possible with the current output. While some of the flags may no longer be necessary, additional modifications to bundle output should be handled in a major version bump.

See this commit for a diff of the dist output between existing bundle output and the output of the changes from this PR.

Summary of changes:

  • migrate all rollup.config.ts files to rollup.config.mjs
  • add additional bundle output flags. Detailed comments included in code changes of react-ai package
  • update @aws-amplify/react-core/elements ESM subpaths
  • enforce linting on directory top level .mjs and .ts files
  • add some lightweight linting rules (and fixes) to the ui package
  • fix some warnings from unit test in the react-native package

Issue #, if available

NA

Description of how you validated changes

Manual tests, visual diffing of bundle output diff, CI workflows taken against this PR

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • yarn test passes and tests are updated/added
  • PR title and commit messages follow conventional commit syntax
  • If this change should result in a version bump, changeset added (This can be done after creating the PR.) This does not apply to changes made to docs, e2e, examples, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@calebpollman calebpollman requested a review from a team as a code owner September 24, 2024 08:16
Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: 1336147

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@aws-amplify/ui-angular Patch
@aws-amplify/ui-react Patch
@aws-amplify/ui-react-ai Patch
@aws-amplify/ui-react-core Patch
@aws-amplify/ui-react-core-notifications Patch
@aws-amplify/ui-react-geo Patch
@aws-amplify/ui-react-liveness Patch
@aws-amplify/ui-react-native Patch
@aws-amplify/ui-react-notifications Patch
@aws-amplify/ui-react-storage Patch
@aws-amplify/ui Patch
@aws-amplify/ui-vue Patch
@aws-amplify/ui-react-auth Patch
@aws-amplify/ui-react-core-auth Patch
@aws-amplify/ui-react-native-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

dbanksdesign
dbanksdesign previously approved these changes Sep 24, 2024
Copy link
Contributor

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

Just 2 questions, but if they are intended, I am GTG

@calebpollman calebpollman changed the title chore(rollup): upgrade rollup deps, migrate to mjs config file, enforce linting on mjs files [WIP] chore(rollup): upgrade rollup deps, migrate to mjs config file, enforce linting on mjs files Sep 25, 2024
package.json Outdated Show resolved Hide resolved
extends: ['@aws-amplify/amplify-ui/react'],
ignorePatterns: ['.eslintrc.js', 'dist', 'rollup.config.ts'],
extends: '@aws-amplify/amplify-ui/react',
ignorePatterns: ['.eslintrc.js', 'coverage', 'dist', 'node_modules'],
Copy link
Member Author

Choose a reason for hiding this comment

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

Linting has been expanded to cover top level .ts and .mjs files. Added coverage and node_modules to the ignorePatterns to mitigate extraneous linting

// point to local tsconfig
parserOptions: { project: ['tsconfig.json'], tsconfigRootDir: __dirname },
overrides: [
{
extends: ['@aws-amplify/amplify-ui/jest'],
files: ['**/__mocks__/**', '**/__tests__/**'],
},
{ files: '*.mjs' },
Copy link
Member Author

Choose a reason for hiding this comment

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

Captures top level .mjs files (basically just rollup.config.mjs

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 do anything if it's not paired with a rule?

Copy link
Member Author

Choose a reason for hiding this comment

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

It runs the default set of rules

Copy link
Contributor

Choose a reason for hiding this comment

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

Do the default rules not get run by default for those files?

Copy link
Member Author

Choose a reason for hiding this comment

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

They were not but this could potentially be removed as some changes were made after it was added, either way preference is not to make any changes to this PR unless they impact the bundle output

@@ -2,5 +2,5 @@ const config = require('../../.lintstagedrc.js');

module.exports = {
...config,
'*.{ts,tsx,js}': 'eslint',
'*.{ts,tsx,js,mjs}': 'eslint',
Copy link
Member Author

Choose a reason for hiding this comment

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

Lint .mjs files on commit

@@ -34,7 +34,7 @@
"check:esm": "node --input-type=module --eval 'import \"@aws-amplify/ui-react-ai\"'",
"clean": "rimraf dist node_modules",
"dev": "yarn build:rollup --watch",
"lint": "yarn typecheck && eslint src",
"lint": "yarn typecheck && eslint .",
Copy link
Member Author

Choose a reason for hiding this comment

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

src -> . to allow linting of top level config files

@@ -1,4 +1,3 @@
import { ComponentStyles } from './utils';

export type ButtonGroupTheme<Required extends boolean = false> =
ComponentStyles;
export interface ButtonGroupTheme extends ComponentStyles {}
Copy link
Member Author

Choose a reason for hiding this comment

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

Linting fix due to new rules (ref)

@@ -1,4 +1,3 @@
import { ComponentStyles } from './utils';

export type CheckboxFieldTheme<Required extends boolean = false> =
ComponentStyles;
export interface CheckboxFieldTheme extends ComponentStyles {}
Copy link
Member Author

Choose a reason for hiding this comment

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

Linting fix due to new rules (ref)

@@ -1,4 +1,3 @@
import { ComponentStyles } from './utils';

export type SelectFieldTheme<Required extends boolean = false> =
ComponentStyles;
export interface SelectFieldTheme extends ComponentStyles {}
Copy link
Member Author

Choose a reason for hiding this comment

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

Linting fix due to new rules (ref)

import { DefaultTheme, WebTheme } from '../types';
import { WebTheme } from '../types';
Copy link
Member Author

Choose a reason for hiding this comment

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

Linting fix due to new rules (ref)

@@ -1,4 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts"],
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensures that only .ts files under src are included in build output

@calebpollman calebpollman changed the title [WIP] chore(rollup): upgrade rollup deps, migrate to mjs config file, enforce linting on mjs files chore(rollup): upgrade rollup deps, migrate to mjs config file, enforce linting on mjs files Sep 25, 2024
dbanksdesign
dbanksdesign previously approved these changes Sep 25, 2024
Copy link
Contributor

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

Most thorough comment walk-through in a PR I've seen in a while. Kudos!

.changeset/good-bats-teach.md Outdated Show resolved Hide resolved
Co-authored-by: Danny Banks <djb@amazon.com>
@calebpollman calebpollman merged commit 545aa6a into main Sep 26, 2024
40 checks passed
@calebpollman calebpollman deleted the rollup/upgrade branch September 26, 2024 17:10
@github-actions github-actions bot mentioned this pull request Sep 26, 2024
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.

4 participants