Second component instantiation has no owner when under vinxi start in a npm linked component

Anyone tried linked components? I have a reproduction where getOwner() goes null and this happens in an application I'm upgrading from solid-start 0.3.11 (worked under pnpm link). Seems like this would be something in vinxi, but I'm not sure. Could there be an issue in Solid-Js?
https://github.com/nksaraf/vinxi/issues/473 I'm simply using npm i --save ./cmp which saves the folder as a file link "file:cmp" in package.json. Then (in the reproduction), I installed solid-js in cmp and create a component that logs getOwner() and then I included that component in the parent solid starter route/index.tsx.
GitHub
Second component instantiation has no owner when under `vinxi start...
Go to the reproduction: https://stackblitz.com/edit/github-28x64bqv-jpputvnc?file=cmp%2FCmp.tsx Open the browser's console (the stackblitz console is not enough) Notice, in the browser's co...
8 Replies
slim (jamesc)
slim (jamesc)OP2w ago
I think I figured it out. It looks like linked components are now treated as external. I can fix it using vite.ssr.noExternal: ['cmp'].
peerreynders
peerreynders2w ago
https://vite.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
However, this requires the linked dep to be exported as ESM.
I'm noticing that cmp/Cmp.tsx is simply TypeScript but the package.json doesn't identify it as ESM with type: module. Not sure if could have anything to do with your problem … but I figured I'd mention it (Your stackblitz example doesn't exhibit the behaviour that you describe in the issue for me).
vitejs
Dependency Pre-Bundling
Next Generation Frontend Tooling
slim (jamesc)
slim (jamesc)OP2w ago
It is working for me to. I have a package-lock.json at stackblitz and I ran it several times in a chromium Cognito window and saw the error. Not sure if re-saving changing things, but I did not re-save anything. But now it works, not in my project, but only at stackblitz. I know for sure I do not have an alter ego! Ok, thanks for checking. My actual project is linking to packages where type: module.
slim (jamesc)
slim (jamesc)OP2w ago
Ok, I have updated stackblitz. Can you please check again? Stackblitz did not save cmp/node_modules .. So, I added build.sh that installs that first. https://stackblitz.com/edit/github-28x64bqv-nnabt8gs?file=src%2Froutes%2Findex.tsx,app.config.ts,build.sh
No description
peerreynders
peerreynders2w ago
1. About StackBlitz:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '>=22' },
npm WARN EBADENGINE current: { node: 'v18.20.3', npm: '10.2.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '>=22' },
npm WARN EBADENGINE current: { node: 'v18.20.3', npm: '10.2.3' }
npm WARN EBADENGINE }
Sure this is a client side issue but a mismatch in node version could have undesirable consequences during the build. 2. Based on your issue description (to expect 3 Cmp hasOwner true) I would have expected 3 <Cmp /> in the JSX on src/routes/index.tsx but there is only one:
import { Title } from '@solidjs/meta';
import Counter from '~/components/Counter';
import { Cmp } from 'mycmp/Cmp';

export default function Home() {
return (
<main>
<Title>Hello World</Title>
<h1>Hello world!</h1>
<Counter />
<p>
Visit{' '}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{' '}
to learn how to build SolidStart apps.
</p>
<p>
C: <Cmp />
</p>
</main>
);
}
import { Title } from '@solidjs/meta';
import Counter from '~/components/Counter';
import { Cmp } from 'mycmp/Cmp';

export default function Home() {
return (
<main>
<Title>Hello World</Title>
<h1>Hello world!</h1>
<Counter />
<p>
Visit{' '}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{' '}
to learn how to build SolidStart apps.
</p>
<p>
C: <Cmp />
</p>
</main>
);
}
But even after I added two more I only ever saw Cmp hasOwner true after a build and running with start (Incognito). 3. Downloaded from StackBlitz - Installed both under root and cmp with pnpm 10.4.1 - Added two more Cmp to src/routes/index.tsx - Built and ran with node .output/server/index.mjs (node: v22.14.0) Again Cmp hasOwner true all around in the browser's console.
slim (jamesc)
slim (jamesc)OP2w ago
Yes, I had only one just like you saw but I got 3 log messages, sometimes I see 2.. unpredictable. How do I change node versions? Also, you will only see 1 if your looking at the StackBlitz terminal. pnpm i (cmp first then project if it matters) under node v18 works. Everything I tried with npm i did not work. The difference is between pnpm picked up rollup 4.37.0 and npm picked up rollup 4.36.0. If I override to rollup 4.37.0 in the root package I can use npm and it works. The next issue is, my packages are in ../cmp not ./cmp and it breaks again! Arrr.. I guess I have to figure out how to explain this to rollup..
peerreynders
peerreynders2w ago
In my survey yesterday some solutions over the years https://stackoverflow.com/questions/67964556/cant-support-npm-link-added-local-package-in-vite-cli#answer-78508257 seemed to use external on rollup. Not saying it applies to your particular case …
Rollup
The JavaScript module bundler
Stack Overflow
can't support "npm link" added local package in vite-cli
I use the "npm link my-package" to redirect my node_module. But I failed to run successfully with "vite dev". Vite Could not resolve my local private package. Uncaught TypeError:
slim (jamesc)
slim (jamesc)OP2w ago
Here is a summary, hope that helps explain things (until it is out of date). Notably: if I had ran into a simple check if(globalThis.createSignal && globalThis.createSignal !== createSignal) { console.error('ERROR, two solid-js versions detected');} else globalThis.createSignal = createSignal, it would have saved me a lot of confusion. https://github.com/nksaraf/vinxi/issues/473#issuecomment-2747949714

Did you find this page helpful?