Comments (8)
Gotcha. That makes sense! I wasn't really thinking what the use case of mainFields
was actually for. I only used it to get around the symlink issue.
from hyperapp-render.
Hi! Just use import { renderToString } from 'hyperapp-render'
, it will automatically import node version for node.js and browser version for all other environments.
import { renderToString } from 'hyperapp-render/browser'
wasn't documented.
from hyperapp-render.
Gotcha! It seems to work fine however rollup is warning me about an unresolved dependency.
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
stream (imported by node_modules/hyperapp-render/esm/node.js)
I'm using rollup then running the output in node. I think this is why I opted to use 'hyperapp-render/browser'
directly.
from hyperapp-render.
With rollup you have to use browser: true
option for @rollup/plugin-node-resolve
plugin:
const nodeResolve = require('@rollup/plugin-node-resolve')
// ...
plugins: [nodeResolve({ browser: true })]
from hyperapp-render.
I've added the browser: true
option but it doesn't seem to have any effect.
from hyperapp-render.
It should work. Maybe you have multiple rollup configurations and didn't apply plugin for all. Hard to help without seeing the code :)
Alternatively you can change import again, but it may change in minor versions in the future:
import { renderToString } from 'hyperapp-render/esm/browser.js'
// or
const { renderToString } = require('hyperapp-render/commonjs/browser.js')
from hyperapp-render.
Perfect. This one seemed to work without a warning. 👍
import { renderToString } from 'hyperapp-render/esm/browser'
Fwiw, this is the command I'm running, so I'm positive the config is getting added. Maybe it's something with the --format
flag?
rollup src/index.js --config --format cjs | node > public/index.html
This is a gist of my full config (without browser: true
but I did try it, promise 😬):
https://gist.github.com/whaaaley/6029e6ba3b873c0bf7111c2cae6fdc0d
from hyperapp-render.
Looks like you are overriding mainFields
:
resolve({
mainFields: ['module'] // 1
})
should be
resolve({ mainFields: ['browser', 'module'] })
// or
resolve({ browser: true })
from hyperapp-render.
Related Issues (5)
- renderToNode (or renderToElement) HOT 5
- Usage with Hyperapp 2 HOT 9
- Broken support for ^2.0.9 HOT 2
- Usage of innerHTML HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyperapp-render.