Skip to content

Commit

Permalink
refactor: pnpm dev and build system (#278)
Browse files Browse the repository at this point in the history
* refactor: new dev mode and build struct

Co-authored-by: Mustafa Türköz <mturkoz93@users.noreply.github.com>

* fix: lint

* fix: filter

* fix: pnpm lock

* fix: typecheck

* chore: readme update

* fix: windows

* fix: nx build

* fix: playground

* fix: dev build mode

---------

Co-authored-by: Mustafa Türköz <mturkoz93@users.noreply.github.com>
  • Loading branch information
productdevbook and Mustafa Türköz authored Aug 12, 2023
1 parent 298b3ec commit bf112df
Show file tree
Hide file tree
Showing 28 changed files with 532 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .github/actions/cache-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ runs:
**/dist/**
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }}

- run: pnpm build:all
- run: pnpm build
if: steps.cache-build.outputs.cache-hit != 'true'
shell: bash
16 changes: 3 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note: What is Terminals Maganger and Commands -> https://github.com/oku-ui/prim
2. Install the project dependencies
`pnpm install`
3. Build the project
`pnpm build:all`
`pnpm build`
4. If new package vue, go to `packages/example-package` example `packages/components` or `packages/core` copy. You can copy
this file and build your new build on it.

Expand All @@ -49,22 +49,12 @@ pnpm build core utils # Build only core and utils package (packages/core) check
### Scripts

```shell
pnpm dev ${component-file-name} # Run a specific component
pnpm dev core ${core-file-name} # Run a specific core package

pnpm build ${component-file-name} # Build a specific component
pnpm build core ${core-file-name} # Build a specific core package
pnpm build:all # Build all packages
pnpm build:components # Build components package
pnpm build:core # Build core package
pnpm dev
pnpm build

pnpm story # Run Storybook
pnpm build:storybook # Build Storybook

pnpm dev:all # Run all packages
pnpm dev:components # Run components package
pnpm dev:core # Run core package

pnpm lint # Run ESLint
pnpm lint:fix # Run ESLint and fix errors

Expand Down
21 changes: 21 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build"
],
"parallel": 1
}
}
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
]
}
}
}
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
"engines": {
"node": ">=18"
},
"workspaces": [
"playground/*",
"packages/*",
"packages/components/*",
"packages/core/*"
],
"scripts": {
"dev": "esno scripts/dev.ts",
"build": "esno scripts/build.ts",
"build": "pnpm nx run-many -t build",
"p:build": "tsup",
"build:all": "turbo run build --filter='./packages/**'",
"build:components": "turbo run build --filter='./packages/components/**'",
"build:core": "turbo run build --filter='./packages/core/**'",
"dev:all": "turbo run dev --filter='./packages/**' --concurrency $(($(ls -1 packages/components packages/core | wc -l)+3))",
"dev:core": "turbo run dev --filter='./packages/core/**'",
"dev:components": "turbo run dev --filter='./packages/components/**' --concurrency $(($(ls -1 packages/components | wc -l)+3))",
"story": "pnpm storybook dev -p 6006 --no-open",
"lint": "eslint . --cache ",
"lint:fix": "eslint . --fix --cache",
"play:vue": "pnpm clean:dts && turbo run dev --filter='./playground/vue3/**'",
"play:nuxt": "pnpm clean:dts && turbo run dev --filter='./playground/nuxt3/**'",
"play": "pnpm clean:dts && turbo run dev --filter='./playground/**'",
"play:vue": "pnpm clean:dts && pnpm --filter=vue3 p:dev",
"play:nuxt": "pnpm clean:dts && pnpm --filter=nuxt3 p:dev",
"play": "pnpm clean:dts && pnpm --filter='./playground/**' p:dev",
"postinstall": "simple-git-hooks",
"test": "vitest run",
"test:watch": "vitest --watch",
Expand Down Expand Up @@ -70,15 +70,19 @@
"@vue/test-utils": "^2.4.1",
"autoprefixer": "^10.4.14",
"changelogen": "^0.5.4",
"chokidar": "^3.5.3",
"chromatic": "^6.21.0",
"eslint": "8.46.0",
"eslint-config-custom": "workspace:*",
"eslint-plugin-storybook": "^0.6.13",
"esno": "^0.17.0",
"globby": "^13.2.2",
"jiti": "^1.19.1",
"jsdom": "^22.1.0",
"lint-staged": "^13.2.3",
"nx": "^16.6.0",
"ofetch": "^1.1.1",
"pathe": "^1.1.1",
"postcss": "^8.4.27",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -88,7 +92,6 @@
"storybook-dark-mode": "^3.0.1",
"tailwindcss": "^3.3.3",
"tsup": "^7.2.0",
"turbo": "^1.10.12",
"typescript": "^5.1.6",
"unbuild": "^1.2.1",
"vite": "^4.4.7",
Expand Down
8 changes: 1 addition & 7 deletions packages/components/arrow/build.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
{
builder: 'mkdist',
input: './src/',
pattern: ['**/!(*.test|*.stories).ts'],
},
],
declaration: true,
clean: true,
})
4 changes: 1 addition & 3 deletions packages/core/primitive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs"
}
},
"require": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand Down
11 changes: 1 addition & 10 deletions packages/core/primitive/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ export default defineConfig((options) => {
external,
dts: true,
clean: true,
outDir: './dist',
target: 'node16',
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
},
{
...options,
entryPoints: ['src/index.ts'],
external,
dts: true,
clean: true,
target: 'node16',
format: ['cjs'],
outExtension: () => ({ js: '.cjs' }),
},
]
})
4 changes: 1 addition & 3 deletions packages/core/provide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand Down
11 changes: 1 addition & 10 deletions packages/core/provide/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ export default defineConfig((options) => {
external,
dts: true,
clean: true,
outDir: './dist',
target: 'node16',
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
},
{
...options,
entryPoints: ['src/index.ts'],
external,
dts: true,
clean: true,
target: 'node16',
format: ['cjs'],
outExtension: () => ({ js: '.cjs' }),
},
]
})
4 changes: 1 addition & 3 deletions packages/core/use-composable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand Down
11 changes: 1 addition & 10 deletions packages/core/use-composable/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ export default defineConfig((options) => {
external,
dts: true,
clean: true,
outDir: './dist',
target: 'node16',
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
},
{
...options,
entryPoints: ['src/index.ts'],
external,
dts: true,
clean: true,
target: 'node16',
format: ['cjs'],
outExtension: () => ({ js: '.cjs' }),
},
]
})
4 changes: 1 addition & 3 deletions packages/core/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand Down
11 changes: 1 addition & 10 deletions packages/core/utils/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ export default defineConfig((options) => {
external,
dts: true,
clean: true,
outDir: './dist',
target: 'node16',
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
},
{
...options,
entryPoints: ['src/index.ts'],
external,
dts: true,
clean: true,
target: 'node16',
format: ['cjs'],
outExtension: () => ({ js: '.cjs' }),
},
]
})
7 changes: 0 additions & 7 deletions packages/example-package/src/example.test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/example-package/src/example.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/example-package/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { exampleFn } from './example'
export type test = 'test'
export { deneme } from './test'
5 changes: 5 additions & 0 deletions packages/example-package/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const deneme = {
test: 'test',
}

export { deneme }
2 changes: 1 addition & 1 deletion packages/example-package/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "tsconfig/node16.json",
"compilerOptions": {
"rootDir": "src",
"baseUrl": "./",
"outDir": "dist"
},
"include": [
Expand Down
5 changes: 2 additions & 3 deletions packages/example-package/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ const external = [
export default defineConfig((options) => {
return [
{
...options,
entryPoints: ['src/index.ts'],
external,
dts: true,
clean: true,
target: 'node16',
outDir: './dist',
target: 'es2022',
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
},
Expand Down
6 changes: 3 additions & 3 deletions packages/tsconfig/node16.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 16",
"display": "Node 18",
"compilerOptions": {
"lib": [
"es2021",
"es2023",
"DOM"
],
"module": "Node16",
"target": "es2021",
"target": "ES2022",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
4 changes: 2 additions & 2 deletions playground/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "nuxt3-playground",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"p:build": "nuxt build",
"p:dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
Expand Down
4 changes: 2 additions & 2 deletions playground/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite --force --port 3010",
"build": "vue-tsc && vite build",
"p:dev": "vite --force --port 3010",
"p:build": "vite build",
"preview": "vite preview --port 3010",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
Expand Down
Loading

0 comments on commit bf112df

Please sign in to comment.