Doesn't seem to work with Deno · Issue #93 · hyperhype/hyperscript · GitHub
Skip to content

Doesn't seem to work with Deno #93

Open

Description

@vikanezrimaya

Deno is a new JS server environment that was created from ground up in attempt to fix Node.js's drawbacks. It looks like this library somehow confused it with a browser (uses process to distinguish Node and browser probably?) Deno doesn't have process, it has its own Deno object in the global namespace, and it uses ES6 modules and not NPM packages.

Hyperscript is small, compact and relatively self-contained, just like Deno. I think they would play together rather nicely.

Activity

  1. rschristian commented on Nov 17, 2020

    @rschristian

    Hyperscript does not check for process, it does a standard window check to determine browser vs Node:

  2. jsejcksn commented on Jul 22, 2021

    @jsejcksn

    it does a standard window check to determine browser vs Node:

    This is an older assumption that window means "browser". Deno also has globalThis.window.

    The next line is where the assumption goes wrong:

    hyperscript/index.js

    Lines 4 to 5 in 4c0d558

    (If environment is unknown, each feature should be tested before being used.)

    All that being said, Hyperscript predates Deno by quite a bit, back in a time where a JavaScript "client" meant "browser" and "server" meant "Node.js".

    @kisik21 Deno doesn't have any DOM support yet, so it would need to provide that feature before something like hyperscript could support it as an environment.

  3. vikanezrimaya commented on Jul 23, 2021

    @vikanezrimaya
    Author

    In Node there's html-element used to simulate a minimal DOM enough to make HTML. If the check in L4-5 is changed to detect absence of window.document instead of just window (which Deno has, unlike Node), then one could easily make it work with Deno via a proxy that rewrites requires to ES6 imports (that's how I originally tried to launch this package, and it would've worked if the check didn't failed.

    I may try to make a PR in the near future. Something like extending the L5 with var document = typeof w.document === 'undefined' ? require('html-element') : w.document - should probably make it work with Deno after rewriting imports.

  4. jsejcksn commented on Jul 23, 2021

    @jsejcksn

    should probably make it work with Deno after rewriting imports

    @kisik21 It's a little more complicated than that. Neither html-element nor its chain of npm dependencies provide ES modules (they only support CommonJS). Because Deno only supports esm with explicit specifiers, you'd have to refactor every module in every dependency (and dependency of dependency... and so on: all the way to the end of the module graph) to that format.

    If you don't want to go that route, you could look at other community modules for DOM in Deno (e.g. https://deno.land/x/deno_dom).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions