Skip to content

Importing solid-js/web (as ESM, from Node.js) throws a SyntaxError #1984

@vinsonchuong

Description

@vinsonchuong

Describe the bug

When I import solid-js/html as an ES module from Node.js, I get the following error:

SyntaxError: The requested module 'solid-js/web' does not provide an export named 'Aliases'

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

For example, in the Node.js REPL:

>> node
Welcome to Node.js v21.1.0.
Type ".help" for more information.
> await import('solid-js/html')
file:///home/vinsonchuong/projects/test-tube/node_modules/solid-js/html/dist/html.js:15
  Aliases,
  ^^^^^^^
Uncaught:
SyntaxError: The requested module 'solid-js/web' does not provide an export named 'Aliases'

Expected behavior

I expect the import to succeed and not throw an error.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Running in Node.js v21.1.0
  • Version: 1.8.7

Additional context

I'm looking to write some custom tooling for writing automated tests from Node.js and was surprised to see this error.

After some searching, I found this issue: #1483, which clued me into the fact that there are separate builds for the browser and for Node.js.

It looks like because the html tag function returns a DOM Node, solid-js/html is a browser-only package. I am, however, able to proceed if I configure Node.js to prefer browser packages:

>> node --conditions browser
Welcome to Node.js v21.4.0.
Type ".help" for more information.
> await import('solid-js/html')
[Module: null prototype] { default: [Function: html] }

Because solid-js/html imports solid-js/web, there's no way to specify that the browser packages should be used without passing in arguments to Node.js. To make this easier, could solid-js/html directly import the browser build of solid-js/web instead? There are probably trade-offs to doing that, but I'm hoping to have easy ways to run Solid from a Node.js + JSDOM environment.

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