Skip to content

feat: inject preload script directly#2455

Merged
Kitenite merged 19 commits into
mainfrom
refactor/update-preload
Jul 20, 2025
Merged

feat: inject preload script directly#2455
Kitenite merged 19 commits into
mainfrom
refactor/update-preload

Conversation

@spartan-vutrannguyen

@spartan-vutrannguyen spartan-vutrannguyen commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Description

Using a CDN to store the preload script makes development harder, especially with caching issues that can interfere with hotfixes.
→ Instead, inject the preload script every time we start editing a project to ensure it’s always up-to-date with the current version.

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Refactor preload script handling by injecting it directly into the project, ensuring it's always up-to-date and resolving caching issues.

  • Behavior:
    • Inject preload script directly into project instead of using CDN.
    • PreloadScriptManager added to manage script injection in engine.ts.
    • injectPreloadScript() updated to handle script injection in layout.tsx.
  • File Changes:
    • engine.ts: Add PreloadScriptManager.
    • sandbox/index.ts: Ensure preload script file exists on file changes.
    • layout.tsx: Remove CDN script, rely on direct injection.
  • Testing:
    • Add tests in layout.test.ts to verify script injection behavior.
  • Misc:
    • Update package.json to build preload script to public directory.
    • Remove CDN reference from .gitignore.

This description was created by Ellipsis for 345c036. You can customize this summary. It will automatically update as commits are pushed.

@vercel

vercel Bot commented Jul 16, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 20, 2025 2:00am
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 20, 2025 2:00am

@supabase

supabase Bot commented Jul 16, 2025

Copy link
Copy Markdown

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

injectedAt: 0,
};
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical suggestion: The file currently does not end with a newline. It would be best to add a trailing newline at the end of the file.

Comment thread apps/web/client/src/components/store/editor/preload-script-manager.ts Outdated
@Kitenite

Copy link
Copy Markdown
Contributor

It seems like there's a version of layout.tsx where there's no body. In this case, we need a better strategy
https://www.onlook.com/project/42333f3b-e175-4c69-ad84-e0ce184d5804

let layoutPath: string;

if (routerConfig.type === RouterType.APP) {
layoutPath = path.join(routerConfig.basePath, 'layout.tsx');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layout path can be jsx/tsx/js/ts

@ellipsis-dev

ellipsis-dev Bot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@ellipsis-dev

ellipsis-dev Bot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@ellipsis-dev

ellipsis-dev Bot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@ellipsis-dev

ellipsis-dev Bot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@Kitenite Kitenite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some updates, thanks Vu!

@Kitenite
Kitenite merged commit 446c132 into main Jul 20, 2025
6 checks passed
@Kitenite
Kitenite deleted the refactor/update-preload branch July 20, 2025 02:00
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