2.5.1 • Published 3 years ago

vite-plugin-fast-external v2.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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'
2.5.0

3 years ago

2.5.1

3 years ago

2.4.2

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.1.2

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.1

3 years ago

2.2.2

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.4.8

3 years ago

1.4.7

3 years ago

1.2.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago