Skip to content

Commit

Permalink
build: make config as public package
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Aug 29, 2023
1 parent 3e8bca7 commit 78e93dc
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 70 deletions.
21 changes: 21 additions & 0 deletions common/config/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019-present vexip-ui

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
23 changes: 22 additions & 1 deletion common/config/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
{
"name": "@vexip-ui/config",
"version": "0.0.0",
"license": "MIT",
"author": "qmhc",
"type": "module",
"scripts": {
"build": "vite build"
},
"main": "dist/index.mjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"private": true,
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
},
"private": false,
"files": [
"dist"
],
"homepage": "https://github.com/vexip-ui/vexip-ui/tree/main/common/config#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/vexip-ui/vexip-ui.git",
"directory": "common/config"
},
"dependencies": {
"@vexip-ui/bem-helper": "workspace:*",
"@vexip-ui/utils": "workspace:*"
Expand Down
2 changes: 2 additions & 0 deletions common/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export * from './icons'
export * from './namespace'
export * from './props'
export * from './z-index'

export type * from './types'
20 changes: 20 additions & 0 deletions common/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"allowJs": false,
"strict": true,
"moduleResolution": "node",
"skipLibCheck": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": false,
"outDir": "dist",
"declaration": true,
"types": ["vite/client"]
},
"include": ["src"],
"exclude": ["node_modules"]
}
17 changes: 17 additions & 0 deletions common/config/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'

export default defineConfig({
build: {
sourcemap: true,
lib: {
entry: 'src/index.ts',
formats: ['cjs', 'es'],
fileName: format => `index.${format === 'es' ? 'mjs' : 'cjs'}`
},
rollupOptions: {
external: ['@vue', 'vue']
}
},
plugins: [dts({ rollupTypes: true })]
})
3 changes: 1 addition & 2 deletions common/meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"private": true,
"devDependencies": {
"dotenv": "^16.3.1",
"npm-run-all": "^4.1.5"
"dotenv": "^16.3.1"
}
}
2 changes: 1 addition & 1 deletion dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"autoprefixer": "^10.4.14",
"postcss": "^8.4.24",
"unplugin-vue-components": "^0.22.12"
"unplugin-vue-components": "^0.25.1"
}
}
17 changes: 1 addition & 16 deletions dev-server/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,7 @@ export default defineConfig(() => {
}
],
exclude: ['../components/**']
}),
{
name: 'single-hmr',
handleHotUpdate({ modules, file }) {
if (file.match(/xml$/)) return []

modules.forEach(m => {
if (!m.url.match(/\.(s|p)?css/)) {
m.clientImportedModules = new Set()
m.importers = new Set()
}
})

return modules
}
}
})
]
}
})
Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"private": true,
"dependencies": {
"@vexip-ui/bem-helper": "workspace:*",
"@vexip-ui/config": "workspace:*",
"@vexip-ui/hooks": "workspace:*",
"@vexip-ui/icons": "workspace:*",
"@vexip-ui/utils": "workspace:*",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"serve:theme": "tsx scripts/serve.ts --theme",
"build": "tsx scripts/build.ts",
"build:bem": "pnpm -C common/bem-helper build && pnpm i",
"build:common": "pnpm run build:utils && pnpm run build:bem && pnpm run build:hooks && pnpm run build:icons",
"build:common": "run-s build:utils build:bem build:config build:hooks build:icons",
"build:config": "pnpm -C common/config build && pnpm i",
"build:docs": "pnpm -C docs build",
"build:full": "tsx scripts/build-full.ts",
Expand All @@ -27,7 +27,7 @@
"build:style": "gulp --require sucrase/register/ts",
"build:utils": "pnpm -C common/utils build && pnpm i",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
"clean": "rimraf node_modules/.cache && rimraf node_modules/.vite && rimraf node_modules/.rts2_cache",
"clean": "rimraf node_modules/.cache && rimraf node_modules/.vite",
"create": "tsx scripts/create.ts",
"lint": "eslint --cache \"**/*.{js,cjs,mjs,ts,tsx,vue}\"",
"lint:style": "stylelint --cache \"**/*.{vue,scss}\"",
Expand Down Expand Up @@ -134,6 +134,7 @@
},
"dependencies": {
"@vexip-ui/bem-helper": "workspace:*",
"@vexip-ui/config": "workspace:*",
"@vexip-ui/hooks": "workspace:*",
"@vexip-ui/icons": "workspace:*",
"@vexip-ui/utils": "workspace:*"
Expand Down Expand Up @@ -180,6 +181,7 @@
"lint-staged": "^13.2.3",
"magic-string": "^0.30.1",
"minimist": "^1.2.8",
"npm-run-all": "^4.1.5",
"pinst": "^3.0.0",
"prettier": "^2.8.8",
"prompts": "^2.4.2",
Expand Down
45 changes: 5 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export function emptyDir(dir: string) {
const packages = [
'vexip-ui',
'common/bem-helper',
'common/config',
'common/hooks',
'common/icons',
'common/plugins',
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default defineConfig(async () => {
resolve: {
alias: [
{ find: /^@\/components/, replacement: resolve(__dirname, 'components') },
{ find: /^@\/directives/, replacement: resolve(__dirname, 'directives') },
{ find: '@vexip-ui/config', replacement: resolve(__dirname, 'common/config/src') }
{ find: /^@\/directives/, replacement: resolve(__dirname, 'directives') }
// { find: '@vexip-ui/config', replacement: resolve(__dirname, 'common/config/src') }
]
},
esbuild: {
Expand Down
12 changes: 6 additions & 6 deletions vite.full.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export default defineConfig(async () => {
resolve: {
alias: [
{ find: /^@\/(.+)/, replacement: resolve(__dirname, '$1') },
// {
// find: /^@vexip-ui\/config/,
// replacement: resolve(__dirname, 'common/config/src')
// },
{
find: /^@vexip-ui\/config/,
replacement: resolve(__dirname, 'common/config/src')
},
{
find: /^@vexip-ui\/(bem-helper|utils|hooks)/,
find: /^@vexip-ui\/(bem-helper|utils|hooks|config)/,
replacement: resolve(__dirname, 'common/$1/src')
}
]
Expand Down Expand Up @@ -94,7 +94,7 @@ export default defineConfig(async () => {
},
copyDtsFiles: true,
pathsToAliases: false,
aliasesExclude: [/^@vexip-ui\/(bem-helper|utils|hooks)/]
aliasesExclude: [/^@vexip-ui\/(bem-helper|utils|hooks|config)/]
})
]
}
Expand Down

0 comments on commit 78e93dc

Please sign in to comment.