mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-11-27 04:09:51 +08:00
build: ts build
This commit is contained in:
parent
ea3744dc1b
commit
43658733e4
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,4 +17,3 @@ es
|
||||
coverage
|
||||
/fonts
|
||||
/site
|
||||
/src-mirror
|
||||
|
@ -1,67 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const rollup = require('rollup')
|
||||
const vuePlugin = require('rollup-plugin-vue')
|
||||
|
||||
const srcDir = path.resolve(__dirname, '../src')
|
||||
const srcMirrorDir = path.resolve(__dirname, '../src-mirror')
|
||||
const projectDir = path.resolve(__dirname, '..')
|
||||
|
||||
async function findAndReplace (filePath, pattern, target) {
|
||||
const content = (await fs.readFile(filePath)).toString()
|
||||
if (pattern.test(content)) {
|
||||
await fs.writeFile(filePath, content.replace(pattern, target))
|
||||
}
|
||||
}
|
||||
|
||||
async function traverse (root) {
|
||||
const dir = await fs.opendir(root)
|
||||
for await (const dirent of dir) {
|
||||
const { name } = dirent
|
||||
if (dirent.isDirectory()) {
|
||||
await traverse(path.resolve(root, dirent.name))
|
||||
} else {
|
||||
const filePath = path.resolve(root, name)
|
||||
// change all vue import to js
|
||||
await findAndReplace(filePath, /\.vue/g, '.js')
|
||||
// build js output for vue file
|
||||
if (filePath.endsWith('.vue')) {
|
||||
console.log('make', filePath.replace(projectDir, ''))
|
||||
const rollupInputOptions = {
|
||||
input: filePath,
|
||||
external: (id) => {
|
||||
return !/\.vue\?vue/.test(id)
|
||||
},
|
||||
plugins: [
|
||||
vuePlugin({
|
||||
file: false
|
||||
})
|
||||
]
|
||||
}
|
||||
const rollupOutputOptions = {
|
||||
format: 'esm',
|
||||
file: filePath.replace(/\.vue$/, '.js')
|
||||
}
|
||||
const bundle = await rollup.rollup(rollupInputOptions)
|
||||
await bundle.write(rollupOutputOptions)
|
||||
// remove original file
|
||||
await fs.unlink(filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
try {
|
||||
if (await fs.pathExists(srcMirrorDir)) {
|
||||
await fs.emptyDir(srcMirrorDir)
|
||||
await fs.remove(srcMirrorDir)
|
||||
}
|
||||
await fs.mkdir(srcMirrorDir)
|
||||
await fs.copy(srcDir, srcMirrorDir)
|
||||
await fs.emptyDir(path.resolve(srcMirrorDir, '_deprecated/icons'))
|
||||
traverse(srcMirrorDir)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})()
|
@ -7,7 +7,7 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
const iconPath = path.resolve(__dirname, '..', 'src', '_deprecated', 'icons')
|
||||
const iconPath = path.resolve(__dirname, '..', 'compat', 'icons')
|
||||
|
||||
const cjsIconPath = path.resolve(__dirname, '..', 'lib', 'icons')
|
||||
const esmIconPath = path.resolve(__dirname, '..', 'es', 'icons')
|
||||
|
14
package.json
14
package.json
@ -7,14 +7,15 @@
|
||||
"scripts": {
|
||||
"start": "npm run dev",
|
||||
"deprecated:build:icons": "npm run clean && node build/build-icons.js",
|
||||
"build:js": "npm run gen-version && npm run clean && node build/before-build.js && rollup -c",
|
||||
"build:package": "npm run gen-version && npm run clean && node build/build-icons.js && node build/before-build.js && rollup -c",
|
||||
"build:js": "npm run gen-version && npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",
|
||||
"build:package": "npm run gen-version && npm run clean && node build/build-icons.js && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",
|
||||
"build:site": "npm run build:package && ./build/before-build-site.sh && node build/restore-side-effects.js && cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 vite build && rm -rf node_modules/naive-ui && cp site/index.html site/404.html && node build/clear-side-effects.js",
|
||||
"build:doc": "npm run gen-version && npm run build && rm -rf build-doc/dist && cross-env NODE_ENV=production webpack --config build/webpack.doc.js",
|
||||
"clean": "rm -rf site lib es src-mirror node_modules/naive-ui",
|
||||
"clean": "rm -rf site lib es node_modules/naive-ui",
|
||||
"dev": "npm run clean && npm run gen-version && cross-env NODE_ENV=development vite",
|
||||
"dev:ts": "npm run clean && npm run gen-version && cross-env NODE_ENV=development TUSIMPLE=true vite",
|
||||
"lint": "npm run lint:code",
|
||||
"lint": "npm run lint:code && npm run lint:type",
|
||||
"lint:type": "tsc --noEmit",
|
||||
"lint:code": "eslint --fix \"{src,build,scripts,demo}/**/*.{js,vue,md}\"",
|
||||
"format": "npm run format:code && npm run format:md",
|
||||
"format:code": "prettier --write \"(src|demo)/**/*.(vue|js)\"",
|
||||
@ -34,6 +35,7 @@
|
||||
"registry": "***REMOVED***"
|
||||
},
|
||||
"files": [
|
||||
"compat",
|
||||
"es",
|
||||
"lib",
|
||||
"src",
|
||||
@ -124,13 +126,13 @@
|
||||
"highlight.js": "^10.4.1",
|
||||
"lodash-es": "^4.17.15",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"seemly": "^0.1.5",
|
||||
"seemly": "^0.1.6",
|
||||
"treemate": "^0.2.4",
|
||||
"vdirs": "^0.0.3",
|
||||
"vfonts": "^0.0.1",
|
||||
"vooks": "0.0.8",
|
||||
"vue": "^3.0.5",
|
||||
"vueuc": "^0.1.1"
|
||||
"vueuc": "^0.1.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
@ -150,11 +150,12 @@ export default defineComponent({
|
||||
ref: 'bodyLayoutInstRef',
|
||||
nativeScrollbar: false,
|
||||
scrollbarProps: {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
contentStyle: {
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
padding: this.paddingBody ? '21px 48px' : null
|
||||
}
|
||||
padding: this.paddingBody ? '21px 48px' : ''
|
||||
} as CSSProperties
|
||||
}
|
||||
}
|
||||
const headerProps = {
|
||||
|
@ -23,7 +23,7 @@ type UseFormItemProps<T> =
|
||||
}
|
||||
| {}
|
||||
|
||||
interface UseFormItem<T> {
|
||||
export interface UseFormItem<T> {
|
||||
mergedSize: ComputedRef<T>
|
||||
nTriggerFormBlur: () => void
|
||||
nTriggerFormChange: () => void
|
||||
|
@ -14,7 +14,7 @@ import { cardLight } from '../styles'
|
||||
import type { CardTheme } from '../styles'
|
||||
import style from './styles/index.cssr'
|
||||
|
||||
interface Segmented {
|
||||
export interface Segmented {
|
||||
content?: boolean | 'soft'
|
||||
footer?: boolean | 'soft'
|
||||
action?: boolean | 'soft'
|
||||
|
@ -39,7 +39,7 @@ function createLocalesObject (
|
||||
}, defaultLocaleMap)
|
||||
}
|
||||
|
||||
interface NaiveUI {
|
||||
export interface NaiveUI {
|
||||
version: string
|
||||
use: (plugin: any) => void
|
||||
install: Function
|
||||
|
@ -3,7 +3,7 @@ import { PropType } from 'vue'
|
||||
export const positionProp = {
|
||||
type: String as PropType<'static' | 'absolute'>,
|
||||
default: 'static'
|
||||
}
|
||||
} as const
|
||||
|
||||
export interface LayoutRef {
|
||||
scrollTo: ((options: ScrollToOptions) => void) &
|
||||
|
@ -3,7 +3,7 @@ import { VNodeChild } from 'vue'
|
||||
|
||||
export type Key = string | number
|
||||
|
||||
interface MenuOptionBase {
|
||||
export interface MenuOptionBase {
|
||||
key: Key
|
||||
disabled?: boolean
|
||||
icon?: () => VNodeChild
|
||||
@ -12,7 +12,7 @@ interface MenuOptionBase {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface MenuGroupOptionBase extends MenuOptionBase {
|
||||
export interface MenuGroupOptionBase extends MenuOptionBase {
|
||||
type: 'group'
|
||||
children: Array<MenuOption | MenuGroupOption>
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export interface RadioGroupInjection {
|
||||
doUpdateValue: (value: string | number) => void
|
||||
}
|
||||
|
||||
interface UseRadio {
|
||||
export interface UseRadio {
|
||||
inputRef: Ref<HTMLElement | null>
|
||||
labelRef: Ref<HTMLElement | null>
|
||||
mergedName: Ref<string | undefined>
|
||||
|
@ -22,7 +22,7 @@ import { scrollbarLight } from '../styles'
|
||||
import type { ScrollbarTheme } from '../styles'
|
||||
import style from './styles/index.cssr'
|
||||
|
||||
interface ScrollTo {
|
||||
export interface ScrollTo {
|
||||
(x: number, y: number): void
|
||||
(options: {
|
||||
left?: number
|
||||
|
8
tsconfig.cjs.json
Normal file
8
tsconfig.cjs.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"module": "CommonJS",
|
||||
"target": "ES6"
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "es",
|
||||
"module": "ESNext"
|
||||
"module": "ESNext",
|
||||
"target": "ESNext"
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
"jsxFragmentFactory": "Fragment",
|
||||
"module": "ES6",
|
||||
"moduleResolution": "Node",
|
||||
"declaration": true,
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM"
|
||||
|
11
vue3.md
11
vue3.md
@ -7,9 +7,9 @@
|
||||
- fonts
|
||||
- `naive-ui/lib|es/styles/fonts/*` has been removed, use [`vfonts`](https://www.npmjs.com/package/vfonts)
|
||||
- icons
|
||||
- `naive-ui/lib|es/icons/*` is deprecated, use [`vicons`](https://www.npmjs.com/package/vicons) instead.
|
||||
- `naive-ui/lib|es/icons/*` is deprecated (vue-loader is required), use [`vicons`](https://www.npmjs.com/package/vicons) instead.
|
||||
- `n-nimbus-icon` is moved to `naive-ui/compat/nimbus-icon` (vue-loader is required)
|
||||
- `n-nimbus-form-card` is removed
|
||||
- `n-nimbus-icon` is removed
|
||||
|
||||
## Components
|
||||
|
||||
@ -422,13 +422,14 @@
|
||||
- [x] form item no label css
|
||||
- [x] unify treemate ignored
|
||||
- [ ] fix menu extra
|
||||
- [ ] build icon
|
||||
- [ ] compat
|
||||
- [x] build icon
|
||||
- [x] compat
|
||||
- [ ] on update value api
|
||||
- [ ] fix upload dragger
|
||||
- [x] fix upload dragger
|
||||
- [x] fix table sorter
|
||||
- [x] tree 多选节点第二个 demo
|
||||
- [ ] table treemate!!!
|
||||
- [ ] createTheme
|
||||
|
||||
## Info
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user