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

Fix ./run gui watch #6212

Merged
merged 11 commits into from Apr 11, 2023
Merged

Fix ./run gui watch #6212

merged 11 commits into from Apr 11, 2023

Conversation

somebody1234
Copy link
Collaborator

@somebody1234 somebody1234 commented Apr 5, 2023

Pull Request Description

  • Fixes Watch does not work anymore #6168
  • Removes enso-copy-plugin in favor of an inline plugin
    • It was only used in one place anyway
    • It is probably necessary since I've "fixed" it by adding all files as entrypoints (I'm not quite sure why it wasn't working with the fix with enso-copy-plugin...)
  • Adds live reload (back) to content/

Important Notes

To QA:
Mandatory:

  • ./run gui watch --skip-version-check --skip-wasm-opt

Recommended:

  • npm run watch-dashboard
  • ./run ide watch --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest
    • and with --ide-option -authentication
  • ./run ide build --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest
    • Enso and Enso -authentication

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@somebody1234 somebody1234 added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 5, 2023
@PabloBuchu
Copy link
Contributor

QA 🟢

  1. Confrim that ./run gui watch works and reloads itself after file changes.
  2. Build works (authentication + ide + workspace).
  3. watch-dashboard & authentication also no issues

@PabloBuchu
Copy link
Contributor

PabloBuchu commented Apr 6, 2023

@somebody1234 can you take a look on windows building? its failing https://github.com/enso-org/enso/actions/runs/4621430061/jobs/8182386985?pr=6212
maybe @Nctdt could help you since he is working on windows

GitHub
Hybrid visual and textual functional programming. Contribute to enso-org/enso development by creating an account on GitHub.

@PabloBuchu PabloBuchu mentioned this pull request Apr 6, 2023
5 tasks
@somebody1234
Copy link
Collaborator Author

ah whoops, it's because i'm using a hardcoded regex to detect folders and forgot to factor in windows

@somebody1234
Copy link
Collaborator Author

somebody1234 commented Apr 6, 2023

this should fix it but it'd be good to get extra testing to make sure i didn't accidentally break it for macos
(i guess CI will error if it's broken though)

@PabloBuchu
Copy link
Contributor

@somebody1234 build went ok on ma laptop

@somebody1234 somebody1234 mentioned this pull request Apr 6, 2023
6 tasks
@somebody1234
Copy link
Collaborator Author

@wdanilo just a heads up - the fix for gui watch is here and has been QA'd. you mentioned that this should be fixed ASAP so you might want to take a look at this sometime soon?

@PabloBuchu
Copy link
Contributor

@mwu-tow are you able to do review for this PR? it fixes problem with ./run gui watch not able to reload browser page after code change

outdir: outputPath,
outbase: 'src',
plugins: [
{
// This is a workaround that is needed because esbuild panics when using `loader: { '.js': 'copy' }`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it panic? Is this a bug in esbuild? Was it reported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reported here. it's a triggered by bundling ts and using js: copy and inject all at the same time

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(the bug has been fixed!! once the next release is made, we should be back to no inline plugins for this package)

// This is a workaround that is needed because esbuild panics when using `loader: { '.js': 'copy' }`.
name: 'pkg-js-is-cjs',
setup: build => {
build.onLoad({ filter: /\/pkg.js$/ }, async ({ path }) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we add a special rule just for pkg.js? Please document, how pkg.js is special.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will do.
(explaining here too for posterity:)
esbuild converts files to ESM because the package.json says so, however pkg.js is loaded using new Function in wasm-pack code, i believe - so the default output (pkg.js being a module) throws a syntax error

outdir: outputPath,
outbase: 'src',
plugins: [
{
// This is a workaround that is needed because esbuild panics when using `loader: { '.js': 'copy' }`.
name: 'pkg-js-is-cjs',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does setting loader to copy mean the file "is cjs"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will add comment - loader: copy prevents esbuild from processing the file, otherwise it becomes ESM which breaks the way we load the file

}))
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about inlining such things. While it is not necessary to keep this as a separate package, it should be extracted, documented and be reusable, e.g. if "client" bundler ever wants to copy directories.

setup: build => {
build.onResolve({ filter: /[/\\][^./\\]+$/ }, ({ path, kind }) =>
kind === 'entry-point'
? { path, namespace: 'copy-directories', watchDirs: [path] }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it will update when the files content change, watchDir is only for the entry list changes. Also, it does not watch subdirectories.

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 is true, however afaict the same is true for the old copy plugin - since directories are copied via fs.cp(from, to, { recursive: true }) and then pushed to watchFiles. since these are resolved on every build (i think) because they are entry points, they are probably always copied - i can add a comment after extracting out to a plugin

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wait actually... it still won't update when file contents change. we might need to use chokidar and manually trigger rebuilds? alternatively leave as-is, but with a comment noting this as a weakness of this approach

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, alternatively chokidar can be used to continuously keep the directories in sync after the initial cp, skipping all onResolve and onLoad except for the first onResolve, which would register the watcher

// ===================

if (IS_DEV_MODE) {
new EventSource('/esbuild').addEventListener('change', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The '/esbuild' and 'change' look here like magic literals. Please document.
(BTW, it's great to see this finally supported in esbuild itself.)

@mwu-tow
Copy link
Contributor

mwu-tow commented Apr 7, 2023

@PabloBuchu I did, but you'll still need a code owner's review.

@somebody1234
Copy link
Collaborator Author

took a bit longer than expected but review issues should be addressed now.

@PabloBuchu PabloBuchu added the CI: Ready to merge This PR is eligible for automatic merge label Apr 10, 2023
@somebody1234
Copy link
Collaborator Author

somebody1234 commented Apr 11, 2023

ah, the issue is that chokidar continues running indefinitely even after esbuild stops...
not sure if there's a way to detect when esbuild is finished though...

@somebody1234
Copy link
Collaborator Author

ah, this

@somebody1234
Copy link
Collaborator Author

well that didn't fix it

@mergify mergify bot merged commit 37d820c into develop Apr 11, 2023
24 checks passed
@mergify mergify bot deleted the wip/sb/fix-gui-watch branch April 11, 2023 06:04
MichaelMauderer pushed a commit that referenced this pull request Apr 25, 2023
- Fixes #6168
- Removes `enso-copy-plugin` in favor of an inline plugin
- It was only used in one place anyway
- It is probably necessary since I've "fixed" it by adding all files as entrypoints (I'm not quite sure why it wasn't working with the fix with `enso-copy-plugin`...)
- Adds live reload (back) to `content/`

# Important Notes
To QA:
Mandatory:
- `./run gui watch --skip-version-check --skip-wasm-opt`

Recommended:
- `npm run watch-dashboard`
- `./run ide watch --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest`
- and with `--ide-option -authentication`
- `./run ide build --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest`
- `Enso` and `Enso -authentication`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants