1.0.4 • Published 9 months ago

vite-default-opt v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

vite-default-opt

A Vite plugin to automatically handle default imports for JavaScript and TypeScript files. It transforms default imports to be compatible with both CommonJS and ES module formats by checking if a module has a default export and falling back to the module itself if not.

Installation

To install the plugin, simply add it to your project using npm or yarn:

npm install --save-dev vite-default-opt

or

yarn add --dev vite-default-opt

Usage

import { defineConfig } from 'vite';
import transformDefaultImportPlugin from 'vite-default-opt';

export default defineConfig({
  plugins: [transformDefaultImportPlugin()],
});

How it works

The plugin processes each JavaScript/TypeScript file and transforms default imports like:

import SomeModule from 'some-module';

to:

import SomeModuleInner from 'some-module';
const SomeModule = SomeModuleInner.default || SomeModuleInner;
1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago