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: ensure code is finished compiling before returning cached file #36

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

jsakas
Copy link
Contributor

@jsakas jsakas commented Feb 28, 2023

Hi @mammadataei - earlier I opened #35

After reviewing the code, I think maybe the problem is that it is not waiting for Vite to finish bundling before returning the cache file location. The process probably works fine for simple files with no external imports. However, in my codebase, we often import files from src, for example utilities which slows down the Vite bundler and makes the file not immediately available.

In the documentation it notes only resolving the promise when the file is written to disk:

https://docs.cypress.io/api/plugins/preprocessors-api#The-callback-function-should-return-one-of-the-following

The callback function should return one of the following:

A promise* that eventually resolves the path to the built file**.
A promise* that eventually rejects with an error that occurred during processing.

  • The promise should resolve only after the file has completed writing to disk. The promise resolving is a signal that the file is ready to be served to the browser.

src/index.ts Show resolved Hide resolved
@mammadataei mammadataei merged commit 91ae5b8 into mammadataei:main Mar 2, 2023
@mammadataei
Copy link
Owner

Hi @jsakas. Thanks a lot for your contribution. Merged and released in v1.3.1.

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