Skip to content

Commit

Permalink
✨ Export gitmojis as CJS and ESM (#1280)
Browse files Browse the repository at this point in the history
* βž• Install `unbuild` dependency
* 🚚 Rename `gitmojis.d.ts` to `index.d.ts`
* ✨ Export `cjs` and `esm` with `unbuild`
* πŸ‘· Add `build` step to publish action
* πŸ”§ Add `gitmojis` build output to turborepo config
* πŸ”§ Add `build` as a dependency for `lint`, `tscheck` and `build`
* ✨ Add `assert { type: json }` for JSON imports
* πŸ§‘β€πŸ’» Watch changes on `gitmojis` to rebuild deps for website (#1282)

Co-authored-by: VinΓ­cius Hoyer <[email protected]>
  • Loading branch information
carloscuesta and vhoyer authored Jan 18, 2023
1 parent 4733717 commit 8fd367f
Show file tree
Hide file tree
Showing 7 changed files with 966 additions and 40 deletions.
40 changes: 21 additions & 19 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ name: NPM Publish
on:
push:
tags:
- 'v*'
- "v*"
jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: '16'
- name: Install dependencies πŸ“¦
run: yarn install --immutable
- name: Publish package to NPM πŸš€
env:
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
yarn turbo publishPackage
- name: Publish GitHub Release πŸ“
uses: softprops/action-gh-release@v1
with:
name: gitmoji ${{github.ref_name}}
generate_release_notes: true
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: "yarn"
node-version: "16"
- name: Install dependencies πŸ“¦
run: yarn install --immutable
- name: Build πŸ‘·β€β™‚οΈ
run: yarn turbo run build --filter=gitmojis
- name: Publish package to NPM πŸš€
env:
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
yarn turbo publishPackage
- name: Publish GitHub Release πŸ“
uses: softprops/action-gh-release@v1
with:
name: gitmoji ${{github.ref_name}}
generate_release_notes: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"prepare": "husky install",
"dev": "yarn turbo dev"
"dev": "yarn turbo --parallel dev"
},
"devDependencies": {
"@vercel/analytics": "^0.1.8",
Expand Down
20 changes: 15 additions & 5 deletions packages/gitmojis/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
{
"name": "gitmojis",
"type": "module",
"version": "3.13.3",
"description": "An emoji guide for your commit messages.",
"main": "src/index.js",
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"files": [
"src/gitmojis.json",
"src/schema.json"
"dist"
],
"types": "src/gitmojis.d.ts",
"scripts": {
"dev": "nodemon --exec 'yarn build' --watch ./src",
"build": "unbuild",
"lint:json": "ajv --spec=draft2020 validate -s ./src/schema.json -d ./src/gitmojis.json",
"lint": "yarn run lint:json && prettier --check ./src/**/*.{js,json,ts}",
"publishPackage": "npm publish"
},
"devDependencies": {
"ajv-cli": "^5.0.0",
"lint-staged": "^13.0.0",
"prettier": "2.8.3"
"nodemon": "^2.0.20",
"prettier": "2.8.3",
"unbuild": "^1.1.1"
},
"author": {
"name": "carloscuesta",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/gitmojis/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gitmojisJson from './gitmojis.json'
import gitmojisJson from './gitmojis.json' assert { type: 'json' }

export { default as schema } from './schema.json'
export { default as schema } from './schema.json' assert { type: 'json' }

export const gitmojis = gitmojisJson.gitmojis
6 changes: 5 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"dev": {
"dependsOn": ["^build"],
"cache": false
},
"lint": {
"dependsOn": ["^build"],
"outputs": []
},
"tscheck": {
"dependsOn": ["^build"],
"outputs": []
},
"test": {
"dependsOn": ["^build"],
"outputs": ["coverage/**"]
},
"build": {
"outputs": [".next/**", "public/**"]
"outputs": [".next/**", "public/**", "dist/**"]
},
"publishPackage": {
"dependsOn": ["^lint"],
Expand Down
Loading

1 comment on commit 8fd367f

@vercel
Copy link

@vercel vercel bot commented on 8fd367f Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gitmoji – ./

gitmoji-git-master-carloscuesta.vercel.app
gitmoji.dev
gitmoji-carloscuesta.vercel.app

Please sign in to comment.