fix(build): fix exclude dependency (#3404)

* fix(build): fix exclude dependency

* Update utils.ts
This commit is contained in:
三咲智子 2021-09-15 01:13:36 +08:00 committed by GitHub
parent 680de635f6
commit 5c70b303d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 187 additions and 445 deletions

View File

@ -36,7 +36,7 @@ jobs:
- name: Gen npmrc
run: echo "//registry.npmjs.com/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" > ./.npmrc
- name: Build&publish
run: sh ./scripts/monorepo.sh
run: sh ./scripts/deploy.sh
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
TAG_VERSION: ${{env.TAG_VERSION}}

5
build/.eslintrc.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
rules: {
'no-console': 'off',
},
}

View File

@ -15,7 +15,7 @@ interface Index {
path: string
}
const algoliaKey = process.env.ALGOLIA_KEY
const algoliaKey = process.env.ALGOLIA_KEY!
const client = algoliasearch('7DCTSU0WBW', algoliaKey)
const langs = {
@ -33,7 +33,7 @@ const langs = {
let indices: Index[] = []
files.forEach((file) => {
const regExp = new RegExp(`website\/docs\/${lang}\/(.*).md`)
const pathContent = file.match(regExp)
const pathContent = file.match(regExp)!
const path = pathContent[1]
const index = path.lastIndexOf('/')
const names = index !== -1 ? path.split('/') : []
@ -42,7 +42,7 @@ const langs = {
const matches = content
.replace(/:::[\s\S]*?:::/g, '')
.replace(/```[\s\S]*?```/g, '')
.match(/#{2,4}[^#]*/g)
.match(/#{2,4}[^#]*/g)!
.map((match) =>
match
.replace(/\n+/g, '\n')

View File

@ -3,12 +3,19 @@ import fs from 'fs'
import save from 'file-save'
import { resolve, basename } from 'path'
import { buildOutput } from './paths'
import babel from '@babel/core'
import type { FileResultCallback } from '@babel/core'
const localePath = resolve(__dirname, '../packages/locale/lang')
const fileList = fs.readdirSync(localePath)
const transform = function (filename, name, cb) {
require('@babel/core').transformFile(
const transform = function (
filename: string,
name: string,
cb: FileResultCallback
) {
babel.transformFile(
resolve(localePath, filename),
{
plugins: ['@babel/plugin-transform-modules-umd'],
@ -29,7 +36,7 @@ fileList
if (err) {
console.error(err)
} else {
const code = result.code
const code = result!.code!
const transformedCode = code
.replace('define("', 'define("element/locale/')
.replace(

View File

@ -7,24 +7,15 @@ import css from 'rollup-plugin-css-only'
import filesize from 'rollup-plugin-filesize'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import esbuild from 'rollup-plugin-esbuild'
import chalk from 'chalk'
import { sync as globSync } from 'fast-glob'
import { compRoot, buildOutput } from './paths'
import getDeps from './get-deps'
import { errorAndExit, getExternals, yellow, green } from './utils'
import genDefs from './gen-dts'
import reporter from './size-reporter'
import { EP_PREFIX } from './constants'
const outputDir = path.resolve(buildOutput, './element-plus')
const pathToPkgJson = path.resolve(compRoot, './package.json')
async function getComponents() {
const raw = await fs.promises.readdir(compRoot)
// filter out package.json since under packages/components we only got this file
//
return raw
.filter((f) => f !== 'package.json' && f !== 'index.ts')
.map((f) => ({ path: path.resolve(compRoot, f), name: f }))
}
const plugins = [
css(),
@ -35,20 +26,6 @@ const plugins = [
nodeResolve(),
esbuild(),
]
const EP_PREFIX = '@element-plus'
const VUE_REGEX = 'vue'
const VUE_MONO = '@vue'
const externals = getDeps(pathToPkgJson)
const excludes = ['icons']
const pathsRewriter = (id) => {
if (id.startsWith(`${EP_PREFIX}/components`))
return id.replace(`${EP_PREFIX}/components`, '..')
if (id.startsWith(EP_PREFIX) && excludes.every((e) => !id.endsWith(e)))
return id.replace(EP_PREFIX, '../..')
return id
}
;(async () => {
// run type diagnoses first
@ -63,15 +40,26 @@ const pathsRewriter = (id) => {
yellow('Start building entry file')
await buildEntry()
green('Entry built successfully')
})()
.then(() => {
console.log('Individual component build finished')
process.exit(0)
})
.catch((e) => {
console.error(e.message)
process.exit(1)
})
green('Individual component build finished')
})().catch((e: Error) => errorAndExit(e))
async function getComponents() {
const files = globSync('*', { cwd: compRoot, onlyDirectories: true })
return files.map((file) => ({
path: path.resolve(compRoot, file),
name: file,
}))
}
function pathsRewriter(id: string) {
const excludes = ['icons']
if (id.startsWith(`${EP_PREFIX}/components`))
return id.replace(`${EP_PREFIX}/components`, '..')
if (id.startsWith(EP_PREFIX) && excludes.every((e) => !id.endsWith(e)))
return id.replace(EP_PREFIX, '../..')
return id
}
async function buildComponents() {
const componentPaths = await getComponents()
@ -81,15 +69,15 @@ async function buildComponents() {
const entry = path.resolve(p, './index.ts')
if (!fs.existsSync(entry)) return
const external = (id) => {
return (
id.startsWith(VUE_REGEX) ||
id.startsWith(VUE_MONO) ||
id.startsWith(EP_PREFIX) ||
externals.some((i) => id.startsWith(i))
)
const rollupConfig = {
input: entry,
plugins,
external: getExternals({ full: false }),
}
const esm = {
const bundle = await rollup.rollup(rollupConfig)
// ESM
await bundle.write({
format: 'es',
file: `${outputDir}/es/components/${componentName}/index.js`,
plugins: [
@ -98,9 +86,10 @@ async function buildComponents() {
}),
],
paths: pathsRewriter,
}
})
const cjs = {
// CJS
await bundle.write({
format: 'cjs',
file: `${outputDir}/lib/components/${componentName}/index.js`,
exports: 'named',
@ -110,21 +99,13 @@ async function buildComponents() {
}),
],
paths: pathsRewriter,
}
const rollupConfig = {
input: entry,
plugins,
external,
}
const bundle = await rollup.rollup(rollupConfig)
await bundle.write(esm as any)
await bundle.write(cjs as any)
})
}
)
try {
await Promise.all(builds)
} catch (e) {
logAndShutdown(e)
} catch (e: any) {
errorAndExit(e)
}
}
@ -133,7 +114,7 @@ async function buildEntry() {
const config = {
input: entry,
plugins,
external: (_) => true,
external: () => true,
}
try {
@ -157,24 +138,7 @@ async function buildEntry() {
}),
],
})
} catch (e) {
logAndShutdown(e)
} catch (e: any) {
errorAndExit(e)
}
}
function yellow(str) {
console.log(chalk.cyan(str))
}
function green(str) {
console.log(chalk.green(str))
}
function red(str) {
console.error(chalk.red(str))
}
function logAndShutdown(e) {
red(e.message)
process.exit(1)
}

View File

@ -11,6 +11,7 @@ import genDts from './gen-entry-dts'
import RollupResolveEntryPlugin from './rollup.plugin.entry'
import { epRoot, buildOutput } from './paths'
import { EP_PREFIX, excludes } from './constants'
import { getExternals } from './utils'
;(async () => {
const config = {
input: path.resolve(epRoot, './index.ts'),
@ -29,9 +30,7 @@ import { EP_PREFIX, excludes } from './constants'
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
external(id) {
return /^vue/.test(id)
},
external: getExternals({ full: true }),
}
console.log(chalk.cyan('Start generating full bundle'))

View File

@ -1,29 +1,17 @@
import path from 'path'
import fs from 'fs'
import { Project } from 'ts-morph'
import { Project, SourceFile } from 'ts-morph'
import vueCompiler from '@vue/compiler-sfc'
import klawSync from 'klaw-sync'
import { sync as globSync } from 'fast-glob'
import chalk from 'chalk'
const TSCONFIG_PATH = path.resolve(__dirname, '../tsconfig.json')
const DEMO_RE = /\/demo\/\w+\.vue$/
const TEST_RE = /__test__|__tests__/
const excludedFiles = [
'mock',
'package.json',
'spec',
'test',
'tests',
'css',
'.DS_Store',
]
const exclude = (path: string) => !excludedFiles.some((f) => path.includes(f))
/**
* fork = require( https://github.com/egoist/vue-dts-gen/blob/main/src/index.ts
*/
const genVueTypes = async (
root,
root: string,
outDir = path.resolve(__dirname, '../dist/types')
) => {
const project = new Project({
@ -38,20 +26,35 @@ const genVueTypes = async (
'@element-plus/*': ['packages/*'],
},
skipLibCheck: true,
strict: false,
},
tsConfigFilePath: TSCONFIG_PATH,
skipAddingFilesFromTsConfig: true,
})
const sourceFiles = []
const sourceFiles: SourceFile[] = []
const filePaths = klawSync(root, {
nodir: true,
})
.map((item) => item.path)
.filter((path) => !DEMO_RE.test(path))
.filter((path) => !TEST_RE.test(path))
.filter(exclude)
const excludedFiles = [
/\/demo\/\w+\.vue$/,
/__test__|__tests__/,
'mock',
'package.json',
'spec',
'test',
'tests',
'css',
'.DS_Store',
]
const filePaths = globSync('**/*', {
cwd: root,
onlyFiles: true,
absolute: true,
}).filter(
(path) =>
!excludedFiles.some((f) =>
f instanceof RegExp ? f.test(path) : path.includes(f)
)
)
await Promise.all(
filePaths.map(async (file) => {
@ -95,10 +98,10 @@ const genVueTypes = async (
})
for (const sourceFile of sourceFiles) {
const relativePath = path.relative(root, sourceFile.getFilePath())
console.log(
chalk.yellow(
'Generating definition for file: ' +
chalk.bold(sourceFile.getBaseName())
`Generating definition for file: ${chalk.bold(relativePath)}`
)
)

View File

@ -2,7 +2,7 @@ import path from 'path'
import fs from 'fs'
import chalk from 'chalk'
import glob from 'fast-glob'
import { Project } from 'ts-morph'
import { Project, SourceFile } from 'ts-morph'
import { epRoot, buildOutput } from './paths'
const TSCONFIG_PATH = path.resolve(__dirname, '../tsconfig.dts.json')
@ -25,7 +25,7 @@ const gen = async () => {
tsConfigFilePath: TSCONFIG_PATH,
skipAddingFilesFromTsConfig: true,
})
const sourceFiles = []
const sourceFiles: SourceFile[] = []
files.map((f) => {
const sourceFile = project.addSourceFileAtPath(f)
sourceFiles.push(sourceFile)

View File

@ -1,12 +0,0 @@
/* eslint-disable */
/**
*
* @param {PathLike} path path to dependencies
* @returns {Array<string>}
*/
export default (path) => {
const pkgJson = require(path)
const { dependencies } = pkgJson
return Object.keys(dependencies)
}

View File

@ -1,4 +0,0 @@
/* eslint-disable */
import os from 'os'
export default os.cpus().length

View File

@ -1,4 +0,0 @@
/* eslint-disable */
import { getPackagesSync } from '@lerna/project'
export default getPackagesSync()

View File

@ -1,25 +1,12 @@
import path from 'path'
const projRoot = path.resolve(__dirname, '../')
const pkgRoot = path.resolve(projRoot, './packages')
const compRoot = path.resolve(pkgRoot, './components')
const themeRoot = path.resolve(pkgRoot, './theme-chalk')
const hookRoot = path.resolve(pkgRoot, './hooks')
const localeRoot = path.resolve(pkgRoot, './locale')
const directiveRoot = path.resolve(pkgRoot, './directives')
const epRoot = path.resolve(pkgRoot, './element-plus')
const utilRoot = path.resolve(pkgRoot, './utils')
const buildOutput = path.resolve(projRoot, './dist')
export {
projRoot,
pkgRoot,
compRoot,
themeRoot,
hookRoot,
directiveRoot,
localeRoot,
epRoot,
utilRoot,
buildOutput,
}
export const projRoot = path.resolve(__dirname, '../')
export const pkgRoot = path.resolve(projRoot, './packages')
export const compRoot = path.resolve(pkgRoot, './components')
export const themeRoot = path.resolve(pkgRoot, './theme-chalk')
export const hookRoot = path.resolve(pkgRoot, './hooks')
export const localeRoot = path.resolve(pkgRoot, './locale')
export const directiveRoot = path.resolve(pkgRoot, './directives')
export const epRoot = path.resolve(pkgRoot, './element-plus')
export const utilRoot = path.resolve(pkgRoot, './utils')
export const buildOutput = path.resolve(projRoot, './dist')

View File

@ -20,7 +20,7 @@ const inputs = getPackagesSync()
.map((pkg) => pkg.name)
.filter((name) => name.includes('@element-plus') && !name.includes('utils'))
export default inputs.map((name) => ({
export default inputs.map((name: string) => ({
input: path.resolve(
__dirname,
`../packages/${name.split('@element-plus/')[1]}/index.ts`
@ -29,7 +29,7 @@ export default inputs.map((name) => ({
{
format: 'es',
file: getOutFile(name, 'es'),
paths(id) {
paths(id: string) {
if (/^@element-plus/.test(id)) {
if (noElPrefixFile.test(id)) return id.replace('@element-plus', '..')
return id.replace('@element-plus/', '../el-')
@ -40,7 +40,7 @@ export default inputs.map((name) => ({
format: 'cjs',
file: getOutFile(name, 'lib'),
exports: 'named',
paths(id) {
paths(id: string) {
if (/^@element-plus/.test(id)) {
if (noElPrefixFile.test(id)) return id.replace('@element-plus', '..')
return id.replace('@element-plus/', '../el-')
@ -57,7 +57,7 @@ export default inputs.map((name) => ({
nodeResolve(),
esbuild(),
],
external(id) {
external(id: string) {
return (
/^vue/.test(id) ||
/^@element-plus/.test(id) ||

View File

@ -1,68 +1,17 @@
import chalk from 'chalk'
import { FileSizeReporter } from 'rollup-plugin-filesize'
export default async function reporter(opt, outputOptions, info) {
const reporter: FileSizeReporter = (opt, outputOptions, info) => {
const values = [
// ...(outputOptions.file || outputOptions.dest
// ? [
// `${title('Destination: ')}${value(
// outputOptions.file || outputOptions.dest,
// )}`,
// ]
// :
info.fileName ? [`${outputOptions.file.split('packages/').pop()}`] : [],
// )
// ...(info.bundleSizeBefore
// ? [
// `${value(info.bundleSize)} (was ${value(
// info.bundleSizeBefore,
// )}${info.lastVersion
// ? ` in version ${info.lastVersion}`
// : ' in last build'
// })`,
// ]
// :
info.fileName ? [`${outputOptions.file?.split('packages/').pop()}`] : [],
[`${info.bundleSize}`],
// ),
...(info.minSize
? // info.minSizeBefore
// ? [
// `${title('Minified Size: ')} ${value(info.minSize)} (was ${value(
// info.minSizeBefore,
// )}${info.lastVersion
// ? ` in version ${info.lastVersion}`
// : ' in last build'
// })`,
// ]
// :
[`${info.minSize}`]
: []),
// ...(info.gzipSize
// ? info.gzipSizeBefore
// ? [
// `${title('Gzipped Size: ')} ${value(info.gzipSize)} (was ${value(
// info.gzipSizeBefore,
// )}${info.lastVersion
// ? ` in version ${info.lastVersion}`
// : ' in last build'
// })`,
// ]
// : [`${title('Gzipped Size: ')} ${value(info.gzipSize)}`]
// : []),
// ...(info.brotliSize
// ? info.brotliSizeBefore
// ? [
// `${title('Brotli size: ')}${value(info.brotliSize)} (was ${value(
// info.brotliSizeBefore,
// )}${info.lastVersion
// ? ` in version ${info.lastVersion}`
// : ' in last build'
// })`,
// ]
// : [`${title('Brotli size: ')}${value(info.brotliSize)}`]
// : []),
...(info.minSize ? [`${info.minSize}`] : []),
]
return `${chalk.cyan(chalk.bold(values[0]))}: bundle size ${chalk.yellow(
values[1]
)} -> minified ${chalk.green(values[2])}`
}
export default reporter

49
build/utils.ts Normal file
View File

@ -0,0 +1,49 @@
import path from 'path'
import os from 'os'
import { getPackagesSync } from '@lerna/project'
import chalk from 'chalk'
import { compRoot } from './paths'
export const getDeps = (pkgPath: string): string[] => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkgJson = require(pkgPath)
const { dependencies } = pkgJson
return Object.keys(dependencies)
}
export const getCpuCount = () => os.cpus().length
export const getPkgs = (): { name: string }[] => getPackagesSync()
export const getExternals = (options: { full: boolean }) => (id: string) => {
const packages: string[] = ['vue', '@vue']
if (!options.full) {
const compPkg = path.resolve(compRoot, './package.json')
const monoPackages = getPkgs().map((pkg) => pkg.name)
const depPackages = getDeps(compPkg)
packages.push(...monoPackages, ...depPackages)
}
return [...new Set(packages)].some(
(pkg) => id === pkg || id.startsWith(`${pkg}\/`)
)
}
export function yellow(str: string) {
console.log(chalk.cyan(str))
}
export function green(str: string) {
console.log(chalk.green(str))
}
export function red(str: string) {
console.error(chalk.red(str))
}
export function errorAndExit(e: Error) {
red(e.message)
process.exit(1)
}

View File

@ -1,72 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const libMode = process.env.LIBMODE
const isFullMode = libMode === 'full'
const externals = [
{
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
},
},
]
const plugins = [
new VueLoaderPlugin(),
// new BundleAnalyzerPlugin(),
]
const entry = path.resolve(__dirname, '../packages/element-plus/index.ts')
if (!isFullMode) {
externals.push(
{
'@popperjs/core': '@popperjs/core',
'async-validator': 'async-validator',
mitt: 'mitt',
'normalize-wheel': 'normalize-wheel',
'resize-observer-polyfill': 'resize-observer-polyfill',
'@vueuse/core': '@vueuse/core',
},
/^dayjs.*/,
/^lodash.*/
)
}
const config = {
mode: 'production',
entry,
output: {
path: path.resolve(__dirname, '../dist/element-plus/dist'),
publicPath: '/',
filename: isFullMode ? 'index.full.js' : 'index.js',
libraryTarget: 'umd',
library: 'ElementPlus',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this",
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader',
},
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
},
externals,
plugins,
}
module.exports = config

View File

@ -1,130 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs')
const path = require('path')
const { parentPort, workerData } = require('worker_threads')
const { Project } = require('ts-morph')
const chalk = require('chalk')
const vueCompiler = require('@vue/compiler-sfc')
const TSCONFIG_PATH = path.resolve(process.cwd(), 'tsconfig.dts.json')
;(async () => {
const { filePaths, workerId, outDir } = workerData
let messagePort
parentPort.once('message', async ({ port }) => {
messagePort = port
messagePort.postMessage({
type: 'log',
message: chalk.yellow(
`Worker: ${chalk.bold(workerData.workerId)} started`
),
})
const project = new Project({
compilerOptions: {
outDir,
},
tsConfigFilePath: TSCONFIG_PATH,
skipAddingFilesFromTsConfig: true,
})
const sourceFiles = []
await Promise.all(
filePaths.map(async (file) => {
if (file.endsWith('.vue')) {
const content = await fs.promises.readFile(file, 'utf-8')
const sfc = vueCompiler.parse(content)
const { script, scriptSetup } = sfc.descriptor
if (script || scriptSetup) {
let content = ''
let isTS = false
if (script && script.content) {
content += script.content
if (script.lang === 'ts') isTS = true
}
if (scriptSetup) {
const compiled = vueCompiler.compileScript(sfc.descriptor, {
id: 'xxx',
})
content += compiled.content
if (scriptSetup.lang === 'ts') isTS = true
}
const sourceFile = project.createSourceFile(
path.relative(process.cwd(), file) + (isTS ? '.ts' : '.js'),
content
)
sourceFiles.push(sourceFile)
}
} else if (file.endsWith('.ts')) {
const sourceFile = project.addSourceFileAtPath(file)
sourceFiles.push(sourceFile)
}
})
)
const diagnostics = project.getPreEmitDiagnostics()
await project.emit({
emitOnlyDtsFiles: true,
})
messagePort.postMessage({
type: 'log',
message: project.formatDiagnosticsWithColorAndContext(diagnostics),
})
for (const sourceFile of sourceFiles) {
messagePort.postMessage({
type: 'log',
message: chalk.yellow(
'Generating definition for file: ' +
chalk.bold(sourceFile.getFilePath())
),
})
// console.log(sourceFile.getStructure())
const ElementPlusSign = '@element-plus/'
sourceFile
.getImportDeclarations((dec) =>
dec.getModuleSpecifierValue().startsWith(ElementPlusSign)
)
.map(modifySpecifier)
function modifySpecifier(d) {
const replaceTo =
'element-plus/es/' +
d.getModuleSpecifierValue().slice(ElementPlusSign.length)
d.setModuleSpecifier(replaceTo)
}
// console.log(sourceFile.getFilePath())
const emitOutput = sourceFile.getEmitOutput({
emitOnlyDtsFiles: true,
})
for (const outputFile of emitOutput.getOutputFiles()) {
// console.log(outputFile)
const filepath = outputFile.getFilePath()
await fs.promises.mkdir(path.dirname(filepath), {
recursive: true,
})
await fs.promises.writeFile(filepath, outputFile.getText(), 'utf8')
messagePort.postMessage({
type: 'log',
message: chalk.green(
'Definition for file: ' +
chalk.bold(sourceFile.getBaseName()) +
' generated'
),
})
}
messagePort.postMessage({ type: 'fulfill', message: workerId })
}
})
// parentPort.emit
})()

View File

@ -11,12 +11,13 @@
"update:version": "esno build/update-version.ts",
"bootstrap": "yarn --frozen-lockfile && npx lerna bootstrap && yarn gen:version",
"clean:lib": "rimraf lib && rimraf es && rimraf dist",
"build": "sh scripts/build.sh",
"build:locale-umd": "esno ./build/build-locale.ts",
"build:helper": "esno build/build-helper.ts",
"build:indices": "esno build/build-indices.ts",
"build:comps": "rimraf dist/components && esno build/components.ts",
"build:style": "gulp --cwd ./build",
"build:prod": "sh scripts/monorepo.sh",
"build:prod": "sh scripts/publish.sh",
"build:directives": "cd packages/directives && yarn clean && yarn build",
"build:hooks": "cd packages/hooks && yarn clean && yarn build",
"build:locale": "cd packages/locale && yarn clean && yarn build",
@ -77,8 +78,8 @@
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/jest": "^26.0.10",
"@types/klaw-sync": "^6.0.1",
"@types/lodash": "^4.14.161",
"@types/through2": "^2.0.36",
"@types/webpack-dev-server": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
@ -114,7 +115,6 @@
"husky": "^7.0.2",
"import-from": "^3.0.0",
"jest": "^26.6.3",
"klaw-sync": "^6.0.0",
"lerna": "^3.22.1",
"lint-staged": "^11.1.2",
"markdown-it": "^11.0.0",

11
scripts/monorepo.sh → scripts/build.sh Normal file → Executable file
View File

@ -1,18 +1,19 @@
#! /usr/bin/bash
#!/bin/sh
set -e
yarn bootstrap
yarn clean:lib
yarn update:version
yarn gen:version
# build all packages in case of error
# build components
yarn build:comps
rsync -a dist/types/components/ dist/element-plus/es/components/
rsync -a dist/types/components/ dist/element-plus/lib/components/
# build style
yarn build:style
yarn build:theme
@ -43,9 +44,3 @@ cp packages/element-plus/package.json dist/element-plus/package.json
echo "copying README"
cp README.md dist/element-plus
cd dist/element-plus
npm publish --access public
cd -
echo "Publish completed"

13
scripts/publish.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e
yarn update:version
sh scripts/build.sh
cd dist/element-plus
npm publish --access public
cd -
echo "Publish completed"

View File

@ -3069,13 +3069,6 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
"@types/klaw-sync@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@types/klaw-sync/-/klaw-sync-6.0.1.tgz#377f629b0fee644575b5b079121020ffa5f35d35"
integrity sha512-hqWJe0mMSxC5fiQjCJzziko2Xxh2HjDAPZNk7Zwv+Uo56XlViXR6p1RzjUCQvFvLd+IXEGeyVHTaAibrbyU1Rw==
dependencies:
"@types/node" "*"
"@types/lodash@^4.14.161":
version "4.14.172"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.172.tgz#aad774c28e7bfd7a67de25408e03ee5a8c3d028a"
@ -3192,6 +3185,13 @@
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.8.tgz#b94a4391c85666c7b73299fd3ad79d4faa435310"
integrity sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ==
"@types/through2@^2.0.36":
version "2.0.36"
resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.36.tgz#35fda0db635827d44c0e08e2c94653e647574a00"
integrity sha512-vuifQksQHJXhV9McpVsXKuhnf3lsoX70PnhcqIAbs9dqLH2NgrGz0DzZPDY3+Yh6eaRqcE1gnCQ6QhBn1/PT5A==
dependencies:
"@types/node" "*"
"@types/uglify-js@*":
version "3.9.3"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.9.3.tgz#d94ed608e295bc5424c9600e6b8565407b6b4b6b"
@ -10454,13 +10454,6 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
klaw-sync@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
dependencies:
graceful-fs "^4.1.11"
kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"