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

An tiny and fast external plugin for vite.


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-fast-external

npm package

Tiny and fast vite external plugin, without lexical transform.

NPM version NPM Downloads

Installation

npm i -D vite-plugin-fast-external

Usage

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

export default defineConfig({
  plugins: [
    fastExternal({
      // use string
      vue: 'Vue',
      // custom external code by function
      '@scope/name': () => `const Lib = window.LibraryName; export default Lib;`,
    })
  ]
})

Options define

export type fastExternal = (
  externals: Record<string, string | (() => string)>,
  options?: {
    /**
     * @default 'esm'
     * esm will generate code - const vue = window['Vue']; export { vue as default };
     * cjs will generate code - const vue = window['Vue']; module.exports = vue;
     */
    format: 'esm' | 'cjs'
  },
) => VitePlugin

How to work

  1. External-module will be generated code into node_modules/.vite-plugin-fast-external/xxxx.js
  2. Append an external-module alias
{
  resolve: {
    alias: [
      {
        find: 'vue',
        replacement: 'User/work-directory/node_modules/.vite-plugin-fast-external/vue.js',
      },
    ],
  },
}

Keywords

FAQs

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