Git Product home page Git Product logo

Comments (8)

whaaaley avatar whaaaley commented on June 18, 2024 1

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.

frenzzy avatar frenzzy commented on June 18, 2024

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.

whaaaley avatar whaaaley commented on June 18, 2024

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.

frenzzy avatar frenzzy commented on June 18, 2024

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.

whaaaley avatar whaaaley commented on June 18, 2024

I've added the browser: true option but it doesn't seem to have any effect.

from hyperapp-render.

frenzzy avatar frenzzy commented on June 18, 2024

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.

whaaaley avatar whaaaley commented on June 18, 2024

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.

frenzzy avatar frenzzy commented on June 18, 2024

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)

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.