solid: Comp is not a function

I created this repo: https://github.com/Seanmclem/solidjs-router

It’s a simple SPA router implementation for solid-js. It works well locally in my solid-js boilerplate, but when I try to build it and distribute/consume it as an npm module, and use it in my boilerplate project as an npm module - I get this error.

Comp is not a function

The error is triggered here, in core solid-js code

function createComponent(Comp, props, dynamicKeys) {
  if (dynamicKeys) {
    for (let i = 0; i < dynamicKeys.length; i++) dynamicProp(props, dynamicKeys[i]);
  }

  return Comp(props);
}

I’m using rollup to try and do the transpilation -seen in another repo here. It seemed to come out correctly, but something is not working. I’d appreciate any help or fixes you can offer.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

You might want to look at something like solid-element. The .gitignore is configured to not commit build files (under ./dist or ./lib) and only the source. The .npmignore doesn’t include /src or /test. Notice the entry points in the package.json, with main being a commonjs build and module being a es6 build. You have some options there, might not need commonjs. I was doing to support some non-build node environments, but with the JSX it is probably unlikely to be necessary.

For your library I’d set solid-js in peerDependencies not a dependencies and put the rest of your deps under devDependencies. From there you just have to tell npm to build on publish. I use the prepublishOnly under scripts. This will automatically create your build as part of your submission to npm… ie. it runs when you run npm publish.

I mean there are a lot of details like that. I hope some of that helps.

If it is not iife you shouldnt need to set globals.