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(types): mark hmr update internal types optional #15606

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 15, 2024

Description

The HMR update type can be manually emitted today like https://github.com/histoire-dev/histoire/blob/bc08dec376faa9f72335f6fa4c54283a0233a93d/packages/histoire/src/node/server.ts#L102, which broke types downstream. Marking them as optional like before for now. (explicitImportRequired was already optional before but I made it required in #15118

Currently these internal types are only used at

async function importUpdatedModule({
acceptedPath,
timestamp,
explicitImportRequired,
isWithinCircularImport,
}) {
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`)
const importPromise = import(
/* @vite-ignore */
base +
acceptedPathWithoutQuery.slice(1) +
`?${explicitImportRequired ? 'import&' : ''}t=${timestamp}${
query ? `&${query}` : ''
}`
)
if (isWithinCircularImport) {
importPromise.catch(() => {
console.info(
`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. ` +
`To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`,
)
pageReload()
})
}

Additional context

Thanks @Akryum for spotting this.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) label Jan 15, 2024
Copy link

stackblitz bot commented Jan 15, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev
Copy link
Member

/ecosystem-ci run histoire

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on d52d250: Open

suite result latest scheduled
histoire success failure

@patak-dev patak-dev merged commit df8f5a5 into main Jan 15, 2024
10 checks passed
@patak-dev patak-dev deleted the relax-hmr-update-type branch January 15, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants