vite-plugin-lazy-import
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -104,3 +104,3 @@ (function (global, factory) { | ||
var item = imports[i]; | ||
if (item.n === resOpts.lib) { | ||
if (item.n === resOpts.libraryName) { | ||
return item; | ||
@@ -132,4 +132,4 @@ } | ||
var dirName = _xeUtils["default"].kebabCase(importName); | ||
jsPath = "import { ".concat(name, " } from \"").concat(resOpts.lib, "/").concat(libDir, "/").concat(dirName, "/index.js\""); | ||
stylePath = "import \"".concat(resOpts.lib, "/").concat(libDir, "/").concat(dirName, "/style.").concat(extName, "\""); | ||
jsPath = "import { ".concat(name, " } from \"").concat(resOpts.libraryName, "/").concat(libDir, "/").concat(dirName, "/index.js\""); | ||
stylePath = "import \"".concat(resOpts.libraryName, "/").concat(libDir, "/").concat(dirName, "/style.").concat(extName, "\""); | ||
if (resOpts.resolve) { | ||
@@ -139,3 +139,3 @@ var rest = resOpts.resolve({ | ||
name: importName, | ||
lib: resOpts.lib | ||
libraryName: resOpts.libraryName | ||
}); | ||
@@ -180,3 +180,3 @@ var fromRest = rest ? rest.from : null; | ||
var resOpts = Object.assign({}, resolver); | ||
if (!resOpts.lib) { | ||
if (!resOpts.libraryName) { | ||
return; | ||
@@ -188,3 +188,3 @@ } | ||
} | ||
var importRE = new RegExp("^import\\s+\\{(\\s+)?([a-zA-Z0-9,_\\s]+)\\}(\\s+)?from\\s+('|\")".concat(resOpts.lib, "('|\")")); | ||
var importRE = new RegExp("^import\\s+\\{(\\s+)?([a-zA-Z0-9,_\\s]+)\\}(\\s+)?from\\s+('|\")".concat(resOpts.libraryName, "('|\")")); | ||
var matchRest = restCode.slice(syntaxItem.ss, syntaxItem.se).replace(/\n/g, ' ').match(importRE); | ||
@@ -191,0 +191,0 @@ if (!matchRest) { |
@@ -26,8 +26,8 @@ (function (global, factory) { | ||
return { | ||
lib: opts.lib, | ||
esm: opts.esm, | ||
libraryName: opts.libraryName, | ||
importStyle: opts.importStyle, | ||
resolve: function resolve(_ref) { | ||
var dirName = _ref.dirName; | ||
var libPath = "".concat(opts.lib, "/").concat(opts.esm ? 'es' : 'lib'); | ||
var libPath = "".concat(opts.libraryName, "/").concat(opts.esm ? 'es' : 'lib'); | ||
if (opts.importStyle) { | ||
@@ -34,0 +34,0 @@ return { |
{ | ||
"name": "vite-plugin-lazy-import", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Used for vite Lazy import js and style", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -9,3 +9,3 @@ import { Plugin, FilterPattern } from 'vite'; | ||
export interface LazyImportResolver { | ||
lib: string; | ||
libraryName: string; | ||
esm?: boolean; | ||
@@ -16,3 +16,3 @@ importStyle?: boolean | 'css' | 'less' | 'scss'; | ||
name: string; | ||
lib: string; | ||
libraryName: string; | ||
}) => null | LazyImportResolverResult; | ||
@@ -19,0 +19,0 @@ } |
import { LazyImportResolver } from '../index'; | ||
export interface VxeResolverOptions { | ||
lib: 'vxe-pc-ui' | 'vxe-table'; | ||
libraryName: 'vxe-pc-ui' | 'vxe-table'; | ||
esm?: boolean; | ||
@@ -5,0 +5,0 @@ importStyle?: boolean; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
26729