Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Better way to import Vite plugin

I get an error when following the usage for vite-plugin-plain-text:

import plainText from 'vite-plugin-plain-text';

console.log(plainText);  // Check what we imported.
let config = plainText(/LICENSE$/);

The output is:

{ default: [Function: plainText] }
> plainTextPlugin is not a function

Instead of importing a function, the import statement imported an object with a function named default. In the module JS file, plainText was exported like this:

Object.defineProperty(exports, "__esModule", { value: true });
...
exports.default = plainText;

I was able to successfully import like this:

import plainTextPlugin from 'vite-plugin-plain-text';
let plainText = plainTextPlugin.default;
let config = plainText(/LICENSE$/);

Is there a more elegant way to accomplish this import? JavaScript ‪Module Cheatsheet doesn't have any pattern for importing a library that was exported like this library. Interestingly, the TS source code exports the module like this:

export default function plainText (...)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!