-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Honor declaration config #61
Comments
👍 |
This commit changes the distributable file format in the following ways: - unbundles both the commonjs and ES module files from one file each to one for each original file for each format - includes `.d.ts` files for each original source file - adds `types` field to `package.json` per https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html - removes rollup as the dist builder and uses a wrapper, `script/build`, that uses `tsc` directly - removes `coffee-lex.js.flow` I don't like that I had to write a custom build script for this. It makes me feel like I'm doing something incorrectly to support both commonjs and ES modules. I removed rollup because it didn't seem to play well with TypeScript from a publishing perspective. Specifically, I couldn't find any way to automatically build a `d.ts` file for the project bundle generated by rollup that didn't have serious shortcomings (https://github.com/rollup/rollup-plugin-typescript/issues/54). I considered keeping the bundled `.js` and `.mjs` files and using multiple `.d.ts` files, but there didn't seem to be much benefit over simply leaving all of them split up. Other rollup-based projects can still efficiently bundle coffee-lex with the modules split out as separate files.
This commit changes the distributable file format in the following ways: - unbundles both the commonjs and ES module files from one file each to one for each original file for each format - includes `.d.ts` files for each original source file - adds `types` field to `package.json` per https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html - removes rollup as the dist builder and uses a wrapper, `script/build`, that uses `tsc` directly - removes `coffee-lex.js.flow` I don't like that I had to write a custom build script for this. It makes me feel like I'm doing something incorrectly to support both commonjs and ES modules. I removed rollup because it didn't seem to play well with TypeScript from a publishing perspective. Specifically, I couldn't find any way to automatically build a `d.ts` file for the project bundle generated by rollup that didn't have serious shortcomings (https://github.com/rollup/rollup-plugin-typescript/issues/54). I considered keeping the bundled `.js` and `.mjs` files and using multiple `.d.ts` files, but there didn't seem to be much benefit over simply leaving all of them split up. Other rollup-based projects can still efficiently bundle coffee-lex with the modules split out as separate files.
This commit changes the distributable file format in the following ways: - unbundles both the commonjs and ES module files from one file each to one for each original file for each format - includes `.d.ts` files for each original source file - adds `types` field to `package.json` per https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html - removes rollup as the dist builder and uses a wrapper, `script/build`, that uses `tsc` directly - removes `coffee-lex.js.flow` I don't like that I had to write a custom build script for this. It makes me feel like I'm doing something incorrectly to support both commonjs and ES modules. I removed rollup because it didn't seem to play well with TypeScript from a publishing perspective. Specifically, I couldn't find any way to automatically build a `d.ts` file for the project bundle generated by rollup that didn't have serious shortcomings (https://github.com/rollup/rollup-plugin-typescript/issues/54). I considered keeping the bundled `.js` and `.mjs` files and using multiple `.d.ts` files, but there didn't seem to be much benefit over simply leaving all of them split up. Other rollup-based projects can still efficiently bundle coffee-lex with the modules split out as separate files.
This commit changes the distributable file format in the following ways: - unbundles both the commonjs and ES module files from one file each to one for each original file for each format - includes `.d.ts` files for each original source file - adds `types` field to `package.json` per https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html - removes rollup as the dist builder and uses a wrapper, `script/build`, that uses `tsc` directly - removes `coffee-lex.js.flow` I don't like that I had to write a custom build script for this. It makes me feel like I'm doing something incorrectly to support both commonjs and ES modules. I removed rollup because it didn't seem to play well with TypeScript from a publishing perspective. Specifically, I couldn't find any way to automatically build a `d.ts` file for the project bundle generated by rollup that didn't have serious shortcomings (https://github.com/rollup/rollup-plugin-typescript/issues/54). I considered keeping the bundled `.js` and `.mjs` files and using multiple `.d.ts` files, but there didn't seem to be much benefit over simply leaving all of them split up. Other rollup-based projects can still efficiently bundle coffee-lex with the modules split out as separate files.
👍 I currently have to use typescript on its own to generate es6 files and |
rollup-plugin-typescript2 says that it supports it. I will give it a try but I would prefer to use the official rollup plugin for typescript. |
I've had to switch to |
Still no update on this? I have to sadly agree to @ncphillips ... |
Yup, I've moved to |
Guys, still nothing? |
Had to switch to |
I use |
There are quite a few people commenting on support for this, but we don't have any open PRs to address this. We're totally open to adding this, but we need you fine folks to help us. 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 if no one from userland steps up to make the request happen. After that point, we'd encourage anyone still facing the issue to pitch in on the new repo and get this improvement in for the plugin. |
Hey folks. We're in progress on migrating the plugin, and have transferred this issue. We're going to lock it for a short time until the migration is complete, and then we'll unlock and continue the discussion. 🍺 |
Is anybody working on this? |
Yes, it's being worked on. Contributor support is also welcome! |
Added in version 4.0.0 of the typescript plugin |
For others also potentially struggling with this: For types to be emitted, you currently have to declare a Also have a look at the PR that implemented this feature for instructions on how to generate declaration files: #217 |
Thanks @danimoh it's very helpful. additionally..
Here's my rollup config to make redux style outputs. import typescript from '@rollup/plugin-typescript'
export default [
// CommonJS
{
input: 'src/index.ts',
output: {
dir: './',
entryFileNames: 'lib/my-pkg.js',
format: 'cjs',
},
plugins: [
typescript({
declaration: true,
declarationDir: 'types/',
rootDir: 'src/'
}),
]
},
// ES
{
input: 'src/index.ts',
output: { file: 'es/my-pkg.js', format: 'es' },
plugins: [
typescript(),
]
},
] |
Note that currently a rootDir needs to be specified in tsconfig.json, see rollup/plugins#61 (comment)
Yes, it's being worked. And get many There was any way to generate only one declaration file? |
Since I always get stuck on this when trying to use this package instead of
typescript({
tsconfig: './tsconfig.json',
}),
babel({ babelHelpers: 'bundled', extensions }), // Note: DON'T need babel typescript preset (or this babel plugin unless you need to)
|
@dominictobias I really wish you would leave the snark and slight out of replies. It doesn't serve any purpose, makes you look like a jerk, and is insulting to the folks who gave their free time to improve this plugin over time. Sure, it works different for people in different scenarios - as all things do - but that doesn't mean you need to disrespect who freely made something for you to use. Be a better person. |
@zeakd @danimoh Following your instructions I finally managed the plugin to output declarations 🎉 Thanks!! I have a question, though. It seems Is there any solution or workaround for this? |
Finally got type definitions to work following this commenting: rollup/plugins#61 (comment)
Also update @typescript-eslint/eslint-plugin, @typescript-eslint/parser and eslint-config-airbnb-typescript for compatibility with the updated typescript version, and fix newly reported type and lint issues. Additionally, with the merge of rollup/plugins#818, the rootDir hack for making typescript build in combination with emitting declaration files could now be removed. For the previous hack see rollup/plugins#61 (comment) and rollup/plugins#287.
It would be nice if the
declaration: true
flag would be honored in the output.The text was updated successfully, but these errors were encountered: