-
-
Notifications
You must be signed in to change notification settings - Fork 189
WIP: tidy up dependencies #418
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
Conversation
08bd75d
to
e901c8a
Compare
e901c8a
to
c3a34e6
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c3a34e6:
|
export const REACT_DOM_VERSION = rootPackageJson.dependencies[ | ||
export const REACT_DOM_VERSION = rootPackageJson?.dependencies?.[ | ||
'react-dom' | ||
].replace(/[^0-9.]/g, ''); | ||
]?.replace(/[^0-9.]/g, '') || '18.0.0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this code will work outside of the monorepo as rootPackageJson
may not exist?
Seems like this could cause issues. Is there another way of getting this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just expose a injectIntoDevTools
function that the user has to call manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this line, but to the whole file.
- I am pretty sure
version
passed toinjectIntoDevTools
doesn't need to be the version of ReactDOM any more. See:
1.1. Advertise a React-equivalent version number to the React DevTools pmndrs/react-three-fiber#1231
1.2. Reconciler should inject its own version into DevTools hook facebook/react#21268
1.3. DevTools should use reconciler version (rather than renderer version) facebook/react#21269 - Please check if the
package.json
file imports are removed from the bundle. From my experience with rollup when I encountered this issue they were not. This increased bundle size unnecessarily. We can provide values read from package json file with thereplace
rollup plugin similar to__DEV__
value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zyie does the code need to work outside of a monorepo? There's already quite a few things that depend on it being inside a monorepo - eslint, jest config and rollup config to name a few. I agree this code is nasty though. We could install React inside just this package, but because almost all the packages depend on it (as with other shared dependencies) I've listed them in the root package.json
to keep versioning easier to manage.
- From your links It appears that the
version
needs to be the current "React version" whether from DOM or React. - I can confirm that right now the whole
package.json
file was being bundled into the build. But in my Typescript PR, it wouldn't let me do an import from outside the package anyway, so I've already written a script to handle this situation and write a json file inside the src dir: https://github.com/pixijs/pixi-react/pull/412/files#diff-68eaf1ddcab994998bf4397fbcd8f7685590ac3760239880627679d5141c3ff4
@@ -2,7 +2,7 @@ import React from 'react'; | |||
import * as PIXI from 'pixi.js'; | |||
import * as ReactPixi from '@pixi/react'; | |||
import * as ReactPixiAnimated from '@pixi/react-animated'; | |||
import { Spring } from 'react-spring'; | |||
import { Spring } from '@react-spring/web'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the docs i also used react-spring/web
. The internet said this was better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah for sure! That would also likely remove some npm install errors as some of the other react spring packages have old peer deps. We should likely do this everywhere!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry lots of questions here! But I'm curious about why you've made some of the changes? 😄
packages/animated/package.json
Outdated
"dependencies": { | ||
"@pixi/react": "*" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is one case that should be a peer dependency shouldn't it? It adds additional functionality on top of pixi-react
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I thought this package was meant to be used instead of pixi-react
So you would only install @pixi/react-animated
not both?
Maybe I misunderstood
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the intention is you install both of them together. @pixi/react-animated
is a very small wrapper around the normal lib.
"@testing-library/react": "^13.4.0", | ||
"canvas": "^2.11.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this needed for tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see it being used anywhere?
I just see jest-webgl-canvas-mock
being used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look, it was already in the original codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a peer dependency of js-dom
: https://github.com/jsdom/jsdom/blob/master/package.json#L51 but the tests seem to run OK without it 🤔
package.json
Outdated
"dependencies": { | ||
"@babel/runtime": "^7.14.8", | ||
"@pixi/app": "^7.1.1", | ||
"@pixi/constants": "^7.1.1", | ||
"@pixi/core": "^7.1.1", | ||
"@pixi/display": "^7.1.1", | ||
"@pixi/extensions": "^7.1.1", | ||
"@pixi/graphics": "^7.1.1", | ||
"@pixi/math": "^7.1.1", | ||
"@pixi/mesh": "^7.1.1", | ||
"@pixi/mesh-extras": "^7.1.1", | ||
"@pixi/particle-container": "^7.1.1", | ||
"@pixi/sprite": "^7.1.1", | ||
"@pixi/sprite-animated": "^7.1.1", | ||
"@pixi/sprite-tiling": "^7.1.1", | ||
"@pixi/text": "^7.1.1", | ||
"@pixi/text-bitmap": "^7.1.1", | ||
"@pixi/ticker": "^7.1.1", | ||
"@react-spring/animated": "^9.6.1", | ||
"@react-spring/types": "^9.6.1", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"react-spring": "^9.6.1" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I don't entirely love either way of doing it, I'd deliberately added these shared packages to the root so it was easier to keep track of versioning across the whole monorepo, rather than specifying potentially separate versions in each package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reasoning for this was that if we have a v6 component package and eventually a v8 package we would need to have individual packages defining there pixi versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point 👍
"jest-webgl-canvas-mock": "^0.2.3", | ||
"prop-types": "^15.8.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in the Stage
component isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is, that is why it was moved to a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed that 👍
"devDependencies": { | ||
"react-reconciler": "~0.29.0" | ||
}, | ||
"peerDependencies": { | ||
"react-reconciler": "^0.29.0" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the react-reconciler
is actually currently bundled into the library code (and always has been AFAIK) - so I'm not sure we need it as a peer dep do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh is the rollup config bundling devDependencies and not setting them as external?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually managing external
libraries manually at the moment, perhaps I should move to your script but still override it in this case. I'll double check how this was done before and how react-three-fiber
does it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react-three-fiber
actually uses preconstruct which looks interesting. Anyway, they don't bundle it in, they just list it as a normal dependency
so we can do the same
packages/react/package.json
Outdated
"devDependencies": { | ||
"dependencies": { | ||
"@pixi/react-components": "*", | ||
"@pixi/react-fiber": "*", | ||
"@pixi/react-invariant": "*", | ||
"@pixi/react-modular": "*", | ||
"@pixi/react-modular": "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are bundled into the @pixi/react
dist as a single package so we don't need them as dependencies do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have misunderstood again how rollup is working in this project
Do we need to bundle everything into this package?
I feel like this should work more like pixi where the main pixi.js
package is just a wrapper for a whole bunch of dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps not, we could try it without bundling here, I guess I was just trying to emulate how the original package worked in spitting out a single build file and anyone that needed to configure things separately still could by importing the individual modules.
packages/react/package.json
Outdated
"@pixi/math": ">=6.0.0", | ||
"@pixi/app": ">=6.0.0", | ||
"@pixi/ticker": ">=6.0.0", | ||
"@pixi/display": ">=6.0.0", | ||
"@pixi/core": ">=6.0.0", | ||
"@pixi/sprite-animated": ">=6.0.0", | ||
"@pixi/text-bitmap": ">=6.0.0", | ||
"@pixi/graphics": ">=6.0.0", | ||
"@pixi/mesh-extras": ">=6.0.0", | ||
"@pixi/particle-container": ">=6.0.0", | ||
"@pixi/constants": ">=6.0.0", | ||
"@pixi/sprite": ">=6.0.0", | ||
"@pixi/text": ">=6.0.0", | ||
"@pixi/sprite-tiling": ">=6.0.0", | ||
"prop-types": ">=15.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't 100% about this, but I added these here because I believe that peerDependencies
, unlike other deps, aren't transitive? That is npm won't install the peerDependencies
of a project's dependency or devDependency. Seeing as the intention here is that most users will only install and consume the single @pixi/react
package, I thought we'd want to make sure that these were also installed for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong about this but i believe the issue you ran into was that @pixi/react didn't define @pixi/react-components as a dependency because its getting bundled here
This meant that when you installed @pixi/react it didn't install @pixi/react-components and therefore didn't add the pixi peer dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that's not the case: https://dev.to/arcanis/implicit-transitive-peer-dependencies-ed0
It's not the end of the world to add them here too I don't think, it just means we need to be careful about making sure they match with the latest version of react-components-pixi-vX
I just had a thought, is the use of a single package (and package.json
) with versioned subfolders going to cause us a problem here for react-fiber
and react-components
?
}, | ||
"gitHead": "6d5b98bc6d7eafd1b0016e60a725b2b6c9f46a33" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These get added automatically by lerna during publish: lerna/lerna#1880
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh strange this didn't happen for pixi or assetpack 🙁
No description provided.