From 13b9ca0a47ed336c3599844c5e36f7ab1d035947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vilcot?= Date: Tue, 26 Nov 2024 16:36:00 +0100 Subject: [PATCH] build(pci-common): add vite config to publish library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Vilcot --- .../modules/manager-pci-common/.gitignore | 3 + .../modules/manager-pci-common/README.md | 6 ++ .../modules/manager-pci-common/package.json | 72 +++++++++++------- .../modules/manager-pci-common/tsconfig.json | 8 +- .../manager-pci-common/vite.config.mjs | 76 +++++++++++++++++++ 5 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 packages/manager/modules/manager-pci-common/README.md create mode 100644 packages/manager/modules/manager-pci-common/vite.config.mjs diff --git a/packages/manager/modules/manager-pci-common/.gitignore b/packages/manager/modules/manager-pci-common/.gitignore index 6b7216d8e63a..8de08929365e 100644 --- a/packages/manager/modules/manager-pci-common/.gitignore +++ b/packages/manager/modules/manager-pci-common/.gitignore @@ -29,3 +29,6 @@ storybook-static coverage playwright-report tests-results + +# Bundle stats +stats diff --git a/packages/manager/modules/manager-pci-common/README.md b/packages/manager/modules/manager-pci-common/README.md new file mode 100644 index 000000000000..5aded36605b8 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/README.md @@ -0,0 +1,6 @@ +# ⚛️⚡ Public Could Manager Components Library + +## Features + +Hosts the components used in manager for the Public Cloud universe +Keep it as simple as possible diff --git a/packages/manager/modules/manager-pci-common/package.json b/packages/manager/modules/manager-pci-common/package.json index 61713a9ea8ad..877e25971e2d 100644 --- a/packages/manager/modules/manager-pci-common/package.json +++ b/packages/manager/modules/manager-pci-common/package.json @@ -1,70 +1,90 @@ { "name": "@ovh-ux/manager-pci-common", "version": "0.9.1", - "private": true, - "sideEffects": true, + "private": false, + "description": "Public Cloud Manager components", + "homepage": "https://github.com/ovh/manager/blob/master/packages/manager/modules/manager-pci-common/README.md", + "bugs": { + "url": "https://github.com/ovh/manager/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ovh/manager.git", + "directory": "packages/manager/modules/manager-pci-common" + }, + "license": "BSD-3-Clause", + "author": "OVH SAS", "type": "module", - "main": "./src/index.ts", + "main": "dist/index.js", + "types": "dist/types/index.d.ts", + "files": [ + "dist" + ], "scripts": { - "build": "tsc --project tsconfig.build.json", - "dev": "tsc", + "build": "vite build", + "clean": "rimraf node_modules && rimraf dist && yarn cache clean", + "dev": "vite build", "lint": "eslint ./src", "lint:fix": "eslint ./src --fix", + "prepare": "vite build", + "prettier": "prettier --write \"src/**/*.{ts,tsx,js,mdx}\"", "test": "vitest run", "test:coverage": "vitest run --coverage", - "test:coverage:watch": "vitest --coverage", - "test:watch": "vitest" + "test:watch": "vitest --watch", + "type:check": "tsc --noEmit" }, "dependencies": { + "@ovh-ux/manager-tailwind-config": "^0.2.1", "clsx": "2.1.1", "date-fns": "^3.6.0", - "element-internals-polyfill": "^1.3.11", - "file-saver": "^2.0.5", - "i18next": "^23.8.2", - "i18next-http-backend": "^2.6.1", "lodash.isequal": "^4.5.0" }, "devDependencies": { - "@jest/globals": "^29.7.0", "@ovh-ux/manager-core-api": "^0.9.0", - "@ovh-ux/manager-react-components": "^1.41.1", + "@ovh-ux/manager-react-components": "^1.42.0", "@ovh-ux/manager-react-shell-client": "^0.8.1", "@ovh-ux/manager-vite-config": "^0.8.3", + "@ovhcloud/ods-common-core": "^17.2.2", + "@ovhcloud/ods-common-stencil": "^17.2.2", + "@ovhcloud/ods-common-theming": "^17.2.2", + "@ovhcloud/ods-components": "^17.2.2", + "@ovhcloud/ods-theme-blue-jeans": "^17.2.2", + "@tanstack/react-query": "^5.51.21", "@testing-library/dom": "^10.1.0", "@testing-library/jest-dom": "^6.4.6", "@testing-library/react": "^16.0.0", "@testing-library/user-event": "^14.5.2", - "@types/file-saver": "^2.0.7", - "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-dom": "^18.2.19", "@vitejs/plugin-react": "^4.2.1", "@vitest/coverage-v8": "^1.2.2", + "element-internals-polyfill": "^1.3.11", + "i18next": "^23.8.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-i18next": "^14.0.5", + "react-router-dom": "^6.3.0", + "rollup-plugin-visualizer": "^5.12.0", "tailwindcss": "^3.4.10", "typescript": "^5.5.4", "vite": "^5.4.2", + "vite-plugin-dts": "3.5.1", "vitest": "^2.0.5" }, "peerDependencies": { - "@ovh-ux/manager-config": "^7.3.2", - "@ovh-ux/manager-core-api": "^0.9.0-alpha.0", - "@ovh-ux/manager-react-components": "^1.41.0-alpha.6", - "@ovh-ux/manager-react-shell-client": "^0.8.0-alpha.0", - "@ovh-ux/manager-tailwind-config": "^0.2.0", - "@ovh-ux/shell": "^3.7.0", + "@ovh-ux/manager-core-api": "^0.9.0", + "@ovh-ux/manager-react-components": "^1.42.0", + "@ovh-ux/manager-react-shell-client": "^0.8.1", "@ovhcloud/ods-common-core": "^17.2.2", "@ovhcloud/ods-common-stencil": "^17.2.2", "@ovhcloud/ods-common-theming": "^17.2.2", "@ovhcloud/ods-components": "^17.2.2", "@ovhcloud/ods-theme-blue-jeans": "^17.2.2", "@tanstack/react-query": "^5.51.21", - "@tanstack/react-query-devtools": "^5.51.21", - "@tanstack/react-table": "^8.20.1", + "i18next": "^23.8.2", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-hook-form": "^7.50.1", "react-i18next": "^14.0.5", - "react-router-dom": "^6.3.0", - "react-use": "^17.5.0" + "react-router-dom": "^6.3.0" } } diff --git a/packages/manager/modules/manager-pci-common/tsconfig.json b/packages/manager/modules/manager-pci-common/tsconfig.json index b8366b98fe06..e7e376496376 100644 --- a/packages/manager/modules/manager-pci-common/tsconfig.json +++ b/packages/manager/modules/manager-pci-common/tsconfig.json @@ -4,13 +4,17 @@ "useDefineForClassFields": true, "lib": ["ES2020", "dom"], "types": ["vite/client", "node"], + "outDir": "dist", "module": "ESNext", + "allowJs": true, "skipLibCheck": true, "moduleResolution": "node", "allowImportingTsExtensions": false, "resolveJsonModule": true, "isolatedModules": true, - "noEmit": true, + "declaration": true, + "declarationDir": "./dist/types", + "emitDeclarationOnly": true, "jsx": "react-jsx", "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, @@ -22,5 +26,5 @@ "esModuleInterop": true }, "include": ["src/**/*", "*.spec.tsx"], - "exclude": ["node_modules", "dist", "types"] + "exclude": ["node_modules", "dist"] } diff --git a/packages/manager/modules/manager-pci-common/vite.config.mjs b/packages/manager/modules/manager-pci-common/vite.config.mjs new file mode 100644 index 000000000000..697f3302ab19 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/vite.config.mjs @@ -0,0 +1,76 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vitest/config'; +import dts from 'vite-plugin-dts'; +import path from 'path'; +import tailwindcss from 'tailwindcss'; +import { getBaseConfig } from '@ovh-ux/manager-vite-config'; +import { visualizer } from 'rollup-plugin-visualizer'; +import * as packageJson from './package.json'; + +const baseConfig = getBaseConfig({}); +const pathSrc = path.resolve(__dirname, 'src'); + +export default defineConfig({ + ...baseConfig, + resolve: { + alias: { + '@/': pathSrc, + }, + }, + plugins: [ + react(), + dts({ + root: __dirname, + insertTypesEntry: true, + outDir: 'dist/types', + }), + visualizer({ + filename: 'stats/bundle-analysis.html', + }), + ], + css: { + postcss: { + plugins: [tailwindcss], + }, + }, + test: { + globals: true, + environment: 'jsdom', + }, + build: { + outDir: path.resolve(__dirname, 'dist'), + emptyOutDir: true, + lib: { + entry: path.resolve(pathSrc, 'index.ts'), + name: 'ManagerPciCommonLib', + fileName: 'index', + formats: ['es'], + }, + rollupOptions: { + external: (id) => { + const deps = [...Object.keys(packageJson.peerDependencies || {})]; + return deps.some((dep) => id === dep || id.startsWith(`${dep}/`)); + }, + output: { + globals: { + '@ovh-ux/manager-core-api': 'ManagerCoreApi', + '@ovh-ux/manager-react-components': 'ManagerReactComponents', + '@ovh-ux/manager-react-shell-client': 'ManagerReactShellClient', + '@ovhcloud/ods-common-core': 'OdsCommonCore', + '@ovhcloud/ods-common-stencil': 'OdsCommonStencil', + '@ovhcloud/ods-common-theming': 'OdsCommonTheming', + '@ovhcloud/ods-components': 'OdsComponents', + '@ovhcloud/ods-components/react': 'OdsComponentsReact', + '@ovhcloud/ods-theme-blue-jeans': 'OdsThemeBlueJeans', + '@tanstack/react-query': 'ReactQuery', + i18next: 'i18next', + react: 'React', + 'react-dom': 'ReactDOM', + 'react-i18next': 'ReactI18next', + 'react/jsx-runtime': 'ReactJsxRuntime', + 'react-router-dom': 'ReactRouterDOM', + }, + }, + }, + }, +});