Skip to content

Commit

Permalink
fix: Refactor a lot of build things for icons (#58)
Browse files Browse the repository at this point in the history
* Refactor a lot of build things for icons

* Some more cleanup and readme update
  • Loading branch information
imprashast committed Nov 16, 2023
1 parent a070e0e commit 5c0efc8
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 831 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
- name: Eik login and publish
run: pnpm eik login -k $EIK_TOKEN && pnpm eik publish || true
env:
EIK_TOKEN: ${{ secrets.EIK_TOKEN }}
run: npx semantic-release
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,13 @@ pnpm dev

### Typescript support

You can define an 'icons.d.ts' file in your repo and export the types bundled with the package for the correct namespace. Eg for React:

```
declare module '@warp-ds/icons/react' {
export * from '@warp-ds/icons/dist/types/react'
}
```
We are bundling types now for all named exports. To make Typescript compiler compliant to these changes you'll need to use `"module": "NodeNext"` in your tsconfig and then all the imports would have types.

## Releases

This project is continuously published to [NPM](https://www.npmjs.com/package/@warp-ds/icons) and [Eik](https://assets.finn.no/pkg/@warp-ds/icons) using a `next` tag (e.g. `1.1.0-next.1`).
This project is continuously published to [NPM](https://www.npmjs.com/package/@warp-ds/icons) using a `next` tag (e.g. `1.1.0-next.1`).
Anyone needing to use the latest changes of this package can point to the `next` version while waiting for the stable release.

Eik versions for each of Vue, Elements and React icons that are built to the ./dist folder are automatically published to Eik under the path `https://assets.finn.no/pkg/{name}/{version}/`.

Example Paths:
* React: `https://assets.finn.no/pkg/@warp-ds/icons/v1/react/icons.min.js`
* Vue: `https://assets.finn.no/pkg/@warp-ds/icons/v1/vue/icons.min.js`
* Custom Elements: `https://assets.finn.no/pkg/@warp-ds/icons/v1/elements/icons.min.js`
* Raw ads svg at size 16: `https://assets.finn.no/pkg/@warp-ds/icons/v1/16/ads.svg`
* Raw air con svg at size 24: `https://assets.finn.no/pkg/@warp-ds/icons/v1/24/air-con.svg`


## Changelog

Detailed changes for each release can be found in the [CHANGELOG](CHANGELOG.md) file.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion elements.eik.js → buildElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ files.forEach(async (filePath) => {
format: "esm",
sourcemap: true,
target: "es2017",
minify: true,
minify: false,
external: ["lit", "@lingui/core"],
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion react.eik.js → buildReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ files.forEach(async (filePath) => {
format: "esm",
sourcemap: true,
target: "es2017",
minify: true,
minify: false,
external: ["react", "@lingui/core"],
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion vue.eik.js → buildVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ files.forEach(async (filePath) => {
format: "esm",
sourcemap: true,
target: "es2017",
minify: true,
minify: false,
external: ["vue", "@lingui/core"],
});
} catch (err) {
Expand Down
69 changes: 37 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@
"version": "1.2.0",
"repository": "git@github.com:warp-ds/icons.git",
"description": "WARP's icon set",
"main": "index.js",
"main": "main.js",
"files": [
"dist"
],
"types": "./dist/types",
"typesVersions": {
"*": {
"./react": [
"./dist/react/index.d.ts"
],
"./react/*": [
"./dist/react/*.d.ts"
],
"./vue": [
"./dist/vue/index.d.ts"
],
"./vue/*": [
"./dist/vue/*.d.ts"
],
"./elements": [
"./dist/elements/index.d.ts"
],
"./elements/*": [
"./dist/elements/*.d.ts"
]
}
},
"exports": {
"./react": "./dist/react/index.js",
"./react/*": "./dist/react/*.js",
Expand All @@ -19,26 +40,24 @@
"./package.json": "./package.json"
},
"scripts": {
"commit": "cz",
"tsc": "tsc",
"import": "node ./scripts/import.js",
"build:all": "lingui extract && lingui compile && rimraf react && mkdir react && rimraf vue && mkdir vue && rimraf elements && mkdir elements && node ./scripts/output/react.js && node ./buildReact.js && node ./scripts/output/vue.js && node ./buildVue.js && node ./scripts/output/elements.js && node ./buildElements.js",
"build:elements": "rimraf elements && mkdir elements && lingui extract && lingui compile && node ./scripts/output/elements.js && node ./buildElements.js",
"build:react": "rimraf react && mkdir react && lingui extract && lingui compile && node ./scripts/output/react.js && node ./buildReact.js",
"build:release": "rimraf dist && pnpm build && pnpm build:vue && pnpm build:react && pnpm build:elements && tsc",
"build:vue": "rimraf vue && mkdir vue && lingui extract && lingui compile && node ./scripts/output/vue.js && node ./buildVue.js",
"build": "node ./scripts/build.js && pnpm i18n",
"i18n": "node ./scripts/i18n.js",
"commit": "cz",
"dev": "pnpm build && vite",
"i18n:clear": "node scripts/i18n-helpers/clear-locales.js",
"i18n:get-sorted-locales": "node scripts/i18n-helpers/sort-locales.js",
"dev": "pnpm build && vite",
"build:release": "rimraf dist && pnpm build && pnpm build:vue && pnpm build:react && pnpm build:elements && tsc",
"vite:build": "vite build",
"i18n": "node ./scripts/i18n.js",
"import": "node ./scripts/import.js",
"preview": "pnpm run build && vite build && vite preview",
"build:react": "rimraf react && mkdir react && lingui extract && lingui compile && node ./scripts/output/react.js && node ./react.eik.js",
"build:vue": "rimraf vue && mkdir vue && lingui extract && lingui compile && node ./scripts/output/vue.js && node ./vue.eik.js",
"build:elements": "rimraf elements && mkdir elements && lingui extract && lingui compile && node ./scripts/output/elements.js && node ./elements.eik.js",
"build:all": "lingui extract && lingui compile && rimraf react && mkdir react && rimraf vue && mkdir vue && rimraf elements && mkdir elements && node ./scripts/output/react.js && node ./react.eik.js && node ./scripts/output/vue.js && node ./vue.eik.js && node ./scripts/output/elements.js && node ./elements.eik.js"
"tsc": "tsc",
"vite:build": "vite build"
},
"license": "Apache-2.0",
"devDependencies": {
"@eik/cli": "^2.0.22",
"@eik/esbuild-plugin": "^1.1.11",
"@lingui/cli": "^4.4.2",
"@lingui/conf": "^4.4.2",
"@semantic-release/changelog": "^6.0.3",
Expand All @@ -63,26 +82,12 @@
"svgo": "^3.0.0",
"typescript": "^5.2.2",
"unocss": "^0.56.0",
"vite": "^4.4.9",
"vite-plugin-nunjucks": "^0.1.10"
"vite-plugin-nunjucks": "^0.1.10",
"vite": "^4.4.9"
},
"publishConfig": {
"access": "public"
},
"eik": {
"server": "https://assets.finn.no",
"type": "package",
"files": {
"react": "./dist/react",
"vue": "./dist/vue",
"elements": "./dist/elements"
},
"import-map": [
"https://assets.finn.no/map/react/v2",
"https://assets.finn.no/map/vue/v1",
"https://assets.finn.no/map/custom-elements/v2"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand All @@ -91,4 +96,4 @@
"dependencies": {
"@lingui/core": "^4.4.2"
}
}
}
Loading

0 comments on commit 5c0efc8

Please sign in to comment.