solidjs / vite-plugin-solid

A simple integration to run solid-js with vite
440 stars 51 forks source link

Installing CesiumJS package breaks solidPlugin #63

Closed Marvosg closed 2 years ago

Marvosg commented 2 years ago

After installing the Cesium JS package, solidPlugin breaks. Starting the dev server exits with the error:

D:\NodeJSProjects\myProject>npm run dev 

> vite-template-solid@0.0.0 dev
> vite

error when starting dev server:
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at containsSolidField (D:\NodeJSProjects\myProject\node_modules\vite-plugin-solid\dist\cjs\index.cjs:33:23)
    at containsSolidField (D:\NodeJSProjects\myProject\node_modules\vite-plugin-solid\dist\cjs\index.cjs:38:44)
    at D:\NodeJSProjects\myProject\node_modules\vite-plugin-solid\dist\cjs\index.cjs:85:39
    at Array.reduce (<anonymous>)
    at getSolidDeps (D:\NodeJSProjects\myProject\node_modules\vite-plugin-solid\dist\cjs\index.cjs:84:15)
    at config (D:\NodeJSProjects\myProject\node_modules\vite-plugin-solid\dist\cjs\index.cjs:106:25)
    at runConfigHook (file:///D:/NodeJSProjects/myProject/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63556:31)
    at resolveConfig (file:///D:/NodeJSProjects/myProject/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63076:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Steps to reproduce:

npx degit solidjs/templates/ts solid-plugin-cesium-bug-example
cd solid-plugin-cesium-bug-example
npm i
npm run dev

At this point the server builds and loads fine. Close it, then:

npm i cesium
npm run dev

Is it solidPlugin or Cesium that needs changes? Cesium maps are crucial for my use case, it would be really great if I could use them in my existing project, as I've got the whole scaffolding for loading my custom data already done in SolidJS.

mosheduminer commented 2 years ago

I suspect this is a bug with this line https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L256, which checks if the type is "object", but null can still pass that check, the plugin probably just needs an extra check to test whether the value is null.

Marvosg commented 2 years ago

@mosheduminer Thank you for the help! I will attempt to add a null check there, and report back.

lxsmnsyc commented 2 years ago

Made a PR: https://github.com/solidjs/vite-plugin-solid/pull/65

Marvosg commented 2 years ago

@lxsmnsyc Can confirm this fixes the issue.

Thanks to both of you for your help!

ryansolid commented 2 years ago

Ok this should be fixed in 2.3.10