updated build pipeline

This commit is contained in:
2024-09-20 10:30:13 +05:30
parent 9d25fee43e
commit aa7e910523
6 changed files with 10538 additions and 34 deletions

10486
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,18 +9,16 @@
"lint": "eslint ."
},
"dependencies": {
"@armco/types": "^0.0.9",
"@armco/utils": "^0.0.7",
"react": ">16.8.0",
"react-dom": ">16.8.0"
},
"devDependencies": {
"@testing-library/dom": "^9.2.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.2.5",
"@types/node": "^22.5.5",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/testing-library__jest-dom": "^5.14.5",
"@vitejs/plugin-react": "^4.0.0",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8.0.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-prettier": "^4.2.1",
@@ -32,6 +30,7 @@
"vite": "^4.0.0",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vite-plugin-dts": "^4.2.1",
"vite-plugin-svgr": "^4.2.0",
"vitest": "^0.30.1"
},
"eslintConfig": {

View File

@@ -7,7 +7,7 @@ import {
IconProps,
IconState,
} from "@armco/types"
import { Network, withTheme } from "@armco/utils"
import Network from "@armco/utils/network"
import {
applyStyles,
createElementFromSvg,

View File

@@ -1,3 +1,4 @@
import React, { ReactElement } from "react"
import {
ArIconSourceTypes,
ArThemes,
@@ -5,7 +6,6 @@ import {
IconProps,
IconState,
} from "@armco/types"
import React, { ReactElement } from "react"
const parser = new DOMParser()
export const placeholder = parser
@@ -36,14 +36,6 @@ export const inferIconType = (source: string | object): ArIconSourceTypes => {
}
}
// async fetchIcon(url: string): Promise<string> {
// const response = await fetch(url)
// if (!response.ok) {
// throw new Error(`Failed to fetch icon from ${url}`)
// }
// return response.text()
// }
export const parseSvgString = (svgString: string): SVGSVGElement => {
try {
const doc = parser.parseFromString(svgString, ArValidImageMimeTypes.SVG)

View File

@@ -1,4 +1,27 @@
{
"extends": "../../tsconfig.json",
"include": ["src"]
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"outDir": "build",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}

View File

@@ -2,34 +2,38 @@ import { resolve } from "path"
import { defineConfig } from "vitest/config"
import react from "@vitejs/plugin-react"
import path from "path"
import svgr from "vite-plugin-svgr"
import dts from "vite-plugin-dts"
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
svgr(),
react(),
dts({ outDir: "build/types" }),
cssInjectedByJsPlugin(),
],
resolve: {
alias: {
"~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
},
},
plugins: [react(), dts({ outDir: "build/types" }), cssInjectedByJsPlugin()],
build: {
outDir: "build",
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "@armco/icon",
formats: ["cjs", "es"],
fileName: (format, b) => `${b}.${format}.js`,
entry: [
resolve(__dirname, "src/index.ts"),
resolve(__dirname, "src/helper.ts"),
resolve(__dirname, "src/Icon.tsx"),
],
},
rollupOptions: {
treeshake: true,
external: ["react", "react/jsx-runtime", "react-dom"],
output: [
{
format: "es",
dir: "build/es",
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
},
{
format: "cjs",
dir: "build/cjs",
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
},
],
},
},
})