From e926d201793d2ef8ffb7552d2a0825030f2bea6b Mon Sep 17 00:00:00 2001 From: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com> Date: Wed, 25 Aug 2021 11:27:16 +0800 Subject: [PATCH] fix(build): exposing installer function and version for umd build (#3041) * fix(build): exposing installer function and version for umd build * fix codepen code snippet error --- build/full-bundle.ts | 6 ------ packages/element-plus/index.ts | 4 ++++ packages/hooks/use-locale/index.ts | 10 +++------- website/components/demo-block.vue | 4 ++-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/build/full-bundle.ts b/build/full-bundle.ts index c7afcbb2c0..0827970b90 100644 --- a/build/full-bundle.ts +++ b/build/full-bundle.ts @@ -61,12 +61,6 @@ import { EP_PREFIX, excludes } from './constants' plugins: [...config.plugins, RollupResolveEntryPlugin()], }) - console.log(chalk.yellow('Generating index.js')) - - await bundle.write(umd as any) - - console.log(chalk.green('index.js generated')) - console.log(chalk.yellow('Generating index.full.js')) await bundle.write(umdMinified as any) diff --git a/packages/element-plus/index.ts b/packages/element-plus/index.ts index dc0a4c0784..0887ab97c3 100644 --- a/packages/element-plus/index.ts +++ b/packages/element-plus/index.ts @@ -1,3 +1,4 @@ +import installer from './defaults' export * from '@element-plus/components' export * from '@element-plus/directives' export * from '@element-plus/hooks' @@ -5,3 +6,6 @@ export * from '@element-plus/tokens' export { default as makeInstaller } from './make-installer' export { default } from './defaults' + +export const install = installer.install +export const version = installer.version diff --git a/packages/hooks/use-locale/index.ts b/packages/hooks/use-locale/index.ts index 4aeed71184..eaa6f423f6 100644 --- a/packages/hooks/use-locale/index.ts +++ b/packages/hooks/use-locale/index.ts @@ -88,13 +88,9 @@ function template(str: string, option) { }) } -export const localeProviderMaker = ({ - locale, -}: { - locale?: Language -}) => { - const lang = ref((locale || English).name) - const localeRef = ref(locale || English) +export const localeProviderMaker = (locale = English) => { + const lang = ref(locale.name) + const localeRef = ref(locale) return { lang, locale: localeRef, diff --git a/website/components/demo-block.vue b/website/components/demo-block.vue index 5bb42540ca..caa8098514 100644 --- a/website/components/demo-block.vue +++ b/website/components/demo-block.vue @@ -262,9 +262,9 @@ ${this.codepen.style} // since 2.6.2 use code rather than jsfiddle https://blog.codepen.io/documentation/api/prefill/ const { script, html, style } = this.codepen const resourcesTpl = '' + - '\n' + '\n' let htmlTpl = `${resourcesTpl}\n
\n${html.trim()}\n
` - let cssTpl = `@import url("//unpkg.com/element-plus/lib/theme-chalk/index.css");\n${(style || '').trim()}\n` + let cssTpl = `@import url("//unpkg.com/element-plus/dist/index.css");\n${(style || '').trim()}\n` let jsTpl = script ? script.replace(/export default/, 'var Main =').trim().replace(/import ({.*}) from 'vue'/g, (s, s1) => `const ${s1} = Vue`).replace(/import ({.*}) from 'element-plus'/g, (s, s1) => `const ${s1} = ElementPlus`) : 'var Main = {}' jsTpl += '\n;const app = Vue.createApp(Main);\napp.use(ElementPlus);\napp.mount("#app")' const data = {