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

feat: upgraded to node v18, added .nvmrc and updated workflows #977

Merged
merged 33 commits into from
Jul 21, 2023

Conversation

BilalQamar95
Copy link
Contributor

@BilalQamar95 BilalQamar95 commented Mar 15, 2023

edx-internal PR

https://github.com/edx/edx-internal/pull/8353
this needs to be merged togther

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

@BilalQamar95 BilalQamar95 self-assigned this Mar 15, 2023
@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (0c787e3) 83.18% compared to head (e05fd4f) 83.18%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #977   +/-   ##
=======================================
  Coverage   83.18%   83.18%           
=======================================
  Files         397      397           
  Lines        8639     8639           
  Branches     1787     1787           
=======================================
  Hits         7186     7186           
  Misses       1415     1415           
  Partials       38       38           
Impacted Files Coverage Δ
src/components/EnrollmentsTable/index.jsx 83.33% <ø> (ø)
src/components/TableComponent/index.jsx 67.34% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@BilalQamar95 BilalQamar95 marked this pull request as ready for review June 5, 2023 09:23
.nvmrc Outdated
@@ -1 +1 @@
16
18.15
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend setting this as just the major version 18 (i.e., no specified minor version) so engineers don't necessarily need explicitly Node 18.15 but can rather use any version of Node 18.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, but in this particular case I pinned it because of "TypeError: Cannot redefine property: window" issue. It was a bug fixed by nodejs/node#46615 but it wasn't back-ported to v18.16 at the time when I made these commits thus causing the aforementioned error, to resolve the issue I pinned it to v18.15. It seems that is has since been back-ported and the issue is now resolved. I have updated the version in .nvmrc.

babel.config.js Outdated
@@ -3,4 +3,6 @@ const { getBaseConfig } = require('@edx/frontend-build');

const config = getBaseConfig('babel');

config.presets.push('@babel/preset-typescript');
Copy link
Member

Choose a reason for hiding this comment

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

[clarification] Is this addition necessary given @edx/frontend-build@alpha is installed, which has both the default webpack.dev.config.js and webpack.prod.config.js files using the babel-typescript ConfigPreset (e.g., webpack.prod.config.js)?

See babel-typescript.config.js in @edx/frontend-build (source) for where @babel/preset-typescript is already added.

tl;dr; I believe general TypeScript configs like this one should live in the default configs provided by @edx/frontend-build, not in repo-specific configs.

Copy link
Contributor Author

@BilalQamar95 BilalQamar95 Jul 7, 2023

Choose a reason for hiding this comment

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

Yes, you are right. I ran into ts import errors as it seemed Babel did not understand TypeScript syntax, this addition resolved that issue but while exploring further I came across @edx/frontend-build@alpha. With @edx/frontend-build@alpha installed this is no longer necessary/required.

babel.config.js Outdated
@@ -3,4 +3,6 @@ const { getBaseConfig } = require('@edx/frontend-build');

const config = getBaseConfig('babel');

config.presets.push('@babel/preset-typescript');

module.exports = config;
Copy link
Member

Choose a reason for hiding this comment

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

[suggestion] It looks like babel.config.js in this repo doesn't actually extend/override any of the Babel configuration. I might recommend we simply delete babel.config.js given its relying on the default configuration from @edx/frontend-build anyways. We can always re-add the file in the repo if/when we need to customize the Babel configuration specific to this repo, but as far as I can tell, this should be unnecessary at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion, we agree that the current babel.config.js file does not extend/override any of the Babel configuration and it is relying on the default configuration from @edx/frontend-build. Considering this, I have removed babel.config.js in this repo.

with:
node-version: ${{ matrix.node }}
- run: npm install -g npm@${{ matrix.npm }}
node-version: ${{ env.NODE_VER }}
Copy link
Member

Choose a reason for hiding this comment

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

Just curious if the node-version-file attribute was considered when constructing the workflow. We could retain the original strategy matrix attributes, but point directly to the .nvmrc file as a reference to the intended node version to upgrade to.
Docs: https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file

strategy:
    matrix:
        node-version-file: ['.nvmrc']     
...
steps:
    ...
    - name: Setup Nodejs Env version ${{ matrix.node-version-file}}
      uses: actions/setup-node@v3
      with:
          node-version-file: ${{matrix.node-version-file}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The workflow was created by arbi-bom originally and with node v18 upgrades it spread across all the remaining MFEs where it was not being used previously. I'm not sure if node-version-file was considered while constructing it but I could see the merit to retain the original strategy matrix attributes. We can explore this further, thanks for bringing it to our attention.

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

LGTM. Also curious about @brobro10000's comment :)

@BilalQamar95 BilalQamar95 merged commit 70536da into master Jul 21, 2023
@BilalQamar95 BilalQamar95 deleted the bilalqamar95/node-v18-upgrade branch July 21, 2023 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants