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

Proposal: add a prepare() pass before run() pass #2981

Closed
sidvishnoi opened this issue Jun 24, 2020 · 2 comments · Fixed by #3311
Closed

Proposal: add a prepare() pass before run() pass #2981

sidvishnoi opened this issue Jun 24, 2020 · 2 comments · Fixed by #3311

Comments

@sidvishnoi
Copy link
Member

sidvishnoi commented Jun 24, 2020

ReSpec has "prepare" code like this or this in many modules. My idea is to add a async prepare(conf) in such modules, and do a pass where all modules run their prepare(), followed by our existing run() pass.

Why?

  • I was trying to reorder some plugins to make overall ReSpec appear to load faster (mainly create ToC before content below the fold). But some plugins add headings dynamically (not available until they run()), but ToC requires those headings (so we've a dependency chain making ToC render late). If we can generate those headings in a prepare, then we can easily generate ToC earlier (See this demo of impact: https://respec-run-toc-early.netlify.app).
  • This would also help with https://github.com/w3c/respec/pull/2187 where we can keep mutations in prepare, and not make them top-level.

Thoughts? @saschanaz @marcoscaceres

@sidvishnoi sidvishnoi changed the title Proposal: prepare function in plugins Proposal: add a prepare() pass before run() pass Jun 24, 2020
@saschanaz
Copy link
Collaborator

This sounds good! I see no immediate negative point.

@marcoscaceres
Copy link
Contributor

Like it! /me presses 👍 button.

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 a pull request may close this issue.

3 participants