Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

vite-plugin-dynamic-import-module

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-dynamic-import-module

dynamic import module

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
104
-60.46%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-dynamic-import-module

NPM version

A vite plugin to support variables in dynamic imports module in Vite

Install

pnpm add vite-plugin-dynamic-import-module -D

Usage


import { defineConfig } from 'vite'
import importDynamicModule from 'vite-plugin-dynamic-import-module'

export default defineConfig({
  plugins: [importDynamicModule()],
})

Options

include

Type: string | Array<string>
Default: []

Files to include in this plugin (default all).

exclude

Type: string | Array<string>
Default: []

Files to exclude in this plugin (default none).

extensions

Type: Array<string> Default: ['js', 'cjs', 'ts', 'tsx', 'jsx', 'mjs', 'mts', 'mtsx']

Automatically add default extensions when your import path has no extensions

How it works?

// Allowed
import(`@ant-design/icons/${name}`)
import(`@ant-design/icons/${name}.js`)
import(`@ant-design/icons/${name}Outlined`)
import(`@ant-design/icons/${name}Outlined.js`)

// Not allowed
// cannot find module
import(`@ant-design/${module}/${name}`)

Limitations

module name does not allow use variables

// module as @ant-design
import(`@ant-design/${module}${name}`)

// module as @ant-design/icons/es/icons
import(`@ant-design/icons/es/icons/${name}`)

Thanks

LICENSE (MIT)

Keywords

dynamic-import

FAQs

Package last updated on 19 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts