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

fs.ensure_symlink throwing error in browser #6132

Closed
QuixThe2nd opened this issue Oct 21, 2024 · 4 comments · Fixed by #6135
Closed

fs.ensure_symlink throwing error in browser #6132

QuixThe2nd opened this issue Oct 21, 2024 · 4 comments · Fixed by #6135
Labels
PR welcome A pull request for this issue would be welcome

Comments

@QuixThe2nd
Copy link
Contributor

Describe the bug

On line 8 of ensure_symlink.ts on-import the script checks if the user is on windows (const isWindows = Deno.build.os === "windows";). Deno however is undefined in browser throwing a fatal error.
image

Steps to Reproduce

  1. Build project with:
import * as esbuild from "npm:esbuild";
await esbuild.build({ plugins: [...denoPlugins()], entryPoints: ["./src/in.ts"], outfile: "./dist/out.js", bundle: true, format: "esm", platform: "browser" });
  1. Import in web:
    <script type="module" src="hydrafiles-web.esm.js"></script>
    <script type="module">
    import Hydrafiles from './hydrafiles-web.esm.js';
    </script>
  1. Error in browser logs

Expected behavior

A check should be done before Deno.build.os === "windows" to first check if user is in Deno environment. For example:

const isWindows = window !== undefined && Deno.build.os === "windows";

Environment

  • OS: N/A
  • deno version: 2.0
  • std version: 0.221.0
@QuixThe2nd QuixThe2nd added bug Something isn't working needs triage labels Oct 21, 2024
@QuixThe2nd
Copy link
Contributor Author

I would have sent a pull request, but I am new to Deno. I'm not confident the error isn't my fault.

@kt3k kt3k removed bug Something isn't working needs triage labels Oct 22, 2024
@kt3k
Copy link
Member

kt3k commented Oct 22, 2024

What is the expected behavior of ensureSymlink in browser?

@QuixThe2nd
Copy link
Contributor Author

What is the expected behavior of ensureSymlink in browser?

If it's imported in a script that runs in both browser and Deno, it throws an error on import. It should instead throw the error when ensureSymlink is called.

@kt3k
Copy link
Member

kt3k commented Oct 22, 2024

It should instead throw the error when ensureSymlink is called.

Ah, ok. That makes sense to me.

@kt3k kt3k added the PR welcome A pull request for this issue would be welcome label Oct 22, 2024
@QuixThe2nd QuixThe2nd changed the title fs.ensure_symlink throwing error in browser fix fs.ensure_symlink throwing error in browser Oct 22, 2024
@QuixThe2nd QuixThe2nd changed the title fix fs.ensure_symlink throwing error in browser fs.ensure_symlink throwing error in browser Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR welcome A pull request for this issue would be welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants