-
Notifications
You must be signed in to change notification settings - Fork 781
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
Import from Node.js #952
Comments
Alright that would be great! I'm trying to server-side render hyperapp. Btw. if it helps any with ideas of setting this up I have a package that I publish in both commonjs and esm form too using rollup, relevant:
|
@Siilwyn you don't need to import Hyperapp on server-side. You can use hyperapp-render to stringify your hyperapp views on server-side. An example of how this can be implemented you can find in hyperapp-starter. |
@Siilwyn What's your strategy for server-side rendering Hyperapp? |
What @frenzzy just mentioned, using Also yes I do need to import Hyperapp on server-side because I need access to |
@Siilwyn Nothing other than duplicating the view code as HTML and serving it. But I'm definitely curious too. 👍 |
Slightly off-topic: |
ES syntax works fine with Node.js with 14.13.1 and 15.0.1 this works: // app.mjs or "type": "module" in package.json
import { h } from 'hyperapp' |
I'm currently trying to write unit tests for my Hyperapp views, but requiring Hyperapp from the Node-based Jasmine CLI causes it to fail as Jasmine won't load any file not ending .mjs as a module. Currently experimenting with creating a mirror package which has its JS files transpiled. |
I've not really tested it yet but here's my bodge: |
We can import Hyperapp as an ES module in Node like in this test. 🙆♂️ |
👋 trying to import hyperapp in Node.js doesn't seem to work?
To reproduce first run
mkdir hyperapp-import; cd hyperapp-import; npm i hyperapp
.Then either require with CommonJS:
node -e 'require("hyperapp")'
, which results in:Or import using ESM by saving
import hyperapp from 'hyperapp';
in atest.mjs
file followed bynode test.mjs
, logging:The text was updated successfully, but these errors were encountered: