Socket
Socket
Sign inDemoInstall

vite-plugin-fast-external

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

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
5
increased by25%
Maintainers
1
Created
Weekly downloads
 

Readme

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
      // will generate code `const vue = window['Vue']; export { vue as default }`
      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

Last updated on 14 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc