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: remove type: module, create openmct-e2e subpackage #7590

Merged
merged 26 commits into from
Mar 28, 2024

Conversation

ozyx
Copy link
Member

@ozyx ozyx commented Mar 14, 2024

Closes #7602

Describe your changes:

Now this is a story all about how our project got flipped, turned upside down--

1iPe0G

TL;DR: We took openmct to type: 'module' too soon.


A few months back, we converted the entire project to using ESM import/export syntax. We switched the package itself to type: module because running unit/e2e tests were failing (as we couldn't use import or export keywords unless the package was of type: module or the file had an *.mjs extension).

Even though our package was of type: module, under the hood Webpack was compiling our source using a UMD wrapper which is meant to support imports in both node and browser environments. However, this never worked properly because we set the package type as 'module' (when it really wasn't!). Consumers would attempt to import the package only to find that it defined no exports. They would then try to require the package, only to be denied under the basis that you cannot require an ESModule. In fact, webpack currently does not support packaging a library as an ESModule. As it stands, webpack is a dead-end for openmct as a true ESModule.

This PR fixes a ton of misconfiguration with webpack, switches our package type off of module, and specifies paths and entry points for both import and require syntax.

In addition, and to avoid having to change the extensions of all e2e test files to *.mjs, this PR initializes a new npm sub-package openmct-e2e of type: module. This package is specified as a workspace of openmct, so a single node_modules folder is shared between the two projects (same as it ever was).

See the corresponding PRs for openmct-yamcs and viper-openmct.

Brief Summary of Changes

  • Removes e2e folder from our distributable
  • Removes type: module from package.json
  • Initializes a new package openmct-e2e which exports our e2e testing framework
  • Adds e2e folder as a workspace to openmct so they share node_modules
  • webpack.*.js -> webpack.*.mjs
  • Specifies module and exports in package.json
  • Updates npm e2e test scripts to use --workspace to call scripts in e2e folder
  • Modifies .tsconfig.json settings to generate TypeScript types in dist/types/index.d.ts as opposed to creating individual files.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this a notable change that will require a special callout in the release notes? For example, will this break compatibility with existing APIs or projects that consume these plugins?

Author Checklist

  • Changes address original issue?
  • Tests included and/or updated with changes?
  • Has this been smoke tested?
  • Have you associated this PR with a type: label? Note: this is not necessarily the same as the original issue.
  • Have you associated a milestone with this PR? Note: leave blank if unsure.
  • Testing instructions included in associated issue OR is this a dependency/testcase change?

Reviewer Checklist

  • Changes appear to address issue?
  • Reviewer has tested changes by following the provided instructions?
  • Changes appear not to be breaking changes?
  • Appropriate automated tests included?
  • Code style and in-line documentation are appropriate?

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 49.99%. Comparing base (fb396ac) to head (b45a127).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7590      +/-   ##
==========================================
- Coverage   56.13%   49.99%   -6.15%     
==========================================
  Files         672      672              
  Lines       27116    27111       -5     
  Branches     2635     2635              
==========================================
- Hits        15222    13554    -1668     
- Misses      11567    13230    +1663     
  Partials      327      327              
Flag Coverage Δ
e2e-full 23.57% <ø> (-0.03%) ⬇️
e2e-stable ∅ <ø> (∅)
unit 49.11% <0.00%> (+0.02%) ⬆️
Files Coverage Δ
src/plugins/notebook/utils/painterroInstance.js 3.70% <0.00%> (-85.19%) ⬇️

... and 189 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb396ac...b45a127. Read the comment docs.

package.json Outdated Show resolved Hide resolved
@shefalijoshi
Copy link
Contributor

@ozyx This is perfect! I tried it with the nirvss project and it now works really well. Thank you!

@ozyx ozyx requested a review from unlikelyzero March 15, 2024 21:18
@ozyx ozyx added this to the Target:4.0.0 milestone Mar 15, 2024
@ozyx ozyx added the type:maintenance tests, chores, or project maintenance label Mar 15, 2024
@ozyx ozyx requested a review from akhenry March 16, 2024 18:09
@ozyx ozyx changed the title Fix import require chore: remove type: module, create openmct-e2e subpackage Mar 16, 2024
@ozyx ozyx marked this pull request as ready for review March 16, 2024 18:10
@ozyx ozyx requested a review from scottbell March 16, 2024 18:12
@ozyx ozyx added the pr:e2e:couchdb npm run test:e2e:couchdb label Mar 16, 2024
@github-actions github-actions bot removed the pr:e2e:couchdb npm run test:e2e:couchdb label Mar 16, 2024
Copy link
Contributor

@scottbell scottbell left a comment

Choose a reason for hiding this comment

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

Nice work! We'll need to let others know who use Open MCT that this will require them updating how they import us. I tested core, and using the accompanying PR, and everything appeared to work well.

@ozyx ozyx removed this from the Target:4.0.0 milestone Mar 19, 2024
@ozyx ozyx marked this pull request as draft March 19, 2024 20:44
@ozyx ozyx added this to the Target:4.0.1 milestone Mar 21, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 49.99%. Comparing base (a5c6b14) to head (1de1510).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7590      +/-   ##
==========================================
- Coverage   56.60%   49.99%   -6.62%     
==========================================
  Files         672      672              
  Lines       27120    27120              
  Branches     2632     2632              
==========================================
- Hits        15351    13558    -1793     
- Misses      11441    13234    +1793     
  Partials      328      328              
Flag Coverage Δ *Carryforward flag
e2e-full 23.64% <ø> (-18.13%) ⬇️ Carriedforward from c8a7114
e2e-stable ?
unit 49.08% <0.00%> (-0.03%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files Coverage Δ
src/plugins/notebook/utils/painterroInstance.js 3.70% <0.00%> (-85.19%) ⬇️

... and 192 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5c6b14...1de1510. Read the comment docs.

@ozyx ozyx marked this pull request as ready for review March 26, 2024 00:16
Copy link
Contributor

@akhenry akhenry left a comment

Choose a reason for hiding this comment

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

Changes look great. Looks like there are some new conflicts due to all the recent merging, and two github warnings we should address before merge. Thanks!

e2e/README.md Outdated Show resolved Hide resolved
e2e/test-data/overlay_plot_storage.json Outdated Show resolved Hide resolved
e2e/tests/functional/planning/ganttChart.e2e.spec.mjs Outdated Show resolved Hide resolved
openmct.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@@ -0,0 +1,27 @@
{
"name": "openmct-e2e",
"version": "4.0.0-next",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should always match openmct's package.json. Is there an easy way to manage that based on monorepo tooling?

@@ -15,6 +15,7 @@ const config = {
timeout: 60 * 1000,
webServer: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need a .npmignore file and to ignore *.config.js

Copy link
Collaborator

@unlikelyzero unlikelyzero left a comment

Choose a reason for hiding this comment

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

Two small changes:

  1. We should not be exposing all avpFixtures in other projects. viper should never attempt to publish a percy check!
  2. We need to .npmignore our e2e config files

@unlikelyzero
Copy link
Collaborator

@ozyx just needs to add npmignore for the config files. avpFixtures is not a problem

@@ -0,0 +1,7 @@
*
!appActions.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're going to want to include the test s but not right now

@ozyx ozyx added the pr:e2e:couchdb npm run test:e2e:couchdb label Mar 28, 2024
@github-actions github-actions bot removed the pr:e2e:couchdb npm run test:e2e:couchdb label Mar 28, 2024
@unlikelyzero unlikelyzero dismissed akhenry’s stale review March 28, 2024 21:48

bad origin on the initial review. All comments were already addressed

@unlikelyzero unlikelyzero merged commit a3fb84a into master Mar 28, 2024
23 of 25 checks passed
@unlikelyzero unlikelyzero deleted the fix-import-require branch March 28, 2024 21:49
@ozyx ozyx added the notable_change A change which should be noted in the changelog label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notable_change A change which should be noted in the changelog type:maintenance tests, chores, or project maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Require/import of openmct doesn't work as expected
6 participants