Reputation: 2307
I'm developing a web application whereby a React client
application and Node Express server
API live in the same repository, but with separate package.json
files. The structure is as follows:
root
-client/
--src/
--package.json // manages create-react-app dependencies, scripts
-controllers/
-models/
-routes/
-app.js
-package.json // manages node express server dependencies, scripts
Seemingly, these separate packages are sub-modules of a system (ie of the web application). For example, consider the way routing is handled where any request that the server doesn't recognize is handled by a client
router:
// app.js
require('./routes/...')(app) // api routes defined first
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'))
const path = require('path')
app.get('*', (req, res) => { // non match fall through to client
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
})
}
The server API does not have cors enabled.
Should these package.json
files share the same version, or be versioned separately?
Upvotes: 2
Views: 107
Reputation: 6659
Each package should be versioned separately. Tying them to the same version number means a simple bug fix in one, requires a meaningless version bump in the other. Don't lie to your customers! A package version number applies to its contents and only its contents. Even a package of packages should have its own version sequence.
Optionally, you could simply ship a single package instead.
Upvotes: 2