Comments (29)
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.
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.
@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.
@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
soimport 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 invite.config.js
resolved the issue:// ... export default defineConfig({ build: { rollupOptions: { external: ['@project/library'], }, }, // ... })
this worked for me!
from plugins.
I'll try to get this working with our larger TS plugin updates.
from plugins.
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.
Having same issue when I build in Vite. All my interfaces get the import/export error
from plugins.
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.
This is fixed with @rollup/plugin-typescript version 3.0.0!
from plugins.
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.
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.
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.
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.
Hi, is this fixed or not?
from plugins.
It's not fixed yet, it's just been transferred to the new repository.
from plugins.
I just realized that this is a duplicate of rollup/rollup-plugin-typescript#28. Sorry for the inconvenience.
from plugins.
@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.
@shellscape OK, I will try to make a reproduction later.
from plugins.
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.
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.
@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.
@rollup/plugin-typescript
Hi, congrats to fix this bug π.
When the new version will be released?
from plugins.
@earksiinni you're welcome to open a new issue with a proper reproduction. We won't be reopening this one.
from plugins.
Solved this issue by doing the following:
index.ts
import { TypeYouWantToExport as TypeYouWantToExportReal } from './file1'
export type TypeYouWantToExport = TypeYouWantToExportReal
from plugins.
this resolved my concern, hope it helps
export type MyType = import("./types.ts").MyType;
from plugins.
Hi, i had similar issue but with react-beautiful-dnd. It helped to yarn install -D @types/react-beautiful-dnd
from plugins.
This also fails with @rollup/plugin-sucrase
FYI. Can however this was solved with the typescript plugin be applied to Sucrase?
from plugins.
Running into this with Nuxt 3.0.0-rc.4 when trying to import from a library, while it was previously working
from plugins.
@thorsent the suggestion to import type { Blah } from "blah"
worked perfectly with a Vite build (which uses rollup). Thanks!
from plugins.
Related Issues (20)
- [@rollup/plugin-eslint] New flat config `eslint.config.js` is not recognized HOT 1
- [@rollup/plugin-esm-shim] Shim inserted incorrectly if source file has `import` in comment HOT 1
- [@rollup/plugin-node-resolve] confusion about what this plugin does HOT 2
- How to tell `--configPlugin` to use specific `tsconfig`? HOT 5
- [@rollup/plugin-node-resolve] resolving package.json exports/imports arrays HOT 1
- Source URLs in generated source map are wrong when `composite` is enabled in tsconfig.json
- requireReturnsDefault: "auto" results in an incorrect bundle for some libraries
- [@rollup/plugin-alias] Allow to configure alias based on entry point
- ε¨SCSSδΈε¦δ½ζΏζ’Varει
- Allow @rollup/plugin-virtual to be a function that takes a module ID
- [@rollup/plugin-tpescript] Rollup does not use `paths` in `rollup.config.ts`
- [@rollup/plugin-typescript] allowImportingTsExtensions warning
- [@rollup/plugin-tpescript] Rollup does not get `module` and `moduleResolution` settings from extended `tsconfig.json`
- [@rollup/plugin-json] won't process files without json suffix HOT 4
- CommonJS plugin version bump to 26.0.0 causes build issue HOT 4
- Confusing explanation in @rollup/plugin-typescript's README
- [@rollup/plugin-swc] leads to unusable bundle in combination with [@rollup/plugin-commonjs] and [@rollup/plugin-node-resolve]
- I don't know if this is a mistake
- Wasm plugin to support latest ESM Integration & Source Phase Imports
- [@rollup/plugin-json] inclusion/exclusion filter fails HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugins.