Socket
Socket
Sign inDemoInstall

vite-plugin-fast-external

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-fast-external

Without lexical transform, support custom external code.


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-fast-external

npm package
NPM version NPM Downloads

🚀 High performance without lexical transform
🌱 Support custom external code

English | 简体中文

  • Like Webpack externals, support browser, Node.js and Electron

  • With out ast analyze, load virtual files by resolveId-hooks -- Real efficient

  • Support customize the code snippets by return string from function -- Real flexible 🎉

Install

npm i vite-plugin-fast-external -D

Usage

import external from 'vite-plugin-fast-external';

export default {
  plugins: [
    external({
      vue: 'Vue',
    })
  ]
}
Customize

Support custom external code by function

external({
  'element-ui': () => `
    const E = window.ELEMENT;
    export { E as default };
    export const Loading = E.Loading;
    export const Message = E.Message;
    export const MessageBox = E.MessageBox;
    export const Notification = E.Notification;
  `,
  // ...other element-ui members
})
Load a file

Support nested module id, support return Promise

resolve({
  'path/filename': () => require('fs/promises').readFile('path', 'utf-8'),
})

API

external(entries)

type entries = Record<string, string | ((id: string) => string | Promise<string>)>;

How to work

In fact, the plugin will intercept your module import and return the specified code snippet
Let's use external({ vue: 'Vue' }) as an example, this will get the below code

const M = window['Vue']; export { M as default }

Keywords

FAQs

Package last updated on 14 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

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