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
Parcel does not generate types when using targets #8082
Comments
The "pkg#types" mechanism is implemented internally as just an additional target. |
This does not let me specify the context with which types are built, as this context differs per target. See: #7379 For me specifically, the context of which directory to generate the output is something I need to configure. Is such a configuration currently possible? |
I'm seeing something more. Even when I am generating all targets, I still see no type declaration files... |
If what you're asking for is a way to have multiple such targets: no, that's currently not possible. It has to be called "types", so there can only be one. |
thanks for the help! with this, i get no "main": "dist/api/api.js",
"type": "module",
"types": "dist/api/types.d.ts",
"targets": {
"cli": {
"context": "node",
"isLibrary": true,
"outputFormat": "esmodule",
"source": "src/index.ts"
},
"api": {
"context": "node",
"isLibrary": true,
"outputFormat": "esmodule",
"source": "src/api.ts"
}
}, |
That's unfortunate. Any idea if it could be a planned feature for specifying types per build? I'd be happy to leave this issue open as a pitch to consider adding it in the future if there are others who feel the same. |
What is the status here? I really need to have two targets with different type definition files for each bundle result. |
@viniciuspalma As a workaround, I ended up using |
No matter what I try, I cannot get types to output if I have any targets defined in my package.json. edit I got it to work. I don't know if this is a feature or a bug, but I'm going to call it a bug. I'm not really sure what exactly is going on, but it has to do with exclusiveTargets and
And now Parcel correctly bundles the preview target and the main/types targets. |
Awesome @kkirby 💯 |
🐛 bug report
I am building a library with Typescript.
I have targets defined in package.json. When running
parcel build
with--target <name>
, it ignores thetypes
entry in package.json and does not generate a .d.ts file.🎛 Configuration (package.json, cli command)
🤔 Expected Behavior
I am running:
But Parcel only generates
index.js
. I also expected it to generateindex.d.ts
which it is not doing.😯 Current Behavior
No
index.d.ts
file generated💁 Possible Solution
No clue, I'm hoping I'm just missing some configuration and this will be an easy fix.
🔦 Context
I need to run Parcel in watch mode as well. So while I could build without
--target
and copy the types manually, it doesn't work for watch mode and is very inconvenient to build multiple times just for types as a hack. I'm hoping there is a cleaner, more intentional solution for this situation.🌍 Your Environment
The text was updated successfully, but these errors were encountered: