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 for vite plugin.


Version published
Weekly downloads
5
increased by25%
Maintainers
1
Install size
8.30 kB
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 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'

FAQs

Last updated on 04 Nov 2021

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