Skip to content

INSTUI-3823 Get InstUI build on Windows #1241

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

Merged
merged 10 commits into from
Aug 11, 2023
Merged

INSTUI-3823 Get InstUI build on Windows #1241

merged 10 commits into from
Aug 11, 2023

Conversation

matyasf
Copy link
Collaborator

@matyasf matyasf commented Jul 24, 2023

This PR gets yarn bootstrap and yarn dev working on windows. yarn test also runs, but its quite flaky -- some tests fail, some others just throw an error.
This is accomplished by using cross-spawn via its API to spawn babel, karma and webpack instead of concurrently and execa via command line.
On OSX nothing should change except babel being a bit more verbose.

To test:
On OSX run our usual build/test commands, especially with parameters (e.g. yarn test --scope..).
On Windows run bootstrap, dev. If you get tons of popups change the default program to run js files to node.exe

matyasf added 3 commits July 24, 2023 22:57
also remove concurrently dependency. This simplifies our script execution a lot. Some scripts are a
bit more colorful, some output a bit more log
let result = { status: 1 }

try {
result = runCommandSync(`${resolveBin('concurrently')}`, args)
Copy link
Collaborator Author

@matyasf matyasf Jul 25, 2023

Choose a reason for hiding this comment

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

This was the biggest issue. This is an ugly hack to allow synchronous parallel execution in node (= execute multiple scripts simultaneously synchronously). This was accomplished by running concurrently (a lib to execute multiple scripts at the same time) synchronously. This had multiple issues:

  • we needed to pass arguments and env variables in a huge string like concurrently "ENV_VAR1=A, ENV_VAR2=B scriptA --arg1 abc --arg2 bcd" ENV_VAR3=3 scriptB --arg1=123 that is very hard to read and is not Windows compatible.
  • We were running concurrently not with native code but with a lib called execa. Dontknow why
  • All these scripts executing scripts made IDE debuggers get lost unable to place breakpoints
  • some of them also mess with stdout causing formatting like colors to be lost.

This solution is pure native code, easy to read, crossplatform with a price that runCommandsConcurrently became async (we never made use of its synchronous nature)

@matyasf matyasf changed the title WIP refactor: use childprocess instead of execa for running processes WIP Get InstUI build on Windows Jul 26, 2023
@github-actions
Copy link

Preview URL: https://1241--preview-instui.netlify.app

@matyasf matyasf self-assigned this Jul 26, 2023
@matyasf matyasf requested review from balzss and HerrTopi July 27, 2023 18:01
@matyasf matyasf changed the title WIP Get InstUI build on Windows Get InstUI build on Windows Jul 27, 2023
@@ -36,7 +36,7 @@
"generate:component": "yarn workspace @instructure/instui-cli instui create component",
"generate:package": "yarn workspace @instructure/instui-cli instui create package",
"commit": "ui-scripts commit",
"bootstrap": "time yarn node scripts/bootstrap.js",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

time does not exist on Windows, we should use a node API in a later PR

@HerrTopi
Copy link
Contributor

HerrTopi commented Aug 7, 2023

It seems that yarn bootstrap, and yarn dev works, but the docs app missing most of its pages. I'd bet it's a path issue. This probably works differently on mac and windows

matyasf added 3 commits August 8, 2023 10:04
react-docgen 6 upgrade required that the docs build scripts use ESM imports. It also has a bug with
some function definitions (see react-docgen issue 827 on Github) that required the rewrite of some
types. Also made doc build scripts a bit more Windows friendly
@@ -22,7 +22,7 @@
* SOFTWARE.
*/

import type { LibraryOptions, ParsedDoc, ProcessedFile } from '../DataTypes'
import type { LibraryOptions, ParsedDoc, ProcessedFile } from '../DataTypes.mjs'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This rewrite was needed because I thought that an issue would be fixed by upgrading react-docgen... it was not, and it required that our TS files are emitted with ESM imports. This needed a change in the extension otherwise they'd be treated as commonJS files.

Comment on lines +52 to +54
if (process.platform === 'win32' && module.description) {
// JSDoc bug https://github.com/jsdoc/jsdoc/issues/2067
module.description = module.description.replace(/\r/g, "\r\n")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ugly hack that is the actual fix

onUpdate?: ({ visibleItemsCount }: { visibleItemsCount: number }) => void
onUpdate?: (visibleItemsCount: { visibleItemsCount: number }) => void
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was needed because react-docgen was failing with the old code, see reactjs/react-docgen#827

Copy link

Choose a reason for hiding this comment

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

This was fixed in [email protected].

Copy link
Contributor

@HerrTopi HerrTopi left a comment

Choose a reason for hiding this comment

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

Yaaay, it works! Fantastic work, thanks a lot!

@matyasf matyasf changed the title Get InstUI build on Windows INSTUI-3823 Get InstUI build on Windows Aug 10, 2023
Copy link
Contributor

@balzss balzss left a comment

Choose a reason for hiding this comment

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

works fine on mac as well (bootstrap, dev, test, build)

@matyasf matyasf merged commit da093e4 into master Aug 11, 2023
@matyasf matyasf deleted the run_on_windows branch August 11, 2023 09:48
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