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 install vite-plugin-fast-external --save-dev

Usage

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

export default defineConfig({
  plugins: [
    fastExternal({
      vue: 'Vue',
    })
  ]
});

Definition

export type fastExternal = (
  externals: Record<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

  • Generate ESModule code into node_modules/.vite-plugin-fast-external/xxxx.js - eg:

    // source code
    import Vue from 'vue'
    // transformed
    const vue = window['Vue']; export { vue as default }
    
  • node_modules/.vite-plugin-fast-external/xxxx.js will be return when vite load hooks - eg:

    {
      name: 'vite-plugin-fast-external',
      load(id) {
        if (id.includes('node_modules/.vite-plugin-fast-external')) {
          return fs.readFileSync(externalFilename, 'utf8')
        }
      },
    },
    

TODO

  • Support multiple member import, such as import { ref, watch } from '@vue/composition-api'

Keywords

FAQs

Package last updated on 11 Nov 2021

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