rollup-plugin-dts icon indicating copy to clipboard operation
rollup-plugin-dts copied to clipboard

[@types/node | undici-types] UnsupportedSyntaxError: ImportEquals should have a literal source.

Open kravetsone opened this issue 7 months ago • 0 comments

Checklist

  • [x] I can reproduce this issue when running this plugin on its own. Other plugins, such as node-resolve are known to cause issues.
  • [ ] I am running this plugin on .d.ts files generated by TypeScript. The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • [ ] This issue is not related to rolling up @types. The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Code Snipped

import type { Response } from "undici-types";

export type A = Response;

Error Message

UnsupportedSyntaxError: ImportEquals should have a literal source.

4:1: `import MockDispatch = MockInterceptor.MockDispatch;`   
    at dr.convertImportDeclaration (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:10590)
    at dr.convertStatement (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:8366)     
    at new Transformer (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:7064)
    at convert (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:6881)
    at Object.transform (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:14853)       
    at handleDtsFile (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:30:1244)
    at Object.transform (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:30:1843)        
    at Z:\PROJECTS\node-ts\test\node_modules\rollup\dist\shared\rollup.js:989:40 {
  code: 'PLUGIN_ERROR',
  plugin: 'dts',
  hook: 'transform',
  id: 'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-agent.d.ts',
  watchFiles: [
    'Z:\\PROJECTS\\node-ts\\test\\src\\index.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\index.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\cache.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\filereader.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\file.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\formdata.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\fetch.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-errors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-client.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\api.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\global-dispatcher.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\errors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\connector.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\client.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\balanced-pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\interceptors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\handlers.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\dispatcher.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\global-origin.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\proxy-agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\cookies.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\diagnostics-channel.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\websocket.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\content-type.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-interceptor.d.ts'
  ]
}

undici-types used by @types/node and in dependencies source code it looks like import("undici-types").Response

kravetsone avatar Jul 17 '24 11:07 kravetsone