From 537d77d5a70f44781d86d850b22427e4924591bd Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Thu, 25 Apr 2024 13:47:39 +0200 Subject: [PATCH] build icon with swc (#2726) --- .changeset/config.json | 1 + packages/components/icon/.srwrc | 18 ++++++++++++++++++ packages/components/icon/package.json | 22 ++++++++++++++++++---- packages/components/icon/tsconfig.json | 10 ++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 packages/components/icon/.srwrc create mode 100644 packages/components/icon/tsconfig.json diff --git a/.changeset/config.json b/.changeset/config.json index 8c2e45c458..6e65edb939 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,6 +7,7 @@ } ], "ignore": [ + "@contentful/f36-icon", "@contentful/f36-icons", "@contentful/f36-avatar", "@contentful/f36-image", diff --git a/packages/components/icon/.srwrc b/packages/components/icon/.srwrc new file mode 100644 index 0000000000..f9dfcd0d7f --- /dev/null +++ b/packages/components/icon/.srwrc @@ -0,0 +1,18 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true + }, + "target": "es2020", + "loose": false, + "minify": { + "compress": false, + "mangle": false + } + }, + "module": { + "type": "es6" + }, + "minify": false +} diff --git a/packages/components/icon/package.json b/packages/components/icon/package.json index b7270522c7..431160efcf 100644 --- a/packages/components/icon/package.json +++ b/packages/components/icon/package.json @@ -1,10 +1,13 @@ { "name": "@contentful/f36-icon", - "version": "5.0.0-alpha.0", + "version": "5.0.0-alpha.1", "description": "Forma 36: Icon component", "license": "MIT", "scripts": { - "build": "tsup" + "build": "npm run build:esm && npm run build:cjs && npm run build:types", + "build:cjs": "swc ./src -d ./dist/cjs --strip-leading-paths -C module.type=commonjs", + "build:esm": "swc ./src -d ./dist/esm --strip-leading-paths", + "build:types": "tsc --outDir ./dist/types --emitDeclarationOnly" }, "dependencies": { "@contentful/f36-core": "^4.67.1", @@ -13,13 +16,24 @@ "emotion": "^10.0.17" }, "devDependencies": { - "react-icons": "^4.4.0", - "@contentful/f36-icons-v4": "npm:@contentful/f36-icons@^4.0.0" + "@contentful/f36-icons-v4": "npm:@contentful/f36-icons@^4.0.0", + "@swc/cli": "^0.3.12", + "@swc/core": "^1.4.14", + "react-icons": "^4.4.0" }, "peerDependencies": { "react": ">=16.8", "react-dom": ">=16.8" }, + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "default": "./dist/esm/index.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], diff --git a/packages/components/icon/tsconfig.json b/packages/components/icon/tsconfig.json new file mode 100644 index 0000000000..32fd5ebd16 --- /dev/null +++ b/packages/components/icon/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["src"], + "exclude": ["dist/**/*"], + "compilerOptions": { + "allowJs": false, + "declaration": true, + "noEmit": false, + }, +}