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

171
Vistas
React: Resolve and transpile aliased file

set of React components is referred by @lib/UI An Admin Dashboard is referred by App`

The @lib/ui is a React package where it is installed in any react app to provide some UI out of the box.

The App which is a Dashboard (SINGLE SIDE APPLICATION) where it uses UI components from @lib/ui.

The @lib/ui needs some configuration to be passed from the Dashboard, where the configuration is in the form of a TSX file. The @lib/ui loads the configuration like the following,

import config from '@root/config'

where @root is an Alias to the App.

We tried to use the @lib/ui in a NextJS app and by simply doing something like the following.

# next.config.js
const nextConfig = {
  webpack: (config, { isServer }) => {
    config.resolve.alias = {
      '@root': path.resolve(__dirname, '.'),
      ...(config.resolve.alias || {}),
    }
}

And it works pretty much fine. The problem arises when using it in The App, which is a single-page application.

We're trying to do as we did in the NextJS application by using Craco to add Webpack config to the App`

#craco.config.js
module.exports = {
  webpack: {
    alias: {
      '@root': path.resolve(__dirname, '.'),
    },
  },
  plugins: [
    {
      plugin: cracoBabelLoader,
      options: {
        includes: [
          resolvePackage('node_modules/@lib/ui'),
        ],
      },
    },
  ],
}

{
  "scripts": {
    "start": "craco start",
  }
}

But it did not work out, and I got the following error.

>Failed to compile.
>./config.TSX 10:28
>Module parse failed: Unexpected token (10:28)
>File was processed with these loaders:
>./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
>You may need an additional loader to handle the result of these loaders.

>import { plainReducers } from './src/store/states'
> export const UiConfig = (): IUiConfig => ({
about 4 years ago · Juan Pablo Isaza
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