Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vite:dts] Internal Error: getResolvedModule() could not resolve module name #242

Closed
3 tasks done
NathanVss opened this issue Jul 13, 2023 · 5 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@NathanVss
Copy link

Describe the bug

Since the upgrade to version 3.x.x we are facing the following error when settings rollupTypes: true:

[vite:dts] Start generate declaration files...
computing gzip size (1)...[vite:dts] Start rollup declaration files...
[vite:dts] Internal Error: getResolvedModule() could not resolve module name "./components/Button"
/Users/nathanvasse/Documents/code/fun/cunningham/packages/react/dist/src/index.d.ts:3:1

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
✓ built in 4.50s
error during build:
Error: Internal Error: getResolvedModule() could not resolve module name "./components/Button"
/Users/nathanvasse/Documents/code/fun/cunningham/packages/react/dist/src/index.d.ts:3:1

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
    at ExportAnalyzer._fetchSpecifierAstModule (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:676:19)
    at ExportAnalyzer.fetchAstModuleFromSourceFile (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:112:65)
    at ExportAnalyzer._fetchSpecifierAstModule (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:693:41)
    at ExportAnalyzer.fetchAstModuleFromSourceFile (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:112:65)
    at AstSymbolTable.fetchAstModuleFromWorkingPackage (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:83:37)
    at Collector.analyze (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/@microsoft/api-extractor/lib/collector/Collector.js:155:51)
    at rollupDeclarationFiles (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/vite-plugin-dts/dist/index.cjs:108:13)
    at Object.writeBundle (/Users/nathanvasse/Documents/code/fun/cunningham/node_modules/vite-plugin-dts/dist/index.cjs:794:13)
    at async Promise.all (index 0)
    at async PluginDriver.hookParallel (file:///Users/nathanvasse/Documents/code/fun/cunningham/node_modules/rollup/dist/es/shared/node-entry.js:25260:9)

It works perfectly with the version 2.3.0.

Reproduction

https://github.com/openfun/cunningham/tree/6ffb537cd0ccc9aa077163021cb31b8055f51a7a/packages/react

Steps to reproduce

yarn install
yarn build

System Info

System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 399.88 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.20.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 114.0.5735.198
    Edge: 113.0.1774.57
    Safari: 16.1

Validations

NathanVss added a commit to openfun/cunningham that referenced this issue Jul 13, 2023
Since the upgrade we had an error during the types rollups, please see
qmhc/vite-plugin-dts#242.
NathanVss added a commit to openfun/cunningham that referenced this issue Jul 13, 2023
Since the upgrade we had an error during the types rollups, please see
qmhc/vite-plugin-dts#242.
@qmhc qmhc added the pending Need further confirmation label Jul 13, 2023
@TheKvist
Copy link

Getting the same error. It seems like the resolution of index files based on a directory import seems to be broken. Adding /index to the import paths resolves the issue, but this is of course only a workaround.

@qmhc qmhc added bug Something isn't working and removed pending Need further confirmation labels Jul 14, 2023
@qmhc qmhc closed this as completed in e53c815 Jul 14, 2023
@gokh4nozturk
Copy link

Getting same error.
Error:

vite v4.4.3 building for production...
✓ 84 modules transformed.

[vite:dts] Start generate declaration files...
computing gzip size (1)...[vite:dts] Start rollup declaration files...
Analysis will use the bundled TypeScript version 5.0.4
[vite:dts] Internal Error: getResolvedModule() could not resolve module name "./lib/main"
/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/dist/rocket-ui-vue.d.ts:1:1

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
✓ built in 36.54s
error during build:
Error: Internal Error: getResolvedModule() could not resolve module name "./lib/main"
/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/dist/rocket-ui-vue.d.ts:1:1

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
    at ExportAnalyzer._fetchSpecifierAstModule (/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:676:19)
    at ExportAnalyzer.fetchAstModuleFromSourceFile (/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:112:65)
    at AstSymbolTable.fetchAstModuleFromWorkingPackage (/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:83:37)
    at Collector.analyze (/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/@microsoft/api-extractor/lib/collector/Collector.js:155:51)
    at Function.invoke (/Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/@microsoft/api-extractor/lib/api/Extractor.js:143:19)
    at rollupDeclarationFiles (file:///Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/vite-plugin-dts/dist/index.mjs:250:28)
    at Object.writeBundle (file:///Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/vite-plugin-dts/dist/index.mjs:881:13)
    at async Promise.all (index 0)
    at async PluginDriver.hookParallel (file:///Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/rollup/dist/es/shared/node-entry.js:25260:9)
    at async file:///Users/gokhanozturk/Desktop/dev/labs/rocket-ui/node_modules/rollup/dist/es/shared/node-entry.js:26572:13
error Command failed with exit code 1.

vite.config.ts

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    dts({
      rollupTypes: true,
    }),
    vue(),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src/'),
    },
  },
  build: {
    lib: {
      entry: resolve(__dirname, 'lib/main.ts'),
      name: 'RocketUIVue',
      fileName: 'rocket-ui-vue',
    },
    rollupOptions: {
      external: ['vue'],
    },
  },
});

Reproduction: https://github.com/Teknasyon/rocket-ui

@martindzejky
Copy link

This is still a problem in vite-plugin-dts@3.6.3, using vite@4.5.0. Getting the same error as described above, using pretty much the same vite.config.ts.

@qmhc
Copy link
Owner

qmhc commented Nov 28, 2023

@martindzejky Hi, you can create a new issue with minimun reproduction to report the problem.

@martindzejky
Copy link

Yep, will do. 👍 I figured out what the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants