solid-hackernews icon indicating copy to clipboard operation
solid-hackernews copied to clipboard

Current rollup config and build commands do not build successfully

Open mitchell-wallace opened this issue 5 months ago • 0 comments

This is like my second time creating a github issue for anything so be merciful if my issue format isn't right :)

The readme says to just run npm install and npm run start. Currently this needs to be npm install --use-legacy-peer-deps but that should be expected with older projects. However, npm run start seems to just serve a file list.

Image

I figured this probably means we need to build first, so I run npm run build. This gives a rollup error:

[!] RollupError: Node tried to load your configuration as an ES module even though it is likely CommonJS. To resolve this, change the extension of your configuration to ".cjs" or pass the "--bundleConfigAsCjs" flag.

Original error: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '...\solid-hackernews\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

Looking in the rollup config, these are the last two imports:

import url from "url";
const pkg = require("./package.json");

Most imports are mjs style with a single cjs import at the end which eslint thinks is unused, so I tried commenting it out and trying again. Then I get this error:

(!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
[!] (plugin babel) Error: Cannot find package '@babel/plugin-proposal-optional-chaining' imported from ...\solid-hackernews\babel-virtual-resolve-base.js

I don't really have experience with configuring Rollup or Babel so I'm not sure how to fix this. If it's fairly straightforward to fix then this might make it a bit easier for people to learn solidjs. Thank you.

mitchell-wallace avatar Aug 06 '25 02:08 mitchell-wallace