Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
What is the correct way to import esm/dist modules? (React/javascript)

So we're using the geist component library in our codebase. It's pretty much integrated into parts of our app and since this library is 250kb, it's impacting our page speed. To circumvent importing the entire module, the usual solution is just importing what you need and ideally, nothing should break and everything should work as expected.

import { CssBaseline } from "@npkn/geist-react"

Doing the above should work but adds 250kb to the bundle.

Another way to import a component would be to import the specific file. I get two options to import the component from either ESM or dist modules

import CssBaseline from "@npkn/geist-react/dist/css-baseline"

and

import CssBaseline from "@npkn/geist-react/esm/css-baseline/index"

I've tried doing both of these but webpack throws errors. I've tried importing named exports as well but even then it throws an error.

TypeError: _npkn_geist_react_dist_css_baseline__WEBPACK_IMPORTED_MODULE_0___default(...).flush is not a function
   9 |   static async getInitialProps(ctx) {
  10 |     const initialProps = await Document.getInitialProps(ctx)
> 11 |     const styles = CssBaseline.flush()
     |                   ^
  12 | 
  13 |     return {
  14 |       ...initialProps,

My question is am I doing the imports right or is there something I'm missing?

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If anyone else comes across this question, please check out the bundle size example https://geist-ui.dev/en-us/guide/bundle-size. The example doesn't quite work but I found this work around https://spectrum.chat/geist-ui/react/minimize-build~d30af727-2b97-4d16-9357-9b4e5104fdc9

Instead of doing

import Button from '@geist-ui/react/esm/button'

do

import Button from '../../../../node_modules/@geist-ui/react/esm/button';

Reduced our bundle size significantly!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda