Skip to content

Commit

Permalink
Merge branch 'main' into Amber-372-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Amber-372 committed Sep 13, 2023
2 parents fda0bf8 + d51b953 commit 14aa6d1
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set node
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: lts/*

- run: corepack enable

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ on:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: lts/*

- run: npx changelogithub
env:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Anthony Fu<https://github.com/antfu>
Copyright (c) 2020-PRESENT Anthony Fu<https://github.com/antfu>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,4 @@ Thanks to [@brattonross](https://github.com/brattonross), this project is heavil

## License

MIT License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)
[MIT](./LICENSE) License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)
3 changes: 2 additions & 1 deletion examples/vite-vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"private": true,
"scripts": {
"dev": "cross-env DEBUG=unplugin-vue-components:* vite",
"build": "cross-env DEBUG=unplugin-vue-components:* vite build"
"build": "cross-env DEBUG=unplugin-vue-components:* vite build",
"preview": "cross-env DEBUG=unplugin-vue-components:* vite preview"
},
"dependencies": {
"vant": "^4.6.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-vue3/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const config: UserConfig = {
directoryAsNamespace: true,
dts: true,
globalNamespaces: ['global'],
include: [/\.vue$/, /\.md$/],
include: [/\.vue($|\?)/, /\.md($|\?)/],
resolvers: [
(name) => {
if (name === 'MyCustom')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unplugin-vue-components",
"version": "0.25.1",
"version": "0.25.2",
"packageManager": "pnpm@8.6.8",
"description": "Components auto importing for Vue",
"author": "antfu <anthonyfu117@hotmail.com>",
Expand Down
4 changes: 2 additions & 2 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { UpdatePayload, ViteDevServer } from 'vite'
import { slash, throttle, toArray } from '@antfu/utils'
import type { ComponentInfo, Options, ResolvedOptions, Transformer } from '../types'
import { DIRECTIVE_IMPORT_PREFIX } from './constants'
import { getNameFromFilePath, matchGlobs, normalizeComponetInfo, parseId, pascalCase, resolveAlias } from './utils'
import { getNameFromFilePath, matchGlobs, normalizeComponentInfo, parseId, pascalCase, resolveAlias } from './utils'
import { resolveOptions } from './options'
import { searchComponents } from './fs/glob'
import { writeDeclaration } from './declaration'
Expand Down Expand Up @@ -239,7 +239,7 @@ export class Context {
else {
info = {
as: name,
...normalizeComponetInfo(result),
...normalizeComponentInfo(result),
}
}
if (type === 'component')
Expand Down
24 changes: 15 additions & 9 deletions src/core/resolvers/element-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export interface ElementPlusResolverOptions {
* a list of component names that have no styles, so resolving their styles file should be prevented
*/
noStylesComponents?: string[]

/**
* nightly version
*/
nightly?: boolean
}

type ElementPlusResolverOptionsResolved = Required<Omit<ElementPlusResolverOptions, 'exclude'>> &
Expand Down Expand Up @@ -73,9 +78,9 @@ function getSideEffectsLegacy(
}

function getSideEffects(dirName: string, options: ElementPlusResolverOptionsResolved): SideEffectsInfo | undefined {
const { importStyle, ssr } = options
const themeFolder = 'element-plus/theme-chalk'
const esComponentsFolder = 'element-plus/es/components'
const { importStyle, ssr, nightly } = options
const themeFolder = nightly ? '@element-plus/nightly/theme-chalk' : 'element-plus/theme-chalk'
const esComponentsFolder = nightly ? '@element-plus/nightly/es/components' : 'element-plus/es/components'

if (importStyle === 'sass') {
return ssr
Expand Down Expand Up @@ -104,13 +109,13 @@ function resolveComponent(name: string, options: ElementPlusResolverOptionsResol
}

const partialName = kebabCase(name.slice(2))// ElTableColumn -> table-column
const { version, ssr } = options
const { version, ssr, nightly } = options

// >=1.1.0-beta.1
if (compare(version, '1.1.0-beta.1', '>=')) {
if (compare(version, '1.1.0-beta.1', '>=') || nightly) {
return {
name,
from: `element-plus/${ssr ? 'lib' : 'es'}`,
from: `${nightly ? '@element-plus/nightly' : 'element-plus'}/${ssr ? 'lib' : 'es'}`,
sideEffects: getSideEffects(partialName, options),
}
}
Expand Down Expand Up @@ -144,13 +149,13 @@ function resolveDirective(name: string, options: ElementPlusResolverOptionsResol
if (!directive)
return

const { version, ssr } = options
const { version, ssr, nightly } = options

// >=1.1.0-beta.1
if (compare(version, '1.1.0-beta.1', '>=')) {
if (compare(version, '1.1.0-beta.1', '>=') || nightly) {
return {
name: directive.importName,
from: `element-plus/${ssr ? 'lib' : 'es'}`,
from: `${nightly ? '@element-plus/nightly' : 'element-plus'}/${ssr ? 'lib' : 'es'}`,
sideEffects: getSideEffects(directive.styleName, options),
}
}
Expand Down Expand Up @@ -183,6 +188,7 @@ export function ElementPlusResolver(
directives: true,
exclude: undefined,
noStylesComponents: options.noStylesComponents || [],
nightly: false,
...options,
}
return optionsResolved
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function stringifyImport(info: ImportInfo | string) {
return `import ${info.as} from '${info.from}'`
}

export function normalizeComponetInfo(info: ImportInfo | ImportInfoLegacy | ComponentInfo): ComponentInfo {
export function normalizeComponentInfo(info: ImportInfo | ImportInfoLegacy | ComponentInfo): ComponentInfo {
if ('path' in info) {
return {
from: info.path,
Expand Down

0 comments on commit 14aa6d1

Please sign in to comment.