-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"React is not defined" error in dependency of dependency #41
Comments
I also got the same error after upgrading version 2.3.1 or higher. This is my package.json: {
"name": "fe",
"private": true,
"version": "0.0.0",
"description": "",
"license": "ISC",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"lint": "pnpm run lint:ts && pnpm run lint:style",
"lint:ts": "eslint . --ext .ts,.tsx",
"lint:style": "stylelint '**/*.{css,scss,sass}'",
"lint:commit": "",
"lint:write": "eslint --cache --fix --ext .js,.jsx,.tsx,.ts",
"prepare": "husky install"
},
"dependencies": {
"@solidjs/router": "^0.4.3",
"konva": "^8.3.12",
"solid-js": "^1.5.5"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@types/node": "^18.7.18",
"@typescript-eslint/parser": "^5.37.0",
"autoprefixer": "^10.4.11",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-solid": "^0.7.3",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"postcss": "^8.4.16",
"postcss-scss": "^4.0.5",
"postcss-syntax": "^0.36.2",
"prettier": "^2.7.1",
"stylelint": "^14.11.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^9.0.0",
"stylelint-config-tailwindcss": "^0.0.6",
"tailwindcss": "^3.1.8",
"typescript": "^4.8.3",
"vite": "^3.1.2",
"vite-plugin-solid": "^2.3.0"
},
"lint-staged": {
"*.(ts|tsx|js|jsx)": [
"yarn run lint:write"
],
"*.{css,scss}": [
"stylelint"
]
}
}
|
This should be fixed in the last couple 2.3.x releases. |
I'm getting this error again, with Nx 16 and vite-solid-plugin ^2.7.0. @thetarnav what is the "my-lib" that you excluded? I tried excluding the other package that I have that uses React (and not Solid) but that didn't work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that during development the solid babel transform doesn't reach .jsx dependencies if they are being used in .js dependencies.
So as a library author, even if I'm not shipping JSX, but the dependency I'm using does, I need to have a .jsx export too?
For example here,
index.js
in my library file,dev.js
is solid andpresence.jsx
is a dependency with JSX. And I get this error, which doesn't appear if I'm using the JSX dependency directly.I know that the "solution" is to just ship .jsx (solid) export too, but it feels wrong to be worrying about those things when I'm not shipping JSX. Especially when it's not hard to make mistakes here, that are hard to track down.
Will try to make a simple repro soon, but I think this is a known issue.
Update:
Adding this to vite.config solves the problem:
The text was updated successfully, but these errors were encountered: