-
Notifications
You must be signed in to change notification settings - Fork 71
emitDeclarationOnly
in v0.33.0 -- what if I want an empty chunk and only declarations?
#411
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
Comments
emitDeclarationOnly
throws in v0.33.0emitDeclarationOnly
throws in v0.33.0 -- needs another plugin (intended)
emitDeclarationOnly
throws in v0.33.0 -- needs another plugin (intended)emitDeclarationOnly
throws in v0.33.0 -- needs a different TS transpiler (intended)
This is a new feature in Per the log you provided, it states Per the docs, this feature is meant to be used together with another plugin, such as Per the release notes, this was implemented in #366 to support the highly requested #268. As such, this is not a bug, but very much intended behavior. If you want to keep |
Hope I don't misunderstand: What if I only want to emit declarations and not transpile TS at all? While it did work before and warn about an empty chunk being generated, it still did emit the declaration as expected. And though |
Oh. I didn't realize that anyone actually wanted an empty chunk. #268 showed that most folks were pretty confused by the resulting empty chunk. But I guess everyone's got their own workflow 😅
Any chance you could provide a small example of where rpt2 simplifies the process vs. using
So this is still possible in So what you could do is use an empty file for Rollup's Does that satisfy your use-case? It's a bit hacky, but I do think the intent is a little more clear that way (e.g. empty file -> empty chunk). Most people seemed to have been pretty confused by the empty chunk behavior before and that didn't seem intuitive to them. |
emitDeclarationOnly
throws in v0.33.0 -- needs a different TS transpiler (intended)emitDeclarationOnly
in v0.33.0 -- what if I want an empty chunk and only declarations?
In some libraries which I cross build to ESM and CJS I use a split rollup configuration to generate the individual outputs with the same The configuration boils down to something like this: https://stackblitz.com/edit/rpt2-repro-e2gczu?file=rollup.config.js, i.e:
rollup.config.js |
Oh woops, my bad, I meant the (I happened to have been changing a Rollup config at the same time, so I screwed that up, sorry! Of course, the
Thanks for providing a detailed example, that made it much easier to understand! A commonly used one by rpt2 users is to set // rollup.config.js
import typescript from 'rollup-plugin-typescript2';
export default [{
input: './src/index.ts',
output: [{
file: './dist/esm/index.js',
format: 'esm',
exports: 'named',
sourcemap: true,
}, {
file: './dist/cjs/index.js',
format: 'cjs',
exports: 'named',
sourcemap: true,
}],
plugins: [
typescript({
verbosity: 3,
clean: true,
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
declarationDir: './dist/types',
},
},
}),
],
}]; Note that I'm also using Rollup's multi-output feature here for ESM + CJS, which should optimize your build a bit too, since Rollup won't need to analyze the input a second time around or re-run any input plugins. The caveat with |
Thanks a lot for your time and the hint regarding the |
Troubleshooting
tsc
have the same output? If so, please explain why this is incorrect behaviorNo
Yes
https://stackblitz.com/edit/rpt2-repro-1kadjh?file=package.json
What happens and why it is incorrect
The build crashes if
emitDeclarationOnly
is set totrue
in overrides or tsconfig.tsc
produces the correct output. Used to work until v0.33.0.Environment
Versions
:rollup.config.js
:tsconfig.json
:package.json
plugin output with verbosity 3
:The text was updated successfully, but these errors were encountered: