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

Build uses outdated files from cache since 5.1.6 or 5.1.7 #13028

Open
1 task
jachang820 opened this issue Jan 21, 2025 · 4 comments
Open
1 task

Build uses outdated files from cache since 5.1.6 or 5.1.7 #13028

jachang820 opened this issue Jan 21, 2025 · 4 comments
Labels
- P2: has workaround Bug, but has workaround (priority) feat: content layer Related to the Content Layer feature (scope)

Comments

@jachang820
Copy link

Astro Info

Astro                    v5.1.8
Node                     v22.12.0
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap
                         @astrojs/svelte

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

If a script is written (e.g. a Shiki transformer or Rehype plugin) that changes something in a content post, then the site is built, then script is changed to do something else, and the site built again. That second build seems to think that because the content file hasn't been updated, nothing has changed, and the changes aren't written to the cache.

For example, I add the following:

// astro.config.mjs
export default defineConfig({
    site: SITE_URL,
    integrations: [sitemap(), svelte()],
    markdown: {
        shikiConfig: {
            transformers: [{
                line(line, index) {
                    line.properties['style'] = 'background-color: red';
                    return line;
                }
            }]
        }
    }
});

Then I run npm run build. Then I delete the line line.properties['style'] = 'background-color: red';. Then I build again and preview. The line backgrounds will remain red.

I have tested this on StackBlitz and it's reproducible, but I don't have a Pro account and can't share the project.

What's the expected result?

I expect that npm run build will always output the latest version of the project. In the case above, I expect that the content files are updated to not have lines with red backgrounds if npm run build is executed after that line has been removed.

Link to Minimal Reproducible Example

N/A, read above

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 21, 2025
@ascorbic
Copy link
Contributor

ascorbic commented Jan 21, 2025

Thanks. It should be using the Astro config as part of the cache key, so it should certainly not be behaving as described. You don't need a pro account to share a reproduction. If you use https://astro.new/repro then you can create one that is shareable.

@ascorbic ascorbic added the needs repro Issue needs a reproduction label Jan 21, 2025
Copy link
Contributor

Hello @jachang820. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 21, 2025
@jachang820
Copy link
Author

I'm assuming you mean a link like this: https://stackblitz.com/edit/github-141451nv

The problem is whenever someone spins it up again, it deletes previous builds in the /dist directory, and it will recognize the script the first time. So whoever who runs it needs to delete (or add) a line and rebuild to see what I'm talking about.

@ascorbic
Copy link
Contributor

OK, thanks. The issue is that it compares the serialised config, and the part you changed was in a function so wasn't serialised. You can try changing e.g. the site value at the same time and see that it does update. We may need to hash the actual file contents instead, though that will need some things to be changed.

@ascorbic ascorbic added - P2: has workaround Bug, but has workaround (priority) feat: content layer Related to the Content Layer feature (scope) and removed needs repro Issue needs a reproduction labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) feat: content layer Related to the Content Layer feature (scope)
Projects
None yet
Development

No branches or pull requests

2 participants