Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda