Giter Club home page Giter Club logo

Comments (29)

kswope avatar kswope commented on July 28, 2024 18

For desperate googlers: I'm a total rollup/typescript noob but I fixed it for myself with

https://www.typescriptlang.org/docs/handbook/modules.html#importing-types

from plugins.

ersinakinci avatar ersinakinci commented on July 28, 2024 8

Can we reopen? I'm still receiving this error when using Babel to compile TypeScript and importing types from third-party libs in node_modules when those types are exported in the library code using the same pattern that @Vehmloewff described above. (Example: import { GraphQLSchema } from 'graphql'.)

from plugins.

boshoff avatar boshoff commented on July 28, 2024 6

@thorsent the suggestion to import type { Blah } from "blah" worked perfectly with a Vite build (which uses rollup). Thanks!

In my case I was importing an enum so import type was preventing it from being used as a value. Specifying that the module that I'm importing from should remain external to the bundle in vite.config.js resolved the issue:

// ...

export default defineConfig({
  build: {
    rollupOptions: {
      external: ['@project/library'],
    },
  },
  // ...
})

from plugins.

codeho avatar codeho commented on July 28, 2024 6

@thorsent the suggestion to import type { Blah } from "blah" worked perfectly with a Vite build (which uses rollup). Thanks!

In my case I was importing an enum so import type was preventing it from being used as a value. Specifying that the module that I'm importing from should remain external to the bundle in vite.config.js resolved the issue:

// ...

export default defineConfig({
  build: {
    rollupOptions: {
      external: ['@project/library'],
    },
  },
  // ...
})

this worked for me!

from plugins.

NotWoods avatar NotWoods commented on July 28, 2024 5

I'll try to get this working with our larger TS plugin updates.

from plugins.

thorsent avatar thorsent commented on July 28, 2024 4

I ran into this issue when trying to use an enum that was exported by the library's typedef but which wasn't exported in the library's es6 module. There was no help from the compiler until switching from import { Blah } from "blah" to import type { Blah } from "blah". Then the compiler barfed up the problem. I worked around the problem by just using the raw string, but there might be a magic sequence of tsconfig that would have helped.

from plugins.

D-Thrane avatar D-Thrane commented on July 28, 2024 4

Having same issue when I build in Vite. All my interfaces get the import/export error

from plugins.

ziofat avatar ziofat commented on July 28, 2024 2

Well. You are referring to a issue in old repository and it was closed due to repository move. However this is not resolved right now. For me the workaround is not acceptable because I have a very large code base.
The rollup-plugin-typescript2 handles this situation very well but it is really slow after upgrading to typescript 3.4.

from plugins.

NotWoods avatar NotWoods commented on July 28, 2024 2

This is fixed with @rollup/plugin-typescript version 3.0.0!

from plugins.

Vehmloewff avatar Vehmloewff commented on July 28, 2024 1

Thanks for responding!

I think that this issue is still relevant @shellscape. I would be glad to know that it will be transferred to the new repo.

from plugins.

Vehmloewff avatar Vehmloewff commented on July 28, 2024 1

There is a workaround for this, I'll be it is not an ideal one, but it is what I have been using in the meantime.

Instead of

import { Type1, Type2 } from './file.ts';

export {
	Type2
}

export const fn1: Type1 = () => {
	// ...
}

I just

import { Type1, Type2 } from './file';

export const fn1: Type1 = () => {
	// ...
}

export * from './file';

The only problem with this is that I do not really want to export Type1. But in my case, I would rather have extra export that not have the ones I need.

from plugins.

chrisrrowland avatar chrisrrowland commented on July 28, 2024 1

For desperate googlers: I'm a total rollup/typescript noob but I fixed it for myself with

https://www.typescriptlang.org/docs/handbook/modules.html#importing-types

This worked for me too (import type) but it does seem like a workaround.

from plugins.

shellscape avatar shellscape commented on July 28, 2024

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. 🍺

from plugins.

ziofat avatar ziofat commented on July 28, 2024

Hi, is this fixed or not?

from plugins.

NotWoods avatar NotWoods commented on July 28, 2024

It's not fixed yet, it's just been transferred to the new repository.

from plugins.

Vehmloewff avatar Vehmloewff commented on July 28, 2024

I just realized that this is a duplicate of rollup/rollup-plugin-typescript#28. Sorry for the inconvenience.

from plugins.

shellscape avatar shellscape commented on July 28, 2024

@ziofat if you'd like to put together a minimal reproduction in a repo that we can clone, I'd be happy to reopen this. We're going to need a reproduction to triage this.

from plugins.

ziofat avatar ziofat commented on July 28, 2024

@shellscape OK, I will try to make a reproduction later.

from plugins.

petejodo avatar petejodo commented on July 28, 2024

I created a repo that reproduces the issue here https://github.com/PeteJodo/repro-rollup-typescript-export-type-issue

I get this output

> [email protected] rollup /Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue
> rollup -c


src/index.ts β†’ dist/index.js...
[!] Error: 'IExample' is not exported by src/dep.ts
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/index.ts (1:9)
1: export { IExample, MyExample } from './dep';
            ^
Error: 'IExample' is not exported by src/dep.ts
    at error (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:5365:30)
    at Module.error (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9708:9)
    at handleMissingExport (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9625:21)
    at Module.getVariableForExportName (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9829:17)
    at Module.includeAllExports (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9876:35)
    at Promise.all.then (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:13083:24)
    at <anonymous>

from plugins.

weyert avatar weyert commented on July 28, 2024

Yes, I have the same issue and temporary not exporting the props of my React components due to this issue. I have also tried rollup-plugin-typescript2 but that's not working at all, keep getting failed to transpile '/Users/work/experiment/src/index.ts' and have no idea what that is supposed to mean.

from plugins.

shellscape avatar shellscape commented on July 28, 2024

@NotWoods this might be up your alley. @petejodo put together a reproduction repo for reference, and it might be related to the updates you have planned already.

from plugins.

hasangenc0 avatar hasangenc0 commented on July 28, 2024

@rollup/plugin-typescript
Hi, congrats to fix this bug πŸŽ‰.
When the new version will be released?

from plugins.

shellscape avatar shellscape commented on July 28, 2024

@earksiinni you're welcome to open a new issue with a proper reproduction. We won't be reopening this one.

from plugins.

marcus13371337 avatar marcus13371337 commented on July 28, 2024

Solved this issue by doing the following:
index.ts

import { TypeYouWantToExport as TypeYouWantToExportReal } from './file1'

export type TypeYouWantToExport = TypeYouWantToExportReal

from plugins.

dayrlism10 avatar dayrlism10 commented on July 28, 2024

this resolved my concern, hope it helps

export type MyType = import("./types.ts").MyType;

from plugins.

spadgeaki avatar spadgeaki commented on July 28, 2024

Hi, i had similar issue but with react-beautiful-dnd. It helped to yarn install -D @types/react-beautiful-dnd

from plugins.

matthew-dean avatar matthew-dean commented on July 28, 2024

This also fails with @rollup/plugin-sucrase FYI. Can however this was solved with the typescript plugin be applied to Sucrase?

from plugins.

mklueh avatar mklueh commented on July 28, 2024

Running into this with Nuxt 3.0.0-rc.4 when trying to import from a library, while it was previously working

from plugins.

mw-sezzle avatar mw-sezzle commented on July 28, 2024

@thorsent the suggestion to import type { Blah } from "blah" worked perfectly with a Vite build (which uses rollup). Thanks!

from plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.