Skip to content

[WIP] Add watch and update capability for hot reloading to Builder#2656

Open
janbiedermann wants to merge 1 commit intoopal:masterfrom
janbiedermann:builder_watch
Open

[WIP] Add watch and update capability for hot reloading to Builder#2656
janbiedermann wants to merge 1 commit intoopal:masterfrom
janbiedermann:builder_watch

Conversation

@janbiedermann
Copy link
Copy Markdown
Member

@janbiedermann janbiedermann commented May 5, 2024

Adds 2 methods to Builder:

Builder#watch(&block)
loops and watches for changes, calls block with block.call(builder, changes)
where changes is a Hash like: { added: [], modified: [], removed: [] }
if a error occured, changes has another key :error which contains the exception

Builder#update
checks for changes and updates itself, returns the changes like watch above

Builder delegates the actual update to the processed asset, which is a Processor instance, via Processor#update

This PR also updates compiler runner to use Builder#watch.

Although CI is green, i have not tested it yet. I will update #2655 to use this PR and test using that.

@janbiedermann janbiedermann changed the title Add watch and update capability for hot reloading to Builder [WIP] Add watch and update capability for hot reloading to Builder May 5, 2024
Comment thread lib/opal/builder.rb Outdated
Comment thread lib/opal/builder.rb Outdated
@janbiedermann
Copy link
Copy Markdown
Member Author

Also added specs, which fail, because i came to a point, where more changes are required to the assets. For example in case of require_tree and a added file, its not enough to just add the new asset to the set, it must also be added to the outer asset as required asset. Thus delegating the detection of a new file to the outer asset may be appropriate. Work in progress.

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.

2 participants