Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-lazy-import

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-lazy-import - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

13

dist/index.js

@@ -121,3 +121,4 @@ (function (global, factory) {

var rest = resOpts.resolve({
name: importName
name: importName,
lib: resOpts.lib
});

@@ -127,9 +128,9 @@ var fromRest = rest ? rest.from : null;

if (_xeUtils["default"].isString(fromRest)) {
jsPath = fromRest;
jsPath = "import { ".concat(name, " } from \"").concat(fromRest, "\"");
} else {
if (fromRest.jsPath) {
jsPath = fromRest.jsPath;
jsPath = "import { ".concat(name, " } from \"").concat(fromRest.jsPath, "\"");
}
if (fromRest.stylePath) {
stylePath = fromRest.stylePath;
stylePath = "import \"".concat(fromRest.stylePath, "\"");
}

@@ -162,5 +163,3 @@ }

opts.resolvers.forEach(function (resolver) {
var resOpts = Object.assign({
esm: true
}, resolver);
var resOpts = Object.assign({}, resolver);
if (!resOpts.lib) {

@@ -167,0 +166,0 @@ return;

{
"name": "vite-plugin-lazy-import",
"version": "0.4.0",
"version": "0.5.0",
"description": "Used for vite Lazy import js and style",

@@ -5,0 +5,0 @@ "scripts": {

@@ -20,3 +20,7 @@ # vite-plugin-lazy-import

resolvers: [
{ lib: 'vxe-pc-ui', importStyle: 'css', esm: true }
{
lib: 'vxe-pc-ui',
importStyle: 'css', // import style '*.css'
esm: true // import directory '/es/*' | '/lib/*'
}
]

@@ -56,3 +60,7 @@ })

## Lazy import js
```javascript
import { lazyImport, kebabCase } from 'vite-plugin-lazy-import'
lazyImport({

@@ -62,5 +70,6 @@ resolvers: [

lib: 'vxe-pc-ui',
importStyle: 'css',
resolve ({ name }) {
return
return {
from: `vxe-pc-ui/es/${kebabCase(name)}/index.js`
}
}

@@ -72,4 +81,27 @@ }

## Lazy import js and css
```javascript
import { lazyImport, kebabCase } from 'vite-plugin-lazy-import'
lazyImport({
resolvers: [
{
lib: 'vxe-pc-ui',
importStyle: true,
resolve ({ name }) {
return {
from: {
jsPath: `vxe-pc-ui/es/${kebabCase(name)}/index.js`
stylePath: `vxe-pc-ui/es/${kebabCase(name)}/style.css`
}
}
}
}
]
})
```
## License
[MIT](LICENSE) © 2019-present, Xu Liangzhan

@@ -17,2 +17,3 @@ import { Plugin, FilterPattern } from 'vite'

name: string
lib: string
}) => null | LazyImportResolverResult

@@ -19,0 +20,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc