Git Product home page Git Product logo

Comments (3)

Jarred-Sumner avatar Jarred-Sumner commented on May 18, 2024

@BeyondMagic text does have a loader.

A possible workaround: start Bun with bun --loader=.html:text ./path.ts

from bun.

BeyondMagic avatar BeyondMagic commented on May 18, 2024

Hello, @Jarred-Sumner, you are right! Although I should have specified it better, using the text loader in a custom plugin does not work! It gives the following error:

1 | (function (entry, parameters, fetcher)
                        ^
error: Expected loader to be one of "js", "jsx", "object", "ts", "tsx", "toml", or "json"
      at requestFetch (:1:21)
      at requestInstantiate (:1:21)
      at requestSatisfyUtil (:1:21)
1 | (function (entry, parameters, fetcher)

I have no desire not work on this, if you give a guidance to where to look at, I'll attempt to fix #5710.


A possible workaround: start Bun with bun --loader=.html:text ./path.ts

This works for loading the content of the HTML files as text and no need for a plugin! Thanks.

However, the issue at hand persists when using --hot, if I save the file using a text editor, what happens is probably what you described here and Bun still crashes! Without debug, the following log is given and I have to force-exit the CLI:

error: Cannot find module "./page.html" from "/home/dream/projects/personal/wdwad/index.ts"

This seems rather trickier to solve, I tried adding std.time.sleep(5000000000); in many HotReload functions in the source-code, in loops of WatchList for example, and still after the 500 milliseconds it still crashes! The problem seems to occur before, when it is signaled by inotify of changes.

from bun.

BeyondMagic avatar BeyondMagic commented on May 18, 2024

Possible workarounds:

  1. The problem can be mitigated in vim or neovim using :set noswapfile as shown by @brw.

  2. The problem can be further mitigated adding a delay of 50 miliseconds into the function reload of /src/watcher.zig and compiling the debug version.

diff --git a/src/watcher.zig b/src/watcher.zig
index 55d160ae9..61b70de14 100644
--- a/src/watcher.zig
+++ b/src/watcher.zig
@@ -128,6 +128,7 @@ pub const INotify = struct {
         std.debug.assert(loaded_inotify);
 
         restart: while (true) {
+            std.time.sleep(50000000);
             Futex.wait(&watch_count, 0, null) catch unreachable;
             const rc = std.os.system.read(
                 inotify_fd,

from bun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.