[{"data":1,"prerenderedAt":1663},["ShallowReactive",2],{"series-\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fdelivering-components-continuously-and-with-confidence":3,"series-context-\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library":1436},{"id":4,"title":5,"body":6,"contentId":1423,"date":1424,"description":1425,"extension":1426,"github":1427,"meetTheInstructor":1427,"meta":1428,"navigation":130,"part":151,"path":1429,"rawbody":1430,"robots":1427,"schemaOrg":1427,"seo":1431,"seriesSlug":1432,"sitemap":1433,"stem":1434,"subtitle":1427,"topics":1427,"__hash__":1435},"series\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fdelivering-components-continuously-and-with-confidence.md","Delivering Components Continuously and with Confidence",{"type":7,"value":8,"toc":1419},"minimark",[9,34,39,46,51,66,102,105,716,719,741,751,758,823,826,830,836,839,885,888,891,917,924,936,939,1221,1224,1230,1263,1266,1289,1292,1337,1350,1365,1386,1409,1415],[10,11,12,13,17,18,21,22,25,26,29,30,33],"p",{},"We've built our ",[14,15,16],"strong",{},"Vue.js"," component library, but if we can't utilize it in our projects, what's the point? In this article, we'll establish a ",[14,19,20],{},"continuous integration"," pipeline with ",[14,23,24],{},"GitHub Actions"," and a ",[14,27,28],{},"release process"," to publish our components to ",[14,31,32],{},"npm",".",[35,36,38],"h2",{"id":37},"continuous-integration-with-github-actions","Continuous integration with GitHub Actions",[10,40,41,42,45],{},"A ",[14,43,44],{},"continuous integration (CI)"," pipeline is a set of automated processes that run every time a new commit is pushed to a repository. It ensures the code is always in a deployable state and meets the project's quality standards.",[10,47,48,50],{},[14,49,24],{}," is a CI\u002FCD service provided by GitHub that automates your workflow by running your code in a clean environment and executing the specified commands.",[10,52,53,54,56,57,61,62,65],{},"To create a CI pipeline with ",[14,55,24],{},", we need to create a ",[58,59,60],"code",{},".github\u002Fworkflows"," directory at the root of our project and add a ",[58,63,64],{},"ci.yml"," file inside it:",[67,68,73],"pre",{"className":69,"code":70,"filename":64,"language":71,"meta":72,"style":72},"language-bash shiki shiki-themes github-light github-light github-dark","mkdir -p .github\u002Fworkflows && touch .github\u002Fworkflows\u002Fci.yml\n","bash","",[58,74,75],{"__ignoreMap":72},[76,77,80,84,88,92,96,99],"span",{"class":78,"line":79},"line",1,[76,81,83],{"class":82},"snPdu","mkdir",[76,85,87],{"class":86},"sBjJW"," -p",[76,89,91],{"class":90},"sIIMD"," .github\u002Fworkflows",[76,93,95],{"class":94},"sxrX7"," && ",[76,97,98],{"class":82},"touch",[76,100,101],{"class":90}," .github\u002Fworkflows\u002Fci.yml\n",[10,103,104],{},"We can then add the following content:",[67,106,111],{"className":107,"code":108,"filename":109,"language":110,"meta":72,"style":72},"language-yaml shiki shiki-themes github-light github-light github-dark","name: CI\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  lint:\n    name: Lint\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Lint files\n        run: pnpm run lint\n\n      - name: Type check\n        run: pnpm run typecheck\n\n  build:\n    name: Build\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Generate files\n        run: pnpm run build\n\n  test:\n    name: Test\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Run tests\n        run: pnpm run test\n","Example","yaml",[58,112,113,125,132,141,149,157,166,174,181,188,193,201,209,220,231,236,244,261,274,288,296,307,318,323,335,346,351,363,373,378,390,400,405,413,423,432,437,444,457,468,481,488,497,506,511,522,531,536,548,558,563,571,581,590,595,602,615,626,639,646,655,664,669,680,689,694,706],{"__ignoreMap":72},[76,114,115,119,122],{"class":78,"line":79},[76,116,118],{"class":117},"sovSZ","name",[76,120,121],{"class":94},": ",[76,123,124],{"class":90},"CI\n",[76,126,128],{"class":78,"line":127},2,[76,129,131],{"emptyLinePlaceholder":130},true,"\n",[76,133,135,138],{"class":78,"line":134},3,[76,136,137],{"class":86},"on",[76,139,140],{"class":94},":\n",[76,142,144,147],{"class":78,"line":143},4,[76,145,146],{"class":117},"  push",[76,148,140],{"class":94},[76,150,152,155],{"class":78,"line":151},5,[76,153,154],{"class":117},"    branches",[76,156,140],{"class":94},[76,158,160,163],{"class":78,"line":159},6,[76,161,162],{"class":94},"      - ",[76,164,165],{"class":90},"main\n",[76,167,169,172],{"class":78,"line":168},7,[76,170,171],{"class":117},"  pull_request",[76,173,140],{"class":94},[76,175,177,179],{"class":78,"line":176},8,[76,178,154],{"class":117},[76,180,140],{"class":94},[76,182,184,186],{"class":78,"line":183},9,[76,185,162],{"class":94},[76,187,165],{"class":90},[76,189,191],{"class":78,"line":190},10,[76,192,131],{"emptyLinePlaceholder":130},[76,194,196,199],{"class":78,"line":195},11,[76,197,198],{"class":117},"jobs",[76,200,140],{"class":94},[76,202,204,207],{"class":78,"line":203},12,[76,205,206],{"class":117},"  lint",[76,208,140],{"class":94},[76,210,212,215,217],{"class":78,"line":211},13,[76,213,214],{"class":117},"    name",[76,216,121],{"class":94},[76,218,219],{"class":90},"Lint\n",[76,221,223,226,228],{"class":78,"line":222},14,[76,224,225],{"class":117},"    runs-on",[76,227,121],{"class":94},[76,229,230],{"class":90},"ubuntu-latest\n",[76,232,234],{"class":78,"line":233},15,[76,235,131],{"emptyLinePlaceholder":130},[76,237,239,242],{"class":78,"line":238},16,[76,240,241],{"class":117},"    steps",[76,243,140],{"class":94},[76,245,247,249,252,254,257],{"class":78,"line":246},17,[76,248,162],{"class":94},[76,250,251],{"class":117},"uses",[76,253,121],{"class":94},[76,255,256],{"class":90},"actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11",[76,258,260],{"class":259},"sCsY4"," # v4\n",[76,262,264,266,269,271],{"class":78,"line":263},18,[76,265,162],{"class":94},[76,267,268],{"class":117},"run",[76,270,121],{"class":94},[76,272,273],{"class":90},"corepack enable\n",[76,275,277,279,281,283,286],{"class":78,"line":276},19,[76,278,162],{"class":94},[76,280,251],{"class":117},[76,282,121],{"class":94},[76,284,285],{"class":90},"actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65",[76,287,260],{"class":259},[76,289,291,294],{"class":78,"line":290},20,[76,292,293],{"class":117},"        with",[76,295,140],{"class":94},[76,297,299,302,304],{"class":78,"line":298},21,[76,300,301],{"class":117},"          node-version",[76,303,121],{"class":94},[76,305,306],{"class":86},"22\n",[76,308,310,313,315],{"class":78,"line":309},22,[76,311,312],{"class":117},"          cache",[76,314,121],{"class":94},[76,316,317],{"class":90},"pnpm\n",[76,319,321],{"class":78,"line":320},23,[76,322,131],{"emptyLinePlaceholder":130},[76,324,326,328,330,332],{"class":78,"line":325},24,[76,327,162],{"class":94},[76,329,118],{"class":117},[76,331,121],{"class":94},[76,333,334],{"class":90},"Install dependencies\n",[76,336,338,341,343],{"class":78,"line":337},25,[76,339,340],{"class":117},"        run",[76,342,121],{"class":94},[76,344,345],{"class":90},"pnpm install\n",[76,347,349],{"class":78,"line":348},26,[76,350,131],{"emptyLinePlaceholder":130},[76,352,354,356,358,360],{"class":78,"line":353},27,[76,355,162],{"class":94},[76,357,118],{"class":117},[76,359,121],{"class":94},[76,361,362],{"class":90},"Lint files\n",[76,364,366,368,370],{"class":78,"line":365},28,[76,367,340],{"class":117},[76,369,121],{"class":94},[76,371,372],{"class":90},"pnpm run lint\n",[76,374,376],{"class":78,"line":375},29,[76,377,131],{"emptyLinePlaceholder":130},[76,379,381,383,385,387],{"class":78,"line":380},30,[76,382,162],{"class":94},[76,384,118],{"class":117},[76,386,121],{"class":94},[76,388,389],{"class":90},"Type check\n",[76,391,393,395,397],{"class":78,"line":392},31,[76,394,340],{"class":117},[76,396,121],{"class":94},[76,398,399],{"class":90},"pnpm run typecheck\n",[76,401,403],{"class":78,"line":402},32,[76,404,131],{"emptyLinePlaceholder":130},[76,406,408,411],{"class":78,"line":407},33,[76,409,410],{"class":117},"  build",[76,412,140],{"class":94},[76,414,416,418,420],{"class":78,"line":415},34,[76,417,214],{"class":117},[76,419,121],{"class":94},[76,421,422],{"class":90},"Build\n",[76,424,426,428,430],{"class":78,"line":425},35,[76,427,225],{"class":117},[76,429,121],{"class":94},[76,431,230],{"class":90},[76,433,435],{"class":78,"line":434},36,[76,436,131],{"emptyLinePlaceholder":130},[76,438,440,442],{"class":78,"line":439},37,[76,441,241],{"class":117},[76,443,140],{"class":94},[76,445,447,449,451,453,455],{"class":78,"line":446},38,[76,448,162],{"class":94},[76,450,251],{"class":117},[76,452,121],{"class":94},[76,454,256],{"class":90},[76,456,260],{"class":259},[76,458,460,462,464,466],{"class":78,"line":459},39,[76,461,162],{"class":94},[76,463,268],{"class":117},[76,465,121],{"class":94},[76,467,273],{"class":90},[76,469,471,473,475,477,479],{"class":78,"line":470},40,[76,472,162],{"class":94},[76,474,251],{"class":117},[76,476,121],{"class":94},[76,478,285],{"class":90},[76,480,260],{"class":259},[76,482,484,486],{"class":78,"line":483},41,[76,485,293],{"class":117},[76,487,140],{"class":94},[76,489,491,493,495],{"class":78,"line":490},42,[76,492,301],{"class":117},[76,494,121],{"class":94},[76,496,306],{"class":86},[76,498,500,502,504],{"class":78,"line":499},43,[76,501,312],{"class":117},[76,503,121],{"class":94},[76,505,317],{"class":90},[76,507,509],{"class":78,"line":508},44,[76,510,131],{"emptyLinePlaceholder":130},[76,512,514,516,518,520],{"class":78,"line":513},45,[76,515,162],{"class":94},[76,517,118],{"class":117},[76,519,121],{"class":94},[76,521,334],{"class":90},[76,523,525,527,529],{"class":78,"line":524},46,[76,526,340],{"class":117},[76,528,121],{"class":94},[76,530,345],{"class":90},[76,532,534],{"class":78,"line":533},47,[76,535,131],{"emptyLinePlaceholder":130},[76,537,539,541,543,545],{"class":78,"line":538},48,[76,540,162],{"class":94},[76,542,118],{"class":117},[76,544,121],{"class":94},[76,546,547],{"class":90},"Generate files\n",[76,549,551,553,555],{"class":78,"line":550},49,[76,552,340],{"class":117},[76,554,121],{"class":94},[76,556,557],{"class":90},"pnpm run build\n",[76,559,561],{"class":78,"line":560},50,[76,562,131],{"emptyLinePlaceholder":130},[76,564,566,569],{"class":78,"line":565},51,[76,567,568],{"class":117},"  test",[76,570,140],{"class":94},[76,572,574,576,578],{"class":78,"line":573},52,[76,575,214],{"class":117},[76,577,121],{"class":94},[76,579,580],{"class":90},"Test\n",[76,582,584,586,588],{"class":78,"line":583},53,[76,585,225],{"class":117},[76,587,121],{"class":94},[76,589,230],{"class":90},[76,591,593],{"class":78,"line":592},54,[76,594,131],{"emptyLinePlaceholder":130},[76,596,598,600],{"class":78,"line":597},55,[76,599,241],{"class":117},[76,601,140],{"class":94},[76,603,605,607,609,611,613],{"class":78,"line":604},56,[76,606,162],{"class":94},[76,608,251],{"class":117},[76,610,121],{"class":94},[76,612,256],{"class":90},[76,614,260],{"class":259},[76,616,618,620,622,624],{"class":78,"line":617},57,[76,619,162],{"class":94},[76,621,268],{"class":117},[76,623,121],{"class":94},[76,625,273],{"class":90},[76,627,629,631,633,635,637],{"class":78,"line":628},58,[76,630,162],{"class":94},[76,632,251],{"class":117},[76,634,121],{"class":94},[76,636,285],{"class":90},[76,638,260],{"class":259},[76,640,642,644],{"class":78,"line":641},59,[76,643,293],{"class":117},[76,645,140],{"class":94},[76,647,649,651,653],{"class":78,"line":648},60,[76,650,301],{"class":117},[76,652,121],{"class":94},[76,654,306],{"class":86},[76,656,658,660,662],{"class":78,"line":657},61,[76,659,312],{"class":117},[76,661,121],{"class":94},[76,663,317],{"class":90},[76,665,667],{"class":78,"line":666},62,[76,668,131],{"emptyLinePlaceholder":130},[76,670,672,674,676,678],{"class":78,"line":671},63,[76,673,162],{"class":94},[76,675,118],{"class":117},[76,677,121],{"class":94},[76,679,334],{"class":90},[76,681,683,685,687],{"class":78,"line":682},64,[76,684,340],{"class":117},[76,686,121],{"class":94},[76,688,345],{"class":90},[76,690,692],{"class":78,"line":691},65,[76,693,131],{"emptyLinePlaceholder":130},[76,695,697,699,701,703],{"class":78,"line":696},66,[76,698,162],{"class":94},[76,700,118],{"class":117},[76,702,121],{"class":94},[76,704,705],{"class":90},"Run tests\n",[76,707,709,711,713],{"class":78,"line":708},67,[76,710,340],{"class":117},[76,712,121],{"class":94},[76,714,715],{"class":90},"pnpm run test\n",[10,717,718],{},"This configuration file defines three jobs:",[720,721,722,729,735],"ol",{},[723,724,725,728],"li",{},[14,726,727],{},"Lint",": Installs dependencies, lints files, and type-checks the code.",[723,730,731,734],{},[14,732,733],{},"Build",": Installs dependencies and generates files.",[723,736,737,740],{},[14,738,739],{},"Test",": Installs dependencies and runs tests.",[10,742,743,744,747,748,750],{},"With this setup, every time a new commit is pushed to the ",[58,745,746],{},"main"," branch or associated with a pull request, ",[14,749,24],{}," will execute the CI pipeline.",[10,752,753,754,757],{},"To make it work, we need to add related scripts to our ",[58,755,756],{},"package.json",":",[67,759,763],{"className":760,"code":761,"filename":756,"language":762,"meta":72,"style":72},"language-json shiki shiki-themes github-light github-light github-dark","{\n  \"scripts\": {\n    \"build\": \"pnpm --filter '.\u002Fpackages\u002F**' prepack\",\n    \"test\": \"pnpm --filter '.\u002Fpackages\u002F**' run test\",\n    \"typecheck\": \"pnpm --filter '.\u002Fpackages\u002F**' run typecheck\"\n  }\n}\n","json",[58,764,765,770,778,791,803,813,818],{"__ignoreMap":72},[76,766,767],{"class":78,"line":79},[76,768,769],{"class":94},"{\n",[76,771,772,775],{"class":78,"line":127},[76,773,774],{"class":86},"  \"scripts\"",[76,776,777],{"class":94},": {\n",[76,779,780,783,785,788],{"class":78,"line":134},[76,781,782],{"class":86},"    \"build\"",[76,784,121],{"class":94},[76,786,787],{"class":90},"\"pnpm --filter '.\u002Fpackages\u002F**' prepack\"",[76,789,790],{"class":94},",\n",[76,792,793,796,798,801],{"class":78,"line":143},[76,794,795],{"class":86},"    \"test\"",[76,797,121],{"class":94},[76,799,800],{"class":90},"\"pnpm --filter '.\u002Fpackages\u002F**' run test\"",[76,802,790],{"class":94},[76,804,805,808,810],{"class":78,"line":151},[76,806,807],{"class":86},"    \"typecheck\"",[76,809,121],{"class":94},[76,811,812],{"class":90},"\"pnpm --filter '.\u002Fpackages\u002F**' run typecheck\"\n",[76,814,815],{"class":78,"line":159},[76,816,817],{"class":94},"  }\n",[76,819,820],{"class":78,"line":168},[76,821,822],{"class":94},"}\n",[10,824,825],{},"These scripts will run the build, test, and typecheck commands for each package in our monorepo, ensuring we execute commands for each package rather than the entire monorepo.",[35,827,829],{"id":828},"publishing-to-npm","Publishing to npm",[10,831,832,833,835],{},"The process of publishing a package to ",[14,834,32],{}," is more intricate than it appears. It involves several steps that must be executed in the correct order to ensure the package is published correctly. In a monorepo, this is even more complex due to multiple packages.",[10,837,838],{},"The process is:",[720,840,841,847,853,859,865,871,879],{},[723,842,843,846],{},[14,844,845],{},"Build the packages",": Build the packages before publishing.",[723,848,849,852],{},[14,850,851],{},"Update the version",": Update the version of the packages before publishing.",[723,854,855,858],{},[14,856,857],{},"Update the changelog",": Update the changelog of the packages before publishing.",[723,860,861,864],{},[14,862,863],{},"Create a commit",": Create a commit with the changes before publishing the packages.",[723,866,867,870],{},[14,868,869],{},"Create a tag",": Create a tag with the version before publishing the packages.",[723,872,873,876,877,33],{},[14,874,875],{},"Publish the packages",": Publish the packages to ",[14,878,32],{},[723,880,881,884],{},[14,882,883],{},"Push the changes",": Push the changes to the repository.",[10,886,887],{},"Executing these steps manually is error-prone and time-consuming. To simplify the process, we will automate it to publish our packages with a single command.",[10,889,890],{},"First, we need to install some dependencies at the root of our project:",[67,892,895],{"className":69,"code":893,"filename":894,"language":71,"meta":72,"style":72},"pnpm add -D bumpp changelogen jiti\n","terminal",[58,896,897],{"__ignoreMap":72},[76,898,899,902,905,908,911,914],{"class":78,"line":79},[76,900,901],{"class":82},"pnpm",[76,903,904],{"class":90}," add",[76,906,907],{"class":86}," -D",[76,909,910],{"class":90}," bumpp",[76,912,913],{"class":90}," changelogen",[76,915,916],{"class":90}," jiti\n",[10,918,919,920,923],{},"Then, create a file ",[58,921,922],{},"scripts\u002Frelease.ts"," at the root of the project:",[67,925,927],{"className":69,"code":926,"filename":922,"language":71,"meta":72,"style":72},"touch scripts\u002Frelease.ts\n",[58,928,929],{"__ignoreMap":72},[76,930,931,933],{"class":78,"line":79},[76,932,98],{"class":82},[76,934,935],{"class":90}," scripts\u002Frelease.ts\n",[10,937,938],{},"With the following content:",[67,940,944],{"className":941,"code":942,"filename":109,"language":943,"meta":72,"style":72},"language-ts shiki shiki-themes github-light github-light github-dark","import { execSync } from 'node:child_process'\nimport { readFileSync } from 'node:fs'\nimport process from 'node:process'\n\nconst { version: oldVersion } = JSON.parse(readFileSync('package.json', 'utf-8'))\n\n\u002F\u002F Update the version in package.json\nexecSync('bumpp -r --no-commit --no-tag --no-push', { stdio: 'inherit' })\n\nconst { version } = JSON.parse(readFileSync('package.json', 'utf-8'))\n\nif (oldVersion === version) {\n  console.log('canceled')\n  process.exit()\n}\n\n\u002F\u002F Create the commit and tag\nexecSync('git add .', { stdio: 'inherit' })\nexecSync(`git commit -m \"chore: release v${version}\"`, { stdio: 'inherit' })\nexecSync(`git tag -a v${version} -m \"v${version}\"`, { stdio: 'inherit' })\n","ts",[58,945,946,961,973,985,989,1040,1044,1049,1068,1072,1104,1108,1122,1138,1149,1153,1157,1162,1177,1197],{"__ignoreMap":72},[76,947,948,952,955,958],{"class":78,"line":79},[76,949,951],{"class":950},"s8jYJ","import",[76,953,954],{"class":94}," { execSync } ",[76,956,957],{"class":950},"from",[76,959,960],{"class":90}," 'node:child_process'\n",[76,962,963,965,968,970],{"class":78,"line":127},[76,964,951],{"class":950},[76,966,967],{"class":94}," { readFileSync } ",[76,969,957],{"class":950},[76,971,972],{"class":90}," 'node:fs'\n",[76,974,975,977,980,982],{"class":78,"line":134},[76,976,951],{"class":950},[76,978,979],{"class":94}," process ",[76,981,957],{"class":950},[76,983,984],{"class":90}," 'node:process'\n",[76,986,987],{"class":78,"line":143},[76,988,131],{"emptyLinePlaceholder":130},[76,990,991,994,997,1001,1003,1006,1009,1012,1015,1017,1020,1023,1026,1028,1031,1034,1037],{"class":78,"line":151},[76,992,993],{"class":950},"const",[76,995,996],{"class":94}," { ",[76,998,1000],{"class":999},"sP4rz","version",[76,1002,121],{"class":94},[76,1004,1005],{"class":86},"oldVersion",[76,1007,1008],{"class":94}," } ",[76,1010,1011],{"class":950},"=",[76,1013,1014],{"class":86}," JSON",[76,1016,33],{"class":94},[76,1018,1019],{"class":82},"parse",[76,1021,1022],{"class":94},"(",[76,1024,1025],{"class":82},"readFileSync",[76,1027,1022],{"class":94},[76,1029,1030],{"class":90},"'package.json'",[76,1032,1033],{"class":94},", ",[76,1035,1036],{"class":90},"'utf-8'",[76,1038,1039],{"class":94},"))\n",[76,1041,1042],{"class":78,"line":159},[76,1043,131],{"emptyLinePlaceholder":130},[76,1045,1046],{"class":78,"line":168},[76,1047,1048],{"class":259},"\u002F\u002F Update the version in package.json\n",[76,1050,1051,1054,1056,1059,1062,1065],{"class":78,"line":176},[76,1052,1053],{"class":82},"execSync",[76,1055,1022],{"class":94},[76,1057,1058],{"class":90},"'bumpp -r --no-commit --no-tag --no-push'",[76,1060,1061],{"class":94},", { stdio: ",[76,1063,1064],{"class":90},"'inherit'",[76,1066,1067],{"class":94}," })\n",[76,1069,1070],{"class":78,"line":183},[76,1071,131],{"emptyLinePlaceholder":130},[76,1073,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102],{"class":78,"line":190},[76,1075,993],{"class":950},[76,1077,996],{"class":94},[76,1079,1000],{"class":86},[76,1081,1008],{"class":94},[76,1083,1011],{"class":950},[76,1085,1014],{"class":86},[76,1087,33],{"class":94},[76,1089,1019],{"class":82},[76,1091,1022],{"class":94},[76,1093,1025],{"class":82},[76,1095,1022],{"class":94},[76,1097,1030],{"class":90},[76,1099,1033],{"class":94},[76,1101,1036],{"class":90},[76,1103,1039],{"class":94},[76,1105,1106],{"class":78,"line":195},[76,1107,131],{"emptyLinePlaceholder":130},[76,1109,1110,1113,1116,1119],{"class":78,"line":203},[76,1111,1112],{"class":950},"if",[76,1114,1115],{"class":94}," (oldVersion ",[76,1117,1118],{"class":950},"===",[76,1120,1121],{"class":94}," version) {\n",[76,1123,1124,1127,1130,1132,1135],{"class":78,"line":211},[76,1125,1126],{"class":94},"  console.",[76,1128,1129],{"class":82},"log",[76,1131,1022],{"class":94},[76,1133,1134],{"class":90},"'canceled'",[76,1136,1137],{"class":94},")\n",[76,1139,1140,1143,1146],{"class":78,"line":222},[76,1141,1142],{"class":94},"  process.",[76,1144,1145],{"class":82},"exit",[76,1147,1148],{"class":94},"()\n",[76,1150,1151],{"class":78,"line":233},[76,1152,822],{"class":94},[76,1154,1155],{"class":78,"line":238},[76,1156,131],{"emptyLinePlaceholder":130},[76,1158,1159],{"class":78,"line":246},[76,1160,1161],{"class":259},"\u002F\u002F Create the commit and tag\n",[76,1163,1164,1166,1168,1171,1173,1175],{"class":78,"line":263},[76,1165,1053],{"class":82},[76,1167,1022],{"class":94},[76,1169,1170],{"class":90},"'git add .'",[76,1172,1061],{"class":94},[76,1174,1064],{"class":90},[76,1176,1067],{"class":94},[76,1178,1179,1181,1183,1186,1188,1191,1193,1195],{"class":78,"line":276},[76,1180,1053],{"class":82},[76,1182,1022],{"class":94},[76,1184,1185],{"class":90},"`git commit -m \"chore: release v${",[76,1187,1000],{"class":94},[76,1189,1190],{"class":90},"}\"`",[76,1192,1061],{"class":94},[76,1194,1064],{"class":90},[76,1196,1067],{"class":94},[76,1198,1199,1201,1203,1206,1208,1211,1213,1215,1217,1219],{"class":78,"line":290},[76,1200,1053],{"class":82},[76,1202,1022],{"class":94},[76,1204,1205],{"class":90},"`git tag -a v${",[76,1207,1000],{"class":94},[76,1209,1210],{"class":90},"} -m \"v${",[76,1212,1000],{"class":94},[76,1214,1190],{"class":90},[76,1216,1061],{"class":94},[76,1218,1064],{"class":90},[76,1220,1067],{"class":94},[10,1222,1223],{},"This script updates the version of the packages, creates a commit with the changes, and tags the version.",[10,1225,1226,1227,1229],{},"Next, create a script in our ",[58,1228,756],{}," to publish the packages:",[67,1231,1233],{"className":760,"code":1232,"filename":756,"language":762,"meta":72,"style":72},"{\n  \"scripts\": {\n    \"release\": \"pnpm run lint && pnpm run typecheck && pnpm run test && changelogen --output CHANGELOG.md && jiti scripts\u002Frelease.ts && pnpm -r run release:publish && git push --follow-tags\"\n  }\n}\n",[58,1234,1235,1239,1245,1255,1259],{"__ignoreMap":72},[76,1236,1237],{"class":78,"line":79},[76,1238,769],{"class":94},[76,1240,1241,1243],{"class":78,"line":127},[76,1242,774],{"class":86},[76,1244,777],{"class":94},[76,1246,1247,1250,1252],{"class":78,"line":134},[76,1248,1249],{"class":86},"    \"release\"",[76,1251,121],{"class":94},[76,1253,1254],{"class":90},"\"pnpm run lint && pnpm run typecheck && pnpm run test && changelogen --output CHANGELOG.md && jiti scripts\u002Frelease.ts && pnpm -r run release:publish && git push --follow-tags\"\n",[76,1256,1257],{"class":78,"line":143},[76,1258,817],{"class":94},[76,1260,1261],{"class":78,"line":151},[76,1262,822],{"class":94},[10,1264,1265],{},"This script will:",[720,1267,1268,1271,1274,1281,1286],{},[723,1269,1270],{},"Run lint, typecheck, and test commands to ensure our packages are ready for publication. If any of these commands fail, the process will halt.",[723,1272,1273],{},"Update the changelog of the repository.",[723,1275,1276,1277,1280],{},"Execute the ",[58,1278,1279],{},"release.ts"," script to update the version, create a commit, and tag.",[723,1282,1283,1284,33],{},"Publish the packages to ",[14,1285,32],{},[723,1287,1288],{},"Push the changes to the repository.",[10,1290,1291],{},"Finally, add the following scripts to each package in our monorepo:",[67,1293,1295],{"className":760,"code":1294,"filename":109,"language":762,"meta":72,"style":72},"{\n  \"scripts\": {\n    \"prepack\": \"pnpm run build\",\n    \"release:publish\": \"pnpm publish --access public\"\n  }\n}\n",[58,1296,1297,1301,1307,1319,1329,1333],{"__ignoreMap":72},[76,1298,1299],{"class":78,"line":79},[76,1300,769],{"class":94},[76,1302,1303,1305],{"class":78,"line":127},[76,1304,774],{"class":86},[76,1306,777],{"class":94},[76,1308,1309,1312,1314,1317],{"class":78,"line":134},[76,1310,1311],{"class":86},"    \"prepack\"",[76,1313,121],{"class":94},[76,1315,1316],{"class":90},"\"pnpm run build\"",[76,1318,790],{"class":94},[76,1320,1321,1324,1326],{"class":78,"line":143},[76,1322,1323],{"class":86},"    \"release:publish\"",[76,1325,121],{"class":94},[76,1327,1328],{"class":90},"\"pnpm publish --access public\"\n",[76,1330,1331],{"class":78,"line":151},[76,1332,817],{"class":94},[76,1334,1335],{"class":78,"line":159},[76,1336,822],{"class":94},[10,1338,1339,1340,1343,1344,1347,1348,33],{},"The ",[58,1341,1342],{},"prepack"," script builds the package before publishing, and the ",[58,1345,1346],{},"release:publish"," script publishes the package to ",[14,1349,32],{},[1351,1352,1355],"callout",{"color":1353,"icon":1354},"info","i-ph-info-duotone",[10,1356,1357,1358,1360,1361,1364],{},"Ensure you are logged into the ",[14,1359,32],{}," registry to publish a package. Use the ",[58,1362,1363],{},"npm login"," command to do so.",[1351,1366,1367],{"color":1353,"icon":1354},[10,1368,1369,1370,1373,1374,1377,1378,1381,1382,1385],{},"Remember to initialize a git repository at the root of the project with ",[58,1371,1372],{},"git init"," and add ",[58,1375,1376],{},"node_modules"," and ",[58,1379,1380],{},"dist"," to the ",[58,1383,1384],{},".gitignore"," file.",[10,1387,1388],{},[1389,1390,1391,1392,1377,1401,1408],"em",{},"If you need more control over the release process and increased automation, explore the ",[1393,1394,1398],"a",{"href":1395,"rel":1396},"https:\u002F\u002Fgithub.com\u002Fnuxt\u002Fnuxt",[1397],"nofollow",[14,1399,1400],{},"nuxt\u002Fnuxt",[1393,1402,1405],{"href":1403,"rel":1404},"https:\u002F\u002Fgithub.com\u002Fvueuse\u002Fvueuse",[1397],[14,1406,1407],{},"vueuse\u002Fvueuse"," repositories. However, as each project differs, I strive to keep the release process as straightforward and generic as possible.",[10,1410,1411,1412,1414],{},"With this setup, you can publish your packages to ",[14,1413,32],{}," with a single command, ensuring they are always delivered with confidence, perfect for a professional developer like you! 😎",[1416,1417,1418],"style",{},"html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sovSZ, html code.shiki .sovSZ{--shiki-light:#22863A;--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":72,"searchDepth":127,"depth":127,"links":1420},[1421,1422],{"id":37,"depth":127,"text":38},{"id":828,"depth":127,"text":829},"34bd87b4-cefd-44bb-affe-21e5e0fe7d56","2024-11-24","Implement a CI pipeline with GitHub Actions and automate the release process to npm for Vue.js component libraries.","md",null,{},"\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fdelivering-components-continuously-and-with-confidence","---\ncontentId: 34bd87b4-cefd-44bb-affe-21e5e0fe7d56\npart: 5\ntitle: \"Delivering Components Continuously and with Confidence\"\ndescription: \"Implement a CI pipeline with GitHub Actions and automate the release process to npm for Vue.js component libraries.\"\ndate: 2024-11-24\nseriesSlug: the-complete-guide-to-building-a-vue-js-component-library\n---\n\nWe've built our **Vue.js** component library, but if we can't utilize it in our projects, what's the point? In this article, we'll establish a **continuous integration** pipeline with **GitHub Actions** and a **release process** to publish our components to **npm**.\n\n## Continuous integration with GitHub Actions\n\nA **continuous integration (CI)** pipeline is a set of automated processes that run every time a new commit is pushed to a repository. It ensures the code is always in a deployable state and meets the project's quality standards.\n\n**GitHub Actions** is a CI\u002FCD service provided by GitHub that automates your workflow by running your code in a clean environment and executing the specified commands.\n\nTo create a CI pipeline with **GitHub Actions**, we need to create a `.github\u002Fworkflows` directory at the root of our project and add a `ci.yml` file inside it:\n\n```bash [ci.yml]\nmkdir -p .github\u002Fworkflows && touch .github\u002Fworkflows\u002Fci.yml\n```\n\nWe can then add the following content:\n\n```yaml [Example]\nname: CI\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  lint:\n    name: Lint\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Lint files\n        run: pnpm run lint\n\n      - name: Type check\n        run: pnpm run typecheck\n\n  build:\n    name: Build\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Generate files\n        run: pnpm run build\n\n  test:\n    name: Test\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\u002Fcheckout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4\n        with:\n          node-version: 22\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Run tests\n        run: pnpm run test\n```\n\nThis configuration file defines three jobs:\n\n1. **Lint**: Installs dependencies, lints files, and type-checks the code.\n2. **Build**: Installs dependencies and generates files.\n3. **Test**: Installs dependencies and runs tests.\n\nWith this setup, every time a new commit is pushed to the `main` branch or associated with a pull request, **GitHub Actions** will execute the CI pipeline.\n\nTo make it work, we need to add related scripts to our `package.json`:\n\n```json [package.json]\n{\n  \"scripts\": {\n    \"build\": \"pnpm --filter '.\u002Fpackages\u002F**' prepack\",\n    \"test\": \"pnpm --filter '.\u002Fpackages\u002F**' run test\",\n    \"typecheck\": \"pnpm --filter '.\u002Fpackages\u002F**' run typecheck\"\n  }\n}\n```\n\nThese scripts will run the build, test, and typecheck commands for each package in our monorepo, ensuring we execute commands for each package rather than the entire monorepo.\n\n## Publishing to npm\n\nThe process of publishing a package to **npm** is more intricate than it appears. It involves several steps that must be executed in the correct order to ensure the package is published correctly. In a monorepo, this is even more complex due to multiple packages.\n\nThe process is:\n\n1. **Build the packages**: Build the packages before publishing.\n2. **Update the version**: Update the version of the packages before publishing.\n3. **Update the changelog**: Update the changelog of the packages before publishing.\n4. **Create a commit**: Create a commit with the changes before publishing the packages.\n5. **Create a tag**: Create a tag with the version before publishing the packages.\n6. **Publish the packages**: Publish the packages to **npm**.\n7. **Push the changes**: Push the changes to the repository.\n\nExecuting these steps manually is error-prone and time-consuming. To simplify the process, we will automate it to publish our packages with a single command.\n\nFirst, we need to install some dependencies at the root of our project:\n\n```bash [terminal]\npnpm add -D bumpp changelogen jiti\n```\n\nThen, create a file `scripts\u002Frelease.ts` at the root of the project:\n\n```bash [scripts\u002Frelease.ts]\ntouch scripts\u002Frelease.ts\n```\n\nWith the following content:\n\n```ts [Example]\nimport { execSync } from 'node:child_process'\nimport { readFileSync } from 'node:fs'\nimport process from 'node:process'\n\nconst { version: oldVersion } = JSON.parse(readFileSync('package.json', 'utf-8'))\n\n\u002F\u002F Update the version in package.json\nexecSync('bumpp -r --no-commit --no-tag --no-push', { stdio: 'inherit' })\n\nconst { version } = JSON.parse(readFileSync('package.json', 'utf-8'))\n\nif (oldVersion === version) {\n  console.log('canceled')\n  process.exit()\n}\n\n\u002F\u002F Create the commit and tag\nexecSync('git add .', { stdio: 'inherit' })\nexecSync(`git commit -m \"chore: release v${version}\"`, { stdio: 'inherit' })\nexecSync(`git tag -a v${version} -m \"v${version}\"`, { stdio: 'inherit' })\n```\n\nThis script updates the version of the packages, creates a commit with the changes, and tags the version.\n\nNext, create a script in our `package.json` to publish the packages:\n\n```json [package.json]\n{\n  \"scripts\": {\n    \"release\": \"pnpm run lint && pnpm run typecheck && pnpm run test && changelogen --output CHANGELOG.md && jiti scripts\u002Frelease.ts && pnpm -r run release:publish && git push --follow-tags\"\n  }\n}\n```\n\nThis script will:\n\n1. Run lint, typecheck, and test commands to ensure our packages are ready for publication. If any of these commands fail, the process will halt.\n2. Update the changelog of the repository.\n3. Execute the `release.ts` script to update the version, create a commit, and tag.\n4. Publish the packages to **npm**.\n5. Push the changes to the repository.\n\nFinally, add the following scripts to each package in our monorepo:\n\n```json [Example]\n{\n  \"scripts\": {\n    \"prepack\": \"pnpm run build\",\n    \"release:publish\": \"pnpm publish --access public\"\n  }\n}\n```\n\nThe `prepack` script builds the package before publishing, and the `release:publish` script publishes the package to **npm**.\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nEnsure you are logged into the **npm** registry to publish a package. Use the `npm login` command to do so.\n::\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nRemember to initialize a git repository at the root of the project with `git init` and add `node_modules` and `dist` to the `.gitignore` file.\n::\n\n_If you need more control over the release process and increased automation, explore the [**nuxt\u002Fnuxt**](https:\u002F\u002Fgithub.com\u002Fnuxt\u002Fnuxt) and [**vueuse\u002Fvueuse**](https:\u002F\u002Fgithub.com\u002Fvueuse\u002Fvueuse) repositories. However, as each project differs, I strive to keep the release process as straightforward and generic as possible._\n\nWith this setup, you can publish your packages to **npm** with a single command, ensuring they are always delivered with confidence, perfect for a professional developer like you! 😎\n",{"title":5,"description":1425},"the-complete-guide-to-building-a-vue-js-component-library",{"loc":1429},"series\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fdelivering-components-continuously-and-with-confidence","Cu0TvtNG8vKph1IrbirQftGvNbPKehktwxShqsR6VaA",{"overview":1437,"chapters":1637},{"id":1438,"title":1439,"body":1440,"contentId":1619,"date":1424,"description":1620,"extension":1426,"github":1621,"meetTheInstructor":1624,"meta":1625,"navigation":130,"part":1427,"path":1626,"rawbody":1627,"robots":1427,"schemaOrg":1427,"seo":1628,"seriesSlug":1432,"sitemap":1629,"stem":1630,"subtitle":1631,"topics":1632,"__hash__":1636},"series\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library.md","The Complete Guide to Building a Vue.js Component Library",{"type":7,"value":1441,"toc":1615},[1442,1445,1448,1459,1463,1466,1480,1484,1487,1602,1605,1609],[10,1443,1444],{},"Welcome! 👋",[10,1446,1447],{},"Initially, this series was intended to be a single article, but it soon became apparent that it would be too lengthy. Even GitHub didn't want to display it in the file tab of pull requests. Therefore, I decided to divide it into multiple articles to make it more digestible and to focus on each part individually.",[10,1449,1450,1451,1455,1456],{},"This series is somewhat of a sequel to the article ",[1393,1452,1454],{"href":1453},"\u002Fposts\u002Fthe-simplest-method-to-create-a-vue-js-component-library","The Simplest Method to Create a Vue.js Component Library"," but adopts a more professional approach. ",[1389,1457,1458],{},"You will learn how the most popular component libraries are constructed behind the scenes and how to create your own.",[1460,1461],"callout-read-more",{"id":1462},"f9754148-40bd-4df2-a144-f686e894b200",[10,1464,1465],{},"While it's still my preferred method when I am certain about what I want to achieve, I also received feedback from readers seeking more custom behavior and requiring more complex features.",[10,1467,1468,1469,1474,1475,33],{},"That's understandable. While ",[1393,1470,1473],{"href":1471,"rel":1472},"https:\u002F\u002Fgithub.com\u002Funjs\u002Funbuild",[1397],"unbuild"," is a powerful tool, it cannot match the flexibility, plugin ecosystem, and adoption of ",[1393,1476,1479],{"href":1477,"rel":1478},"https:\u002F\u002Fvite.dev\u002F",[1397],"Vite",[35,1481,1483],{"id":1482},"what-to-expect","What to expect",[10,1485,1486],{},"Throughout this series, we will address the following topics:",[720,1488,1489,1501,1533,1551,1568,1573,1585],{},[723,1490,1491,1494,1495,1500],{},[14,1492,1493],{},"Getting Started with Monorepo, Linter, and Formatter",": We'll set up a monorepo to manage our component library and all the tools necessary to ensure a good development experience. We'll also configure ",[1393,1496,1499],{"href":1497,"rel":1498},"https:\u002F\u002Feslint.org\u002F",[1397],"ESLint"," to ensure code consistency.",[723,1502,1503,1506,1507,1033,1511,1516,1517,1522,1523,1377,1528,33],{},[14,1504,1505],{},"Building a First Component with Vue.js and Tailwind CSS",": We'll create our first component with ",[1393,1508,16],{"href":1509,"rel":1510},"https:\u002F\u002Fvuejs.org\u002F",[1397],[1393,1512,1515],{"href":1513,"rel":1514},"https:\u002F\u002Ftailwindcss.com\u002F",[1397],"Tailwind CSS",", and ",[1393,1518,1521],{"href":1519,"rel":1520},"https:\u002F\u002Fwww.tailwind-variants.org\u002F",[1397],"Tailwind Variants"," using the most advanced and powerful techniques employed in popular component libraries like ",[1393,1524,1527],{"href":1525,"rel":1526},"https:\u002F\u002Fwww.radix-vue.com\u002F",[1397],"Radix Vue",[1393,1529,1532],{"href":1530,"rel":1531},"https:\u002F\u002Fui.nuxt.com\u002F",[1397],"Nuxt UI",[723,1534,1535,1538,1539,1544,1545,1550],{},[14,1536,1537],{},"A Better Development Experience with TypeScript and TSConfig",": We'll enhance our development experience by adding ",[1393,1540,1543],{"href":1541,"rel":1542},"https:\u002F\u002Fwww.typescriptlang.org\u002F",[1397],"TypeScript"," to our component library and configuring ",[1393,1546,1549],{"href":1547,"rel":1548},"https:\u002F\u002Fwww.typescriptlang.org\u002Ftsconfig",[1397],"TSConfig"," to ensure that our components are typed correctly and that we can take full advantage of TypeScript's features.",[723,1552,1553,1556,1557,1377,1562,1567],{},[14,1554,1555],{},"Automatic Component Testing with Vitest and Testing Library",": We'll write tests for our components using ",[1393,1558,1561],{"href":1559,"rel":1560},"https:\u002F\u002Fvitest.dev\u002Fguide\u002F",[1397],"Vitest",[1393,1563,1566],{"href":1564,"rel":1565},"https:\u002F\u002Ftesting-library.com\u002F",[1397],"Testing Library"," to ensure that our components function as expected. This is crucial for a professional component library that remains reliable over time.",[723,1569,1570,1572],{},[14,1571,5],{},": We'll establish a continuous integration process to ensure that our components are always delivered with confidence. For every commit of every branch, we'll run our tests to verify everything is functioning correctly. We'll also establish a release process to publish our components to npm.",[723,1574,1575,1578,1579,1584],{},[14,1576,1577],{},"Creating a Playground and a Storybook for Components",": We'll create a playground to test our components in a real environment and a storybook with ",[1393,1580,1583],{"href":1581,"rel":1582},"https:\u002F\u002Fhistoire.dev\u002F",[1397],"Histoire"," to document them. This will enable us to share our components with other developers and to test them in various scenarios, both in isolation and in combination.",[723,1586,1587,1590,1591,25,1596,1601],{},[14,1588,1589],{},"Enhancing Integration with Unplugin and Nuxt Module",": We'll enhance the integration of our component library with the ecosystem by creating a Vite plugin with ",[1393,1592,1595],{"href":1593,"rel":1594},"https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components",[1397],"Unplugin Vue Components",[1393,1597,1600],{"href":1598,"rel":1599},"https:\u002F\u002Fnuxt.com\u002Fdocs\u002Fguide\u002Fgoing-further\u002Fmodules",[1397],"Nuxt module"," to utilize our components in a Nuxt application.",[10,1603,1604],{},"By the end of this series, you will have a complete Vue.js component library that you can use in your projects or share with the community, like a professional developer. Isn't that exciting? 😎",[35,1606,1608],{"id":1607},"chapters","Chapters",[1610,1611],"series-chapters-list",{"className":1612},[1613,1614],"mx-auto","max-w-5xl",{"title":72,"searchDepth":127,"depth":127,"links":1616},[1617,1618],{"id":1482,"depth":127,"text":1483},{"id":1607,"depth":127,"text":1608},"55d2cdcf-ba27-4bfe-9bc1-492e866ff3b1","Discover how to build a Vue.js component library using Vite with a guide that covers essential techniques for professional web development.",{"name":1622,"repository":1623},"huchet-vue","barbapapazes\u002Fhuchet-vue","I create this series because I love \u003Cstrong>Vue.js\u003C\u002Fstrong> and, for years, I have been unable to find a complete, up-to-date, and \u003Cstrong>professional guide\u003C\u002Fstrong> on how to build a Vue.js component library and want more software developers to feel empowered to create their own.",{},"\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library","---\ncontentId: 55d2cdcf-ba27-4bfe-9bc1-492e866ff3b1\ntitle: The Complete Guide to Building a Vue.js Component Library\nsubtitle: The most advanced and professional course to build a Vue.js component library with Vite.\ndescription: Discover how to build a Vue.js component library using Vite with a guide that covers essential techniques for professional web development.\ndate: 2024-11-24\ntopics:\n  - vue\n  - vite\n  - component library\ngithub:\n  name: huchet-vue\n  repository: barbapapazes\u002Fhuchet-vue\nmeetTheInstructor: I create this series because I love \u003Cstrong>Vue.js\u003C\u002Fstrong> and, for years, I have been unable to find a complete, up-to-date, and \u003Cstrong>professional guide\u003C\u002Fstrong> on how to build a Vue.js component library and want more software developers to feel empowered to create their own.\nseriesSlug: the-complete-guide-to-building-a-vue-js-component-library\n---\n\nWelcome! 👋\n\nInitially, this series was intended to be a single article, but it soon became apparent that it would be too lengthy. Even GitHub didn't want to display it in the file tab of pull requests. Therefore, I decided to divide it into multiple articles to make it more digestible and to focus on each part individually.\n\nThis series is somewhat of a sequel to the article [The Simplest Method to Create a Vue.js Component Library](\u002Fposts\u002Fthe-simplest-method-to-create-a-vue-js-component-library) but adopts a more professional approach. _You will learn how the most popular component libraries are constructed behind the scenes and how to create your own._\n\n\u003CCalloutReadMore id=\"f9754148-40bd-4df2-a144-f686e894b200\" \u002F>\n\nWhile it's still my preferred method when I am certain about what I want to achieve, I also received feedback from readers seeking more custom behavior and requiring more complex features.\n\nThat's understandable. While [unbuild](https:\u002F\u002Fgithub.com\u002Funjs\u002Funbuild) is a powerful tool, it cannot match the flexibility, plugin ecosystem, and adoption of [Vite](https:\u002F\u002Fvite.dev\u002F).\n\n## What to expect\n\nThroughout this series, we will address the following topics:\n\n1. **Getting Started with Monorepo, Linter, and Formatter**: We'll set up a monorepo to manage our component library and all the tools necessary to ensure a good development experience. We'll also configure [ESLint](https:\u002F\u002Feslint.org\u002F) to ensure code consistency.\n2. **Building a First Component with Vue.js and Tailwind CSS**: We'll create our first component with [Vue.js](https:\u002F\u002Fvuejs.org\u002F), [Tailwind CSS](https:\u002F\u002Ftailwindcss.com\u002F), and [Tailwind Variants](https:\u002F\u002Fwww.tailwind-variants.org\u002F) using the most advanced and powerful techniques employed in popular component libraries like [Radix Vue](https:\u002F\u002Fwww.radix-vue.com\u002F) and [Nuxt UI](https:\u002F\u002Fui.nuxt.com\u002F).\n3. **A Better Development Experience with TypeScript and TSConfig**: We'll enhance our development experience by adding [TypeScript](https:\u002F\u002Fwww.typescriptlang.org\u002F) to our component library and configuring [TSConfig](https:\u002F\u002Fwww.typescriptlang.org\u002Ftsconfig) to ensure that our components are typed correctly and that we can take full advantage of TypeScript's features.\n4. **Automatic Component Testing with Vitest and Testing Library**: We'll write tests for our components using [Vitest](https:\u002F\u002Fvitest.dev\u002Fguide\u002F) and [Testing Library](https:\u002F\u002Ftesting-library.com\u002F) to ensure that our components function as expected. This is crucial for a professional component library that remains reliable over time.\n5. **Delivering Components Continuously and with Confidence**: We'll establish a continuous integration process to ensure that our components are always delivered with confidence. For every commit of every branch, we'll run our tests to verify everything is functioning correctly. We'll also establish a release process to publish our components to npm.\n6. **Creating a Playground and a Storybook for Components**: We'll create a playground to test our components in a real environment and a storybook with [Histoire](https:\u002F\u002Fhistoire.dev\u002F) to document them. This will enable us to share our components with other developers and to test them in various scenarios, both in isolation and in combination.\n7. **Enhancing Integration with Unplugin and Nuxt Module**: We'll enhance the integration of our component library with the ecosystem by creating a Vite plugin with [Unplugin Vue Components](https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components) and a [Nuxt module](https:\u002F\u002Fnuxt.com\u002Fdocs\u002Fguide\u002Fgoing-further\u002Fmodules) to utilize our components in a Nuxt application.\n\nBy the end of this series, you will have a complete Vue.js component library that you can use in your projects or share with the community, like a professional developer. Isn't that exciting? 😎\n\n## Chapters\n\n::series-chapters-list\n---\nclass: mx-auto max-w-5xl\n---\n::\n",{"title":1439,"description":1620},{"loc":1626},"series\u002Fthe-complete-guide-to-building-a-vue-js-component-library","The most advanced and professional course to build a Vue.js component library with Vite.",[1633,1634,1635],"vue","vite","component library","2VSSnBlkuSLlt05n9MySLBFt6vBkgd7691eX-TK2cTs",[1638,1642,1646,1650,1654,1655,1659],{"contentId":1639,"title":1493,"description":1640,"path":1641,"part":79,"github":1427,"topics":1427},"1f6cf4af-8637-458d-93f8-52ac60dd8f87","Start your monorepo journey! Learn how to set up a linter and formatter for streamlined coding and organizing your project.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fgetting-started-with-monorepo-linter-and-formatter",{"contentId":1643,"title":1505,"description":1644,"path":1645,"part":127,"github":1427,"topics":1427},"e9f57d8c-a722-4fd7-b326-61af0ea9dbd4","Creating a simple Vue.js button component using Tailwind CSS for styling and variants, along with step-by-step library build configuration using Vite.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fbuilding-a-first-component-with-vuejs-and-tailwind-css",{"contentId":1647,"title":1537,"description":1648,"path":1649,"part":134,"github":1427,"topics":1427},"c2d651b0-4487-472d-b55a-b3cf195bcba8","Learn how to configure TypeScript with multiple contexts and generate types for a library to expose types to developers.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fa-better-development-experience-with-typescript-and-tsconfig",{"contentId":1651,"title":1555,"description":1652,"path":1653,"part":143,"github":1427,"topics":1427},"e95133e4-2362-4aa3-bd3d-b70afc6c4d4e","Learn how to automate testing for Vue.js components using Vitest and Testing Library for efficient and user-focused testing.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fautomatic-component-testing-with-vitest-and-testing-library",{"contentId":1423,"title":5,"description":1425,"path":1429,"part":151,"github":1427,"topics":1427},{"contentId":1656,"title":1577,"description":1657,"path":1658,"part":159,"github":1427,"topics":1427},"53bbc0ae-a7b8-49d3-8ae6-73b585c43efc","Learn how to create a playground and use Histoire to visualize and document your components in both isolated and combined scenarios.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fcreating-a-playground-and-a-storybook-for-components",{"contentId":1660,"title":1589,"description":1661,"path":1662,"part":168,"github":1427,"topics":1427},"8b808104-15ac-42ca-9535-cef0996ddf66","Discover how to seamlessly integrate a Vue.js component library using Unplugin Vue Components and Nuxt Module, enhancing usability and developer experience.","\u002Fseries\u002Fthe-complete-guide-to-building-a-vue-js-component-library\u002Fenhancing-integration-with-unplugin-and-nuxt-module",1795016694855]