Skip to content

Commit

Permalink
feature: add package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Aug 27, 2022
1 parent 89f2a48 commit bd19504
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 20 deletions.
10 changes: 8 additions & 2 deletions build/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { TaskFunction } from "undertaker";
import { deleteSync } from 'del'
import { buildModules } from './tasks/modules'
import { buildOutput } from './utils/paths'
import { copyTypesDefinitions, generateTypesDefinitions } from './tasks/types-definitions'
import { generateTypesDefinitions } from './tasks/types-definitions'
import { buildTheme } from './tasks/theme/gulpfile.prod'
import { copyComponentsPackages, copyTypesDefinitions } from './tasks/copy-file';

export const clean: TaskFunction = (done) => {
deleteSync(
Expand All @@ -14,4 +15,9 @@ export const clean: TaskFunction = (done) => {
done()
}

export default series(clean, buildTheme, parallel(buildModules, generateTypesDefinitions), copyTypesDefinitions)
export default series(
clean,
buildTheme,
parallel(buildModules, generateTypesDefinitions),
parallel(copyTypesDefinitions, copyComponentsPackages)
)
20 changes: 20 additions & 0 deletions build/tasks/copy-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { buildOutput, epOutput, pkgRoot } from "../utils/paths"
import { buildConfig, Module } from "../utils/build-info"
import { copy, copyFile } from 'fs-extra'
import { resolve, join } from 'path'
import { parallel, TaskFunction } from "gulp"

export const copyTypesDefinitions: TaskFunction = (done) => {
const src = resolve(buildOutput, 'types', 'packages')
const copyTypes = (module: Module) =>
Object.assign(
() => copy(src, buildConfig[module].output.path, { recursive: true }),
{ displayName: `copyTypes:${module}` }
)

return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
}

export const copyComponentsPackages = () => {
return copyFile(resolve(pkgRoot, 'package.json'), join(epOutput, 'package.json'))
}
19 changes: 1 addition & 18 deletions build/tasks/types-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { Project } from 'ts-morph'
import type { CompilerOptions, SourceFile } from 'ts-morph'
import { buildOutput, epRoot, pkgRoot, projRoot, PKG_NAME } from '../utils/paths'
import { excludeFiles } from './modules'
import { parallel } from 'gulp'
import type { TaskFunction } from 'gulp'
import { copy } from 'fs-extra'
import { buildConfig, Module } from '../utils/build-info'

const TSCONFIG_PATH = path.resolve(projRoot, 'tsconfig.web.json')
const outDir = path.resolve(buildOutput, 'types')
Expand Down Expand Up @@ -149,17 +145,4 @@ function typeCheck(project: Project) {
consola.error(err)
throw err
}
}

export const withTaskName = <T>(name: string, fn: T) =>
Object.assign(fn, { displayName: name })

export const copyTypesDefinitions: TaskFunction = (done) => {
const src = path.resolve(buildOutput, 'types', 'packages')
const copyTypes = (module: Module) =>
withTaskName(`copyTypes:${module}`, () =>
copy(src, buildConfig[module].output.path, { recursive: true })
)

return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
}
}
55 changes: 55 additions & 0 deletions packages/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "xs-components",
"version": "1.0.0",
"description": "Vue3 Component Library",
"keywords": [
"xs-components",
"ui framework",
"vue"
],
"bugs": {
"url": "https://github.com/jsxiaosi/xiaosiCommitLib/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jsxiaosi/xiaosiCommitLib.git"
},
"license": "MIT",
"main": "lib/index.js",
"module": "es/index.mjs",
"types": "es/*.d.ts",
"exports": {
".": {
"require": "./lib/index.js",
"import": "./es/index.mjs",
"types/*": "./es/*.ts"
},
"./es": "./es/index.mjs",
"./lib": "./lib/index.js",
"./es/*.mjs": "./es/*.mjs",
"./es/*": "./es/*.mjs",
"./lib/*.js": "./lib/*.js",
"./lib/*": "./lib/*.js",
"./*": "./*"
},
"publishConfig": {
"access": "public"
},
"style": "./theme-default/index.css",
"sideEffects": [
"theme-chalk/**/*.css",
"theme-chalk/src/**/*.scss",
"es/components/*/style/*",
"lib/components/*/style/*"
],
"peerDependencies": {
"vue": "^3.2.0"
},
"dependencies": {},
"devDependencies": {},
"browserslist": [
"> 1%",
"not ie 11",
"not op_mini all"
]
}

0 comments on commit bd19504

Please sign in to comment.