-
Notifications
You must be signed in to change notification settings - Fork 69
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
Plugin doesn't pass files to next plugin (babel) -- need to add TS extensions to Babel plugin #108
Comments
rtp2 transpiles code, but doesn't change file extension (there is no way to do that in rollup as far as I know). Babel plugin, even though it claims it processes all files, only looks at code with those extensions by default: If you add .ts and .tsx to that list ( |
@ezolenko thanks! Seems behaviour of babel plugin was changed in last updates. My solution of this problem: // ...
import { DEFAULT_EXTENSIONS } from '@babel/core';
// ...
babel({
extensions: [
...DEFAULT_EXTENSIONS,
'ts',
'tsx'
],
runtimeHelpers: true
}),
// ... |
I just spent a lot of time debugging this -- wish I'd found the issue sooner. Thanks for the solution! @ezolenko Would you be open to PR adding a section adding a section mentioning this to the documentation? It took me longer than I care to admit to find this issue and I've seen other people (on my team and in open source) repeating this mistake. I'd be happy to try to write a paragraph for the readme that might save others some time if you're hope to it. |
@jakegavin sure, a PR would be nice |
@jakegavin nvm, I added a bit in readme. Could you check if code snipped is correct? (should extensions have dots in front or it doesn't mater?) |
@ezolenko Sorry I didn't get to it yesterday. I havent merged the change in my project yet but thats basically what I have and it appears to be working well locally. I don't think Thanks! |
@ezolenko I have a build that uses Apparently they've discovered the way to rename output files! This works for me: const renameExtensionsConfig = {
include: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
mappings: {
'.ts': '.js',
'.tsx': '.js'
}
};
const plugins = [
nodeResolve(),
peerDepsAsExternal({ includeDependencies: true }),
typescript(),
renameExtensions(renameExtensionsConfig),
babel(babelConfig),
postcss(postCSSConfig)
]; But it would be even better if this plugin could co-opt the technique they're using and produce correct filenames on its own. Thanks for all your hard work on this! |
It is in a There are probably some gotchas with that though, like I see it also re-parses files and changes extensions in |
What happens and why it is wrong
My plugins:
output script is doesn't transformed.
If I remove all typescript things from rollup config and set input file to 'lib/index.es.js' - output script is successfully transformed.
You can reproduce it with my project:
https://github.com/TrigenSoftware/flexis-redux/tree/upd-deps-wip
plugin output with verbosity 3
log:
The text was updated successfully, but these errors were encountered: