From 59bec5e61cc9272d60b2fe624590fcc3b7692265 Mon Sep 17 00:00:00 2001 From: Amir Angel <36531255+17Amir17@users.noreply.github.com> Date: Wed, 7 Feb 2024 18:28:24 +0200 Subject: [PATCH] fix: build lib-web and fix types --- .github/workflows/cd.yml | 3 +-- package.json | 6 ++++-- src/webEditorUtils/tsconfig.json | 4 +++- src/webEditorUtils/vite.config.ts | 2 +- yarn.lock | 14 +++++++++++++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6fc9013..80cb098 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -21,8 +21,7 @@ jobs: - name: Build simple editor bundle run: yarn editor:build - name: Build web utils - run: yarn vite build - working-directory: src/webEditorUtils + run: yarn editor:build-web-utils - name: Build package run: yarn prepare - run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 495abd2..a09709c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "./web": { "import": "./lib-web/index.mjs", "require": "./lib-web/index.umd.cjs", - "types": "./lib/typescript/src/index.d.ts" + "types": "./lib-web/typescript/webEditorUtils/index.d.ts" } }, "source": "src/index", @@ -39,7 +39,8 @@ ], "scripts": { "editor:dev": "vite", - "editor:build": "vite build && node ./scripts/buildEditor.js", + "editor:build": "vite build && node ./scripts/buildEditor.js && editor:build-web-utils", + "editor:build-web-utils": "rimraf lib-web && vite build --config ./src/webEditorUtils/vite.config.ts && tsc --project ./src/webEditorUtils", "example": "yarn workspace tentap-example", "test": "jest", "typecheck": "tsc --noEmit", @@ -90,6 +91,7 @@ "react-native": "0.73.2", "react-native-builder-bob": "^0.20.0", "release-it": "^15.0.0", + "rimraf": "^5.0.5", "turbo": "^1.12.2", "typescript": "^5.0.2", "vite": "^5.0.12", diff --git a/src/webEditorUtils/tsconfig.json b/src/webEditorUtils/tsconfig.json index 783f07e..fe066d7 100644 --- a/src/webEditorUtils/tsconfig.json +++ b/src/webEditorUtils/tsconfig.json @@ -2,6 +2,8 @@ "$schema": "https://json.schemastore.org/tsconfig", "_version": "2.0.0", "compilerOptions": { + "outDir": "../../lib-web/typescript", + "declaration": true, "lib": ["dom", "dom.iterable", "esnext"], "module": "esnext", "moduleResolution": "bundler", @@ -13,7 +15,7 @@ "forceConsistentCasingInFileNames": true, "isolatedModules": true, "jsx": "react-jsx", - "noEmit": true, + "noEmit": false, "noFallthroughCasesInSwitch": true, "resolveJsonModule": true, "skipLibCheck": true, diff --git a/src/webEditorUtils/vite.config.ts b/src/webEditorUtils/vite.config.ts index c04659b..ee6dfa8 100644 --- a/src/webEditorUtils/vite.config.ts +++ b/src/webEditorUtils/vite.config.ts @@ -17,7 +17,7 @@ export default defineConfig({ // into your library external: ['react'], output: { - dir: '../../lib-web', + dir: 'lib-web', // Provide global variables to use in the UMD build // for externalized deps globals: { diff --git a/yarn.lock b/yarn.lock index f98be48..7308187 100644 --- a/yarn.lock +++ b/yarn.lock @@ -59,6 +59,7 @@ __metadata: react-native-builder-bob: ^0.20.0 react-native-webview: 13.6.4 release-it: ^15.0.0 + rimraf: ^5.0.5 turbo: ^1.12.2 typescript: ^5.0.2 vite: ^5.0.12 @@ -10809,7 +10810,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^10.2.2, glob@npm:^10.3.10": +"glob@npm:^10.2.2, glob@npm:^10.3.10, glob@npm:^10.3.7": version: 10.3.10 resolution: "glob@npm:10.3.10" dependencies: @@ -18442,6 +18443,17 @@ __metadata: languageName: node linkType: hard +"rimraf@npm:^5.0.5": + version: 5.0.5 + resolution: "rimraf@npm:5.0.5" + dependencies: + glob: ^10.3.7 + bin: + rimraf: dist/esm/bin.mjs + checksum: d66eef829b2e23b16445f34e73d75c7b7cf4cbc8834b04720def1c8f298eb0753c3d76df77325fad79d0a2c60470525d95f89c2475283ad985fd7441c32732d1 + languageName: node + linkType: hard + "rimraf@npm:~2.6.2": version: 2.6.3 resolution: "rimraf@npm:2.6.3"