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)
You might want to look at something like solid-element. The
.gitignoreis configured to not commit build files (under./distor./lib) and only the source. The.npmignoredoesn’t include/srcor/test. Notice the entry points in thepackage.json, withmainbeing a commonjs build andmodulebeing 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-jsinpeerDependenciesnot adependenciesand put the rest of your deps underdevDependencies. From there you just have to tell npm to build on publish. I use theprepublishOnlyunderscripts. This will automatically create your build as part of your submission to npm… ie. it runs when you runnpm 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.