Can't use yarn build command
Closed this issue · 4 comments
Hello @ojkelly
I recently migrate successfully my project from Yarn 1 to Yarn 3
After a yarn install
which worked like a charm, the yarn build
command returns me an empty success.
`[ Summary ]---------------------------------------------------------------------
Success: 0
Fail:0
Total: 0
Runtime (wall): 0.01s
[ build finished ]--------------------------------------------------------------
➤ YN0000: Done in 0s 62ms`
The yarn bundle
command is working fine.
Maybe there is something wrong in my package.json
{
"name": "front-end",
"version": "0.0.0",
"private": true,
"repository": {
"type": "git",
"url": "https://...../front-end"
},
"scripts": {
"dev": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node server.js",
"build": "yarn build:client && yarn build:server",
"build:client": "vite build --ssrManifest --outDir dist/client",
"build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
"serve": "cross-env NODE_ENV=production node server",
"serve:local": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production node server"
},
"dependencies": {
"@vueuse/core": "^5.1.3",
"axios": "^0.21.1",
"js-cookie": "^2.2.1",
"vue": "3.1.5",
"vue-router": "4.0.10",
"vue-virtual-scroller": "^2.0.0-alpha.1",
"vuex": "4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.2.5",
"@vue/compiler-sfc": "3.1.5",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/server-renderer": "3.1.5",
"compression": "^1.7.4",
"cross-env": "^7.0.3",
"eslint": "^7.30.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.13.0",
"express": "^4.17.1",
"prettier": "^2.3.2",
"sass": "^1.32.11",
"serve-static": "^1.14.1",
"vite": "^2.4.2"
}
}
I know I miss something but after 1 hour of tries I did'nt succeed.
Can you help me? :)
Regards, Michael.
I had the same issue on initializing. Try yarn build --ignore-cache
and see if it will complete.
This is just to get you unstuck until @ojkelly has a chance to chime in.
That message would indicate nothing needs to be built.
By default yarn build
will look for package.json#scripts.build
which you have.
So first place I'd look is .yarn/yarn.build.json
(this should be in your .gitignore
)
It should look something like
{
"comment": "This is an auto-generated file, it keeps track of whats been built. This is a local file, don't store this in version control.",
"packages": {
"packages/examples/words/adipiscing#build": {
"lastModified": 1627200304059.7244,
"status": "succeeded",
"haveCheckedForRerun": true,
"rerun": false,
"command": "build"
},
the main this to look for here is if the workspace you want to build shows up. If it's in there, it means yarn build
doesn't think it needs to be rebuilt.
We try to make a best guess at your input/output folders by looking at package.json#main
and treating that as your output folder. Output is ignored in determining if a rebuild it needed. If Input has been modified we rebuild. If no files have changed in your workspace, yarn build
will not rebuild. if you changed a file outside your workspace, unless it's in the dependencies it wont trigger a rebuild.
Here's an example of packages that depend on other local packages https://github.com/ojkelly/yarn.build/blob/main/packages/examples/phrases/lorem-ipsum/package.json#L12
If you need to you can add this to your package.json
to specify your input/output folders. Though, this usually solves for when yarn build
does cache at all.
"yarn.build": {
"input":"src",
"output":"dist"
}
Lastly, check if the workspaces are defined in the root package.json
.
If you run yarn build inside your yarn repo, but outside a workspace it will try to build everything. If none are defined, you could get the message you described.
Have a look at https://github.com/ojkelly/yarn.build/blob/main/package.json#L6
This repo is also an example of how to use yarn.build.
Hello @ojkelly and @dancernogorsky
First of all thank you for your both answers :)
@dancernogorsky I tried your solution but it didn't worked :/
@ojkelly
So I followed your solutions too, it took me a while but I succeed 🥳
My main issue was my worktree. I did'nt dev the project, I'm just the DevOps guy so I'm not realy an expert with node projects and yarn ahah
I created a simple workspace with all my src
dir into. And the build finaly worked but just with 1 line. So it took 30 sec :(
After that I just splited the server
and client
projects, put a package.json into each project and the magic happened.
To reach a full optimized build I will show this to the dev team.
The front-end project was created with yarn 1 so I think it's not design into workspaces/packages. I think that's why the build don't looks like your demo.
Best regards,
Michael.
@OptimusKoala great to hear you got it working.
Yep, with only a few packages you wont see much in the way of time saving. Though even just building in the order of the dependency tree can be helpful.
Most of the use cases where this becomes powerful and a must have tool is when you have 5 or more packages. Often we'll have 20, 50 or over a few hundred.