vite-plugin-components
Advanced tools
Comparing version 0.13.2 to 0.13.3
@@ -148,7 +148,13 @@ import { Plugin } from 'vite'; | ||
/** | ||
* import style along with components | ||
* import style css or sass with components | ||
* | ||
* @default true | ||
* @default 'css' | ||
*/ | ||
importStyle?: boolean; | ||
importStyle?: boolean | 'css' | 'sass'; | ||
/** | ||
* specify element-plus version to load style | ||
* | ||
* @default installed version | ||
*/ | ||
version?: string; | ||
} | ||
@@ -159,5 +165,7 @@ /** | ||
* See https://github.com/antfu/vite-plugin-components/pull/28 for more details | ||
* See https://github.com/antfu/vite-plugin-components/issues/117 for more details | ||
* | ||
* @author @develar | ||
* @link https://element-plus.org/#/en-US | ||
* @author @develar @nabaonan | ||
* @link https://element-plus.org/#/en-US for element-plus | ||
* | ||
*/ | ||
@@ -189,3 +197,16 @@ declare function ElementPlusResolver(options?: ElementPlusResolverOptions): ComponentResolver; | ||
interface IduxResolverOptions { | ||
/** | ||
* import style along with components | ||
*/ | ||
importStyle?: 'css' | 'less'; | ||
} | ||
/** | ||
* Resolver for `@idux/cdk` and `@idux/components` | ||
* | ||
* @link https://idux.site | ||
*/ | ||
declare function IduxResolver(options?: IduxResolverOptions): ComponentResolver; | ||
/** | ||
* Resolver for Naive UI | ||
@@ -296,3 +317,2 @@ * | ||
export default VitePluginComponents; | ||
export { AntDesignVueResolver, AntDesignVueResolverOptions, ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentsImportMap, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, ImportInfo, LibraryResolver, Matcher, NaiveUiResolver, Options, PrimeVueResolver, PrimeVueResolverOptions, ResolvedOptions, SideEffectsInfo, Transformer, UILibraryOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, ViewUiResolver, VueUseComponentsResolver, VuetifyResolver, camelCase, kebabCase, pascalCase, tryLoadVeturTags }; | ||
export { AntDesignVueResolver, AntDesignVueResolverOptions, ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentsImportMap, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, IduxResolver, IduxResolverOptions, ImportInfo, LibraryResolver, Matcher, NaiveUiResolver, Options, PrimeVueResolver, PrimeVueResolverOptions, ResolvedOptions, SideEffectsInfo, Transformer, UILibraryOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, ViewUiResolver, VueUseComponentsResolver, VuetifyResolver, camelCase, VitePluginComponents as default, kebabCase, pascalCase, tryLoadVeturTags }; |
@@ -340,2 +340,104 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __create = Object.create; | ||
// node_modules/.pnpm/compare-versions@3.6.0/node_modules/compare-versions/index.js | ||
var require_compare_versions = __commonJS({ | ||
"node_modules/.pnpm/compare-versions@3.6.0/node_modules/compare-versions/index.js"(exports, module) { | ||
(function(root, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define([], factory); | ||
} else if (typeof exports === "object") { | ||
module.exports = factory(); | ||
} else { | ||
root.compareVersions = factory(); | ||
} | ||
})(exports, function() { | ||
var semver = /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i; | ||
function indexOrEnd(str, q) { | ||
return str.indexOf(q) === -1 ? str.length : str.indexOf(q); | ||
} | ||
function split(v) { | ||
var c = v.replace(/^v/, "").replace(/\+.*$/, ""); | ||
var patchIndex = indexOrEnd(c, "-"); | ||
var arr = c.substring(0, patchIndex).split("."); | ||
arr.push(c.substring(patchIndex + 1)); | ||
return arr; | ||
} | ||
function tryParse(v) { | ||
return isNaN(Number(v)) ? v : Number(v); | ||
} | ||
function validate(version) { | ||
if (typeof version !== "string") { | ||
throw new TypeError("Invalid argument expected string"); | ||
} | ||
if (!semver.test(version)) { | ||
throw new Error("Invalid argument not valid semver ('" + version + "' received)"); | ||
} | ||
} | ||
function compareVersions(v1, v2) { | ||
[v1, v2].forEach(validate); | ||
var s1 = split(v1); | ||
var s2 = split(v2); | ||
for (var i = 0; i < Math.max(s1.length - 1, s2.length - 1); i++) { | ||
var n1 = parseInt(s1[i] || 0, 10); | ||
var n2 = parseInt(s2[i] || 0, 10); | ||
if (n1 > n2) | ||
return 1; | ||
if (n2 > n1) | ||
return -1; | ||
} | ||
var sp1 = s1[s1.length - 1]; | ||
var sp2 = s2[s2.length - 1]; | ||
if (sp1 && sp2) { | ||
var p1 = sp1.split(".").map(tryParse); | ||
var p2 = sp2.split(".").map(tryParse); | ||
for (i = 0; i < Math.max(p1.length, p2.length); i++) { | ||
if (p1[i] === void 0 || typeof p2[i] === "string" && typeof p1[i] === "number") | ||
return -1; | ||
if (p2[i] === void 0 || typeof p1[i] === "string" && typeof p2[i] === "number") | ||
return 1; | ||
if (p1[i] > p2[i]) | ||
return 1; | ||
if (p2[i] > p1[i]) | ||
return -1; | ||
} | ||
} else if (sp1 || sp2) { | ||
return sp1 ? -1 : 1; | ||
} | ||
return 0; | ||
} | ||
; | ||
var allowedOperators = [ | ||
">", | ||
">=", | ||
"=", | ||
"<", | ||
"<=" | ||
]; | ||
var operatorResMap = { | ||
">": [1], | ||
">=": [0, 1], | ||
"=": [0], | ||
"<=": [-1, 0], | ||
"<": [-1] | ||
}; | ||
function validateOperator(op) { | ||
if (typeof op !== "string") { | ||
throw new TypeError("Invalid operator type, expected string but got " + typeof op); | ||
} | ||
if (allowedOperators.indexOf(op) === -1) { | ||
throw new TypeError("Invalid operator, expected one of " + allowedOperators.join("|")); | ||
} | ||
} | ||
compareVersions.validate = function(version) { | ||
return typeof version === "string" && semver.test(version); | ||
}; | ||
compareVersions.compare = function(v1, v2, operator) { | ||
validateOperator(operator); | ||
var res = compareVersions(v1, v2); | ||
return operatorResMap[operator].indexOf(res) > -1; | ||
}; | ||
return compareVersions; | ||
}); | ||
} | ||
}); | ||
// src/context.ts | ||
@@ -531,2 +633,10 @@ var import_utils4 = __toModule(require_dist()); | ||
} | ||
function getPkgVersion(pkgName, defaultVersion) { | ||
try { | ||
return __require(`${pkgName}/package.json`).version; | ||
} catch (err) { | ||
console.error(err); | ||
return defaultVersion; | ||
} | ||
} | ||
@@ -1026,11 +1136,50 @@ // src/fs/glob.ts | ||
// src/resolvers/element-plus.ts | ||
var import_compare_versions = __toModule(require_compare_versions()); | ||
function getSideEffectsLegacy(partialName, options) { | ||
const { importStyle = "css" } = options; | ||
if (!importStyle) | ||
return; | ||
if (importStyle === "sass") { | ||
return [ | ||
"element-plus/packages/theme-chalk/src/base.scss", | ||
`element-plus/packages/theme-chalk/src/${partialName}.scss` | ||
]; | ||
} else if (importStyle === true || importStyle === "css") { | ||
return [ | ||
"element-plus/lib/theme-chalk/base.css", | ||
`element-plus/lib/theme-chalk/el-${partialName}.css` | ||
]; | ||
} | ||
} | ||
function getSideEffects2(dirName, options) { | ||
const { importStyle = "css" } = options; | ||
if (importStyle === "sass") | ||
return `element-plus/es/components/${dirName}/style`; | ||
else if (importStyle === true || importStyle === "css") | ||
return `element-plus/es/components/${dirName}/style/css`; | ||
} | ||
function ElementPlusResolver(options = {}) { | ||
return (name) => { | ||
const { importStyle = true } = options; | ||
if (name.startsWith("El")) { | ||
const partialName = name[2].toLowerCase() + name.substring(3).replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`); | ||
return { | ||
path: `element-plus/es/el-${partialName}`, | ||
sideEffects: importStyle ? `element-plus/packages/theme-chalk/src/${partialName}.scss` : void 0 | ||
}; | ||
if (name.match(/^El[A-Z]/)) { | ||
const { | ||
version = getPkgVersion("element-plus", "1.0.2") | ||
} = options; | ||
const partialName = kebabCase(name.slice(2)); | ||
if ((0, import_compare_versions.default)(version, "1.1.0-beta.1")) { | ||
return { | ||
importName: name, | ||
path: "element-plus/es", | ||
sideEffects: getSideEffects2(partialName, options) | ||
}; | ||
} else if ((0, import_compare_versions.default)(version, "1.0.2-beta.28")) { | ||
return { | ||
path: `element-plus/es/el-${partialName}`, | ||
sideEffects: getSideEffectsLegacy(partialName, options) | ||
}; | ||
} else { | ||
return { | ||
path: `element-plus/lib/el-${partialName}`, | ||
sideEffects: getSideEffectsLegacy(partialName, options) | ||
}; | ||
} | ||
} | ||
@@ -1041,3 +1190,3 @@ }; | ||
// src/resolvers/element-ui.ts | ||
function getSideEffects2(partialName, options) { | ||
function getSideEffects3(partialName, options) { | ||
const { importStyle = "css" } = options; | ||
@@ -1065,3 +1214,3 @@ if (!importStyle) | ||
path: `element-ui/lib/${partialName}`, | ||
sideEffects: getSideEffects2(partialName, options) | ||
sideEffects: getSideEffects3(partialName, options) | ||
}; | ||
@@ -1116,2 +1265,40 @@ } | ||
// src/resolvers/idux.ts | ||
function IduxResolver(options = {}) { | ||
return (name) => { | ||
if (name.match(/^Ix[A-Z]/)) { | ||
const { importStyle } = options; | ||
const compName = name.slice(2); | ||
const kebabCaseName = kebabCase(compName); | ||
const isCdk = cdkNames.includes(kebabCaseName); | ||
const packageName = isCdk ? "cdk" : "components"; | ||
const dirname3 = getDirname(kebabCaseName); | ||
const path = `@idux/${packageName}/${dirname3}`; | ||
const sideEffects = isCdk || !importStyle ? void 0 : `${path}/style/${importStyle === "css" ? "css" : "index"}`; | ||
return { importName: name, path, sideEffects }; | ||
} | ||
}; | ||
} | ||
var cdkNames = ["portal", "resizable", "virtual-list"]; | ||
var kebabCaseDirnames = [ | ||
"virtual-list", | ||
"auto-complete", | ||
"back-top", | ||
"date-picker", | ||
"input-number", | ||
"time-picker", | ||
"tree-select" | ||
]; | ||
function getDirname(compName) { | ||
const dirname3 = kebabCaseDirnames.find((name) => compName.startsWith(name)); | ||
if (dirname3) { | ||
return dirname3; | ||
} | ||
const [first] = compName.split("-"); | ||
if (first === "row" || first === "col") { | ||
return "grid"; | ||
} | ||
return first; | ||
} | ||
// src/resolvers/naive-ui.ts | ||
@@ -1274,3 +1461,3 @@ function NaiveUiResolver() { | ||
// src/resolvers/view-ui.ts | ||
function getSideEffects3(componentName) { | ||
function getSideEffects4(componentName) { | ||
const sideEffects = [ | ||
@@ -1312,3 +1499,3 @@ "view-design/dist/styles/iview.css", | ||
path: `view-design/src/components/${getCompDir(compName)}`, | ||
sideEffects: getSideEffects3(compName) | ||
sideEffects: getSideEffects4(compName) | ||
}; | ||
@@ -1391,2 +1578,3 @@ } | ||
exports.AntDesignVueResolver = AntDesignVueResolver; exports.ElementPlusResolver = ElementPlusResolver; exports.ElementUiResolver = ElementUiResolver; exports.HeadlessUiResolver = HeadlessUiResolver; exports.LibraryResolver = LibraryResolver; exports.NaiveUiResolver = NaiveUiResolver; exports.PrimeVueResolver = PrimeVueResolver; exports.VantResolver = VantResolver; exports.VarletUIResolver = VarletUIResolver; exports.ViewUiResolver = ViewUiResolver; exports.VueUseComponentsResolver = VueUseComponentsResolver; exports.VuetifyResolver = VuetifyResolver; exports.camelCase = camelCase; exports.default = src_default; exports.kebabCase = kebabCase; exports.pascalCase = pascalCase; exports.tryLoadVeturTags = tryLoadVeturTags; | ||
exports.AntDesignVueResolver = AntDesignVueResolver; exports.ElementPlusResolver = ElementPlusResolver; exports.ElementUiResolver = ElementUiResolver; exports.HeadlessUiResolver = HeadlessUiResolver; exports.IduxResolver = IduxResolver; exports.LibraryResolver = LibraryResolver; exports.NaiveUiResolver = NaiveUiResolver; exports.PrimeVueResolver = PrimeVueResolver; exports.VantResolver = VantResolver; exports.VarletUIResolver = VarletUIResolver; exports.ViewUiResolver = ViewUiResolver; exports.VueUseComponentsResolver = VueUseComponentsResolver; exports.VuetifyResolver = VuetifyResolver; exports.camelCase = camelCase; exports.default = src_default; exports.kebabCase = kebabCase; exports.pascalCase = pascalCase; exports.tryLoadVeturTags = tryLoadVeturTags; |
{ | ||
"name": "vite-plugin-components", | ||
"version": "0.13.2", | ||
"version": "0.13.3", | ||
"description": "Components auto importing for Vite", | ||
@@ -35,3 +35,3 @@ "homepage": "https://github.com/antfu/vite-plugin-components", | ||
"debug": "^4.3.2", | ||
"fast-glob": "^3.2.6", | ||
"fast-glob": "^3.2.7", | ||
"magic-string": "^0.25.7", | ||
@@ -41,18 +41,19 @@ "minimatch": "^3.0.4" | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^0.6.6", | ||
"@antfu/eslint-config": "^0.7.0", | ||
"@antfu/utils": "^0.2.4", | ||
"@types/debug": "^4.1.6", | ||
"@types/jest": "^26.0.23", | ||
"@types/minimatch": "^3.0.4", | ||
"@types/node": "^15.14.0", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
"eslint": "^7.29.0", | ||
"@types/debug": "^4.1.7", | ||
"@types/jest": "^27.0.1", | ||
"@types/minimatch": "^3.0.5", | ||
"@types/node": "^16.6.1", | ||
"@typescript-eslint/eslint-plugin": "^4.29.1", | ||
"compare-versions": "^3.6.0", | ||
"eslint": "^7.32.0", | ||
"jest": "^27.0.6", | ||
"rollup": "^2.52.6", | ||
"standard-version": "^9.3.0", | ||
"ts-jest": "^27.0.3", | ||
"tsup": "^4.12.0", | ||
"rollup": "^2.56.2", | ||
"standard-version": "^9.3.1", | ||
"ts-jest": "^27.0.4", | ||
"tsup": "^4.13.1", | ||
"typescript": "^4.3.5", | ||
"vite": "^2.3.8" | ||
"vite": "^2.4.4" | ||
} | ||
} |
@@ -135,2 +135,3 @@ <h2 align='center'><samp>vite-plugin-components</samp></h2> | ||
- [Headless UI](https://github.com/antfu/vite-plugin-components/blob/master/src/resolvers/headless-ui.ts) | ||
- [IDux](https://github.com/antfu/vite-plugin-components/blob/master/src/resolvers/idux.ts) | ||
- [Naive UI](https://github.com/antfu/vite-plugin-components/blob/master/src/resolvers/naive-ui.ts) | ||
@@ -137,0 +138,0 @@ - [Prime Vue](https://github.com/antfu/vite-plugin-components/blob/master/src/resolvers/prime-vue.ts) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110268
3361
229
16
Updatedfast-glob@^3.2.7