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

useScript breaking when called in the browser #859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saymondamasio
Copy link
Contributor

@saymondamasio saymondamasio commented Oct 9, 2024

I checked that Deno is not called on the client side.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 1.104.3 update
  • 🎉 for Minor 1.105.0 update
  • 🚀 for Major 2.0.0 update

@viktormarinho
Copy link
Contributor

viktormarinho commented Oct 10, 2024

Some things to note here:

  • $fresh/runtime probably should not be imported in this file, since you can use it independently from the fresh setup (could be changed to if window)
  • useScript should probably not be used in the browser at all; it is importing terser

Makes me conclude that this should be solved via you app's code; unless we do something like a dynamic import checming for window or something along these lines.

@matheusgr
Copy link
Contributor

useScript must fail if run in client side. Its a server side only thing to do.

Maybe you can give a warning and don't run it on client side instead.

import { LRUCache } from "npm:[email protected]";
import { minify as terserMinify } from "npm:[email protected]";

const verbose = !!Deno.env.get("SCRIPT_MINIFICATION_DEBUG");
const verbose = !IS_BROWSER && !!Deno.env.get("SCRIPT_MINIFICATION_DEBUG");
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that this function should not run client side.

Maybe if it is run at clientSide, throw an exception and stop it execution.

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.

3 participants