mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
build(build): buid/add-locale-theme-in-es-build (#1132)
- Now lib provides cjs format exports and es provides esm format
This commit is contained in:
parent
691ecf5354
commit
70c31d0bec
10
.github/workflows/publish-npm.yml
vendored
10
.github/workflows/publish-npm.yml
vendored
@ -43,13 +43,3 @@ jobs:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
|
||||
TAG_VERSION: ${{env.TAG_VERSION}}
|
||||
REGISTRY: https://registry.npmjs.com/
|
||||
PKG_NAME: element-plus
|
||||
- name: Generate grp token
|
||||
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ./.npmrc
|
||||
- name: Publish grp
|
||||
run: sh ./scripts/publish.sh
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
TAG_VERSION: ${{env.TAG_VERSION}}
|
||||
REGISTRY: https://npm.pkg.github.com/
|
||||
PKG_NAME: "@element-plus/element-plus"
|
||||
|
54
build/build-util.js
Normal file
54
build/build-util.js
Normal file
@ -0,0 +1,54 @@
|
||||
/* eslint-disable */
|
||||
const pkg = require('../package.json')
|
||||
const path = require('path')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const rollup = require('rollup')
|
||||
const typescript = require('rollup-plugin-typescript2')
|
||||
|
||||
const deps = Object.keys(pkg.dependencies)
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const file = process.argv[2];
|
||||
const defaultOpts = {
|
||||
input: path.resolve(root, file),
|
||||
plugins: [
|
||||
nodeResolve(),
|
||||
typescript({
|
||||
tsconfigOverride: {
|
||||
compilerOptions: {
|
||||
declaration: false,
|
||||
},
|
||||
'exclude': [
|
||||
'node_modules',
|
||||
'__tests__',
|
||||
],
|
||||
},
|
||||
abortOnError: false,
|
||||
}),
|
||||
],
|
||||
external(id) {
|
||||
return /^vue/.test(id)
|
||||
|| /^@vue/.test(id)
|
||||
|| deps.some(k => new RegExp('^' + k).test(id))
|
||||
},
|
||||
}
|
||||
|
||||
const run = async (name) => {
|
||||
const esm = {
|
||||
format: 'es',
|
||||
file: `es/${name}`,
|
||||
};
|
||||
const cjs = {
|
||||
format: 'cjs',
|
||||
file: `lib/${name}`,
|
||||
exports: 'named',
|
||||
}
|
||||
|
||||
const bundle = await rollup.rollup(defaultOpts);
|
||||
await Promise.all([bundle.write(esm), bundle.write(cjs)]);
|
||||
console.log(name, 'build finished');
|
||||
}
|
||||
|
||||
let normalizedName = file.slice(11); // remove ./packages
|
||||
|
||||
run(`${normalizedName.split('.').shift()}.js`);
|
@ -1,9 +1,9 @@
|
||||
import { Ref } from 'vue'
|
||||
import isServer from './isServer'
|
||||
import { getConfig } from './config'
|
||||
import { addClass, removeClass, on } from './dom'
|
||||
import { EVENT_CODE } from './aria'
|
||||
|
||||
import type { Ref } from 'vue'
|
||||
interface Instance {
|
||||
closeOnClickModal: Ref<boolean>
|
||||
closeOnPressEscape: Ref<boolean>
|
||||
|
@ -20,11 +20,14 @@ yarn build:lib-full
|
||||
# node .build/build.js command
|
||||
find './packages' -type d -maxdepth 1 ! -name '*util*' ! -name '__mocks__' ! -name 'locale' ! -name 'theme*' -print0 | xargs -I {} -P6 -0 node ./build/build.comps.js {}
|
||||
|
||||
|
||||
find ./packages/utils -type f ! -name '*.test.ts' ! -name 'package.json' -print0 \
|
||||
| xargs -P6 -0 -I {} node ./build/build-util.js {}
|
||||
|
||||
node ./build/build.entry.js
|
||||
|
||||
yarn build:utils
|
||||
|
||||
yarn build:locale
|
||||
find ./packages/locale -type f ! -name '*.spec.ts' ! -name 'package.json' -print0 \
|
||||
| xargs -P6 -0 -I {} node ./build/build-util.js {}
|
||||
|
||||
yarn build:locale-umd
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
cat package.json \
|
||||
| grep -v '"private":' \
|
||||
| grep -v '"version":' \
|
||||
| sed "s/\(\"name\": \"element-plus\"\)/\"name\": \"${PKG_NAME}\",\n \"version\": \"${TAG_VERSION}\"/g" > package.json.bak
|
||||
| sed "s/\(\"name\": \"element-plus\"\)/\1,\n \"version\": \"${TAG_VERSION}\"/g" > package.json.bak
|
||||
|
||||
cat package.json.bak > package.json
|
||||
npm publish --registry ${REGISTRY}
|
||||
|
Loading…
Reference in New Issue
Block a user