Multiple instances of Solid #1623
Replies: 3 comments 1 reply
-
I am also trying to bundle a solid component which can be imported in anywhere module.exports = {
mode: "development",
devtool: false,
entry: "main.js",
output: {
path: __dirname,
filename: "bundle.[fullhash].js",
library: {
type: "module",
},
},
experiments: {
outputModule: true,
},
module: {
rules: [
{
test: /\.(jsx?)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
["solid", { generate: "dom", hydratable: true }],
],
},
},
],
},
],
},
}; then using it like this import { lazy } from "solid-js";
export default function Outlet(props) {
const component = lazy(() => import(/* webpackIgnore: true */ "bundle.[fullhash].js"))
return (
<div>
<component/>
<div/>
);
} but i get the warning message
|
Beta Was this translation helpful? Give feedback.
-
If you want to export components to be used in other solid projects, those need to have 1. solid-js as a peer dependency and 2. an extra "solid" export conditions that exposes the jsx code so it can be transpiled by the solid version of the importing project. |
Beta Was this translation helpful? Give feedback.
-
I had this problem as well - one part of the solution is here: solidjs/vite-plugin-solid#112 Set solid-js as peerDependency so it's not bundled in:
I also use Rollup to build my library components - you can see the full repo here: https://github.com/lightning-js/solid |
Beta Was this translation helpful? Give feedback.
-
I want to use individual widgets written in solid.js + solid-element and embed them into an existing web application. Each widget is a separate npm package with its own version of solid.js.
The idea behind this usage is that a widget-package is independent of a particular version of solid.js and may update itself or not be updated at all for a long time.
At the same time, there can be > 1 such widgets on a page at the same time with different versions of the framework under the hood!
For now if i try to use this approach solid.js shows this warning
“You appear to have multiple instances of Solid. This can lead to unexpected behavior.”
At the same time, some widgets work as expected, and ui-kit, which is written according to the principle described above and is used as an npm package inside another widget written in solid.js, behaves unpredictably (problems with reactivity).
Is there a way to isolate the runtime of different versions of solid.js and is it even possible to use the framework in this way?
Beta Was this translation helpful? Give feedback.
All reactions