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

165
Visualizações
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 à 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