question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

resolve.alias doesn't work is this plugin

See original GitHub issue

Hello !

It looks like aliases are not correctly transformed in d.ts files… All the JavaScript code is ok. It’s just my d.ts files.

image

Here my vite config :

import { defineConfig } from 'vitest/config'
import tsconfigPaths from 'vite-tsconfig-paths'
import react from '@vitejs/plugin-react'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import dts from 'vite-plugin-dts'

const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  test: {
    environment: 'jsdom',
    globals: true
  },
  build: {
    sourcemap: true,
    target: 'esnext',
    minify: false,
    lib: {
      entry: path.resolve(__dirname, 'src/index.tsx'),
      name: 'Mui-phone-number',
      fileName: format => `mui-phone-number.${format}.js`
    },
    rollupOptions: {
      output: {
        sourcemapExcludeSources: true,
        globals: {
          react: 'React',
          '@mui/material/InputAdornment': 'InputAdornment',
          '@mui/material/TextField': 'TextField',
          '@mui/material/IconButton': 'IconButton',
          '@mui/material/styles': 'styles',
          'react/jsx-runtime': 'jsxRuntime',
          '@mui/material/Menu': 'Menu',
          '@mui/material/MenuItem': 'MenuItem',
          '@mui/material/Typography': 'Typography',
          '@mui/material/ListItemIcon': 'ListItemIcon',
          '@mui/material/ListItemText': 'ListItemText'
        }
      }
    }
  },
  plugins: [
    peerDepsExternal(),
    react(),
    tsconfigPaths(),
    dts({
      insertTypesEntry: true
    })
  ]
})

Is anyone has the same issue ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
qmhccommented, Mar 18, 2022

I initially think this may be some unrobust when using with the vite-tsconfig-paths.

Normally it is as expected when using resolve.alias in the vite config file.

This is one of the main tasks for next version, I still need more time for futher testing, thanks for your patience.

0reactions
gyzerokcommented, Oct 7, 2022

@viclafouch would you mind sharing your config? It seems like emitted typescript declarations do not work with vite-aliases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack resolve.alias does not work with typescript?
I am using Babel 7 with babel-plugin-module-resolver to resolve aliases. No ts-loader or awesome-typescript-loader as Babel 7 supports TypeScript out of the box ......
Read more >
Resolve | webpack
An object which maps extension to extension aliases. webpack.config.js module.exports = { //... resolve: ...
Read more >
@rollup/plugin-alias - npm
This is plugin mimics the resolve.extensions and resolve.alias functionality in Webpack. This plugin will work for any file type that Rollup ...
Read more >
Can't resolve path alias : r/reactjs - Reddit
I'm trying to use alias for paths but I can't seem to get it to work I keep getting this error even though...
Read more >
Import Aliases in Vite - Vue School Blog
Vite takes a resolve.alias config option that it passes on to @rollup/plugin-alias as it's entries option. All that's needed is to pass it ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found