Skip to content

Conversation

@Wituareard
Copy link
Collaborator

No description provided.

@netlify
Copy link

netlify bot commented Jun 23, 2025

Deploy Preview for pauseai ready!

Name Link
🔨 Latest commit 9906bf8
🔍 Latest deploy log https://app.netlify.com/projects/pauseai/deploys/6859b77f5524250008126b90
😎 Deploy Preview https://deploy-preview-379--pauseai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Wituareard Wituareard changed the title Use vite flag for Paraglide isServer check #373 Use vite flag for Paraglide isServer check Jun 23, 2025
@Wituareard Wituareard linked an issue Jun 23, 2025 that may be closed by this pull request
@Wituareard
Copy link
Collaborator Author

@anthonybailey wdyt? Had to use a workaround to import the runtime outside Vite-processed code

@Wituareard Wituareard requested a review from anthonybailey June 23, 2025 20:32
@Wituareard Wituareard marked this pull request as ready for review June 23, 2025 20:32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Heh, we also both fixed this and the other endpoint TS error at the same time. I committed six minutes later, and didn't notice it merged because 585de1d had a tiny Tally warning fix too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the result of the broken Git configuration on one of my machines, I tried to merge from main

typeof import('../../src/lib/paraglide/runtime.js')
> {
const runtimeString = await fs.readFile('src/lib/paraglide/runtime.js', 'utf-8')
const patchedRuntime = runtimeString.replace('import.meta.env.SSR', 'true')
Copy link
Collaborator

Choose a reason for hiding this comment

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

So let me say this out loud? The scripts that call importRuntimeWithoutVite are clobbered so that if isServer was checked by the runtime in the course of its methods being called, it acts the same as it does when running as a server rather than running as a build.

(Presumably because SSR does not end up in the environment. I get it, and sorry.)

But... shouldn't it really be false? It gets used in a build context.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replied in the main thread

Copy link
Collaborator

@anthonybailey anthonybailey left a comment

Choose a reason for hiding this comment

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

As per individual comments, I get the ugly hack and need for it, but should it really be "true" we hardcode when the flag is missing?

@Wituareard
Copy link
Collaborator Author

Replacing with a static value is what Vite does as well and what enables tree-shaking. I guess the behavior for "runs during build" isn't defined because that isn't something Vite-processed code ever does. The docs say it indicates "runs on the server" because presumably it's meant to check for the existence of a server environment / the absence of a browser environment. But in the contexts where the file is actually imported it doesn't really matter I think so we can also set it to false.

@Wituareard
Copy link
Collaborator Author

@anthonybailey Can I merge this tonight?

@anthonybailey
Copy link
Collaborator

Sure. The Boolean value was the only query I had, really.

I advocate force pushing to l10-preview to see things work in non-en locales under true Netlify as well as the obvious checks of the PR preview in main's en-only mode.

But if all was well under "netlify serve" that seems likely.

I'll approve with that said.

Copy link
Collaborator

@anthonybailey anthonybailey left a comment

Choose a reason for hiding this comment

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

As per thread. Fine given multiple locale testing.

@Wituareard
Copy link
Collaborator Author

Alright, finally tested it on the preview branch and everything seems to work

@Wituareard Wituareard merged commit 27d6c6d into main Jul 1, 2025
7 checks passed
@anthonybailey
Copy link
Collaborator

Thanks!

@Wituareard Wituareard deleted the isserver-vite branch July 7, 2025 18:49
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.

Use vite flag for Paraglide isServer check

3 participants