-
Notifications
You must be signed in to change notification settings - Fork 71
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
Using together with Babel plugins and emitDeclarationOnly
overwrites output files with no content
#268
Comments
Does babel work without rpt2 in the chain when You might have to create a separate rollup config for declarations. |
Doesnt Work for me either with babel 7 nodeResolve({
browser: true,
}),
commonjs({
include: /node_modules/,
}),
babel({
exclude: /node_modules/,
babelHelpers: 'runtime',
}) // package.json
"rollup-plugin-typescript2": "^0.31.0"
"rollup": "2.59.0", Output: ./src/index.ts → lib/index.cjs.js, lib/index.ems.js, lib/index.umd.js...
(!) Generated empty chunks
index, index, index
created lib/index.cjs.js, lib/index.ems.js, lib/index.umd.js in 1.8s
|
This comment was marked as duplicate.
This comment was marked as duplicate.
Experiencing this too, using only babel, with typescript preset works fine. When add rpt2 to the list of plugins the output is empty files |
This should probably be investigated in more depth as this is a good feature to have. try rpt2 first if possibleThat being said, my suspicion at first glance is that this might actually be correct behavior: once If you run rpt2 first (with Could also run Rollup twice with two different configs as mentioned above, one for type declarations and the other for JS if Babel must be first, this may not be possible (may require TS transformers instead)Of course, if you're using a Babel plugin as OP is (particularly ones with syntax transforms I believe), you may not be able to change the Rollup plugin order like that. This is kind of a chicken-and-egg problem in that sense: either TS reads it and doesn't understand the Babel plugin syntax, or Babel reads it and strips the TS. With new syntax in the mix, it's basically no longer valid "TS" as it has some custom syntax, so I believe that will also cause issues with other tooling as well unfortunately. |
emitDeclarationOnly: true
emitDeclarationOnly
overwrites output files with no content
Ah so I hypothesized that Babel plugins might be possible with a two-pass Babel set-up and I believe they are. I'm also gonna investigate |
root cause analysisSo I dug a bit more into this and found an interesting result when logging out {
outputFiles: [
{
name: '<project root>/node_modules/.cache/rollup-plugin-typescript2/placeholder/index.d.ts.map',
writeByteOrderMark: false,
text: '{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAE/C;AAED,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA"}'
},
{
name: '<project root>/node_modules/.cache/rollup-plugin-typescript2/placeholder/index.d.ts',
writeByteOrderMark: false,
text: 'export default function sum(a: number, b: number): number;\r\n' +
"export { default as difference } from './difference';\r\n" +
'//# sourceMappingURL=index.d.ts.map'
}
],
emitSkipped: false,
diagnostics: [],
exportedModulesFromDeclarationEmit: undefined
} Some key pieces:
feature incoming!Changing the code to instead I wrote up the code for this and already tested it and confirmed that is working! It's actually a very small feature that opens up quite a bit of new use-cases (which is why I wanted to prioritize it after joining on as a maintainer!) 🙂 I'll have a PR out for this tomorrow (heading to bed now) 🚀 EDIT: see #366 |
Hey, thanks for this great plugin. Always use it but this time I have to compile the code with babel and just use this for declarations and it doesn't work for that.
What happens and why it is wrong
Environment
Using babel to compile files since I need to run code through a plugin:
Tried setting
emitDeclarationOnly
intsconfig.json
and above e.g.:Also tried putting
typescript()
beforebabel()
and it still somehow overrides the output files.Versions
rollup.config.js
#### .babelrc.json
tsconfig.json
plugin output with verbosity 3
plugin output with verbosity 3:
dist/index.js
becomes empty if typescript plugin is loaded anddist/index.umd.js
just has a stub -var e;e=function(){},"function"==typeof define&&define.amd&&define(e);
Thanks!
The text was updated successfully, but these errors were encountered: