-
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
0.34.0
not handling JSON import in rollup.config.ts
#426
Comments
rollup.config.ts
rollup.config.ts
0.34.0
not handling JSON import in rollup.config.ts
Thanks for the repro, I was able to successfully reproduce in
I'll have to investigate this more when I get the time, nice catch on this change between |
Thank you for your reply. I went to see what caused the mistake today |
So I added some "scripts": {
"build": "rollup --config ./rollup.config.ts --configPlugin \"typescript2={ verbosity: 3 }\"",
}, and the strange part is that the logs between versions are virtually identical (outside of version number, cache hash, and the error ofc, everything else is identical):
|
I did some additional logging and experimentation, and this hunch of mine seems to be roughly correct: the additional We could potentially skip For reference, here's the JS that rpt2 outputs: import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';
const banner = `/** ${pkg.name} */`;
export default () => {
return {
input: './src/index.ts',
output: {
banner,
exports: 'auto',
inlineDynamicImports: true,
format: 'cjs',
file: `dist/index.cjs.js`,
},
plugins: [
typescript({
clean: true,
useTsconfigDeclarationDir: true,
abortOnError: true,
}),
],
};
}; This is correct, so that suggests this isn't an rpt2 bug, but an upstream Rollup bug. I'm also not 100% sure that rpt2 skipping JSON files would be valid behavior. A theoretical scenario, for instance, would be if another plugin were to transform the JSON to a type-only TS file, which would be a case rpt2 should handle. |
This is a very hacky workaround, but could also do: const pkg = JSON.parse(await fs.readFile('./package.json', 'utf8')); as this SO answer does (for a more detailed example). (or ofc, add |
I dug into this a bit, in particular, re-reading my initial logic and root cause analysis of the type-only issue, and I actually think this should be feasible. Based on my logic there, So I think adding a fix to filter early should be ok. I also use rpt2 as a |
Looks like this has been coincidentally fixed by #451. By coincidence, this line ends up fixing this regression as well because it makes the exact same fix I outlined above 😅 . Running the repro with Will still be looking to merge in part of my branch there in order to automatically test and future-proof the |
Troubleshooting
Does
tsc
have the same output? If so, please explain why this is incorrect behaviorno
Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
matched
https://stackblitz.com/edit/rpt2-repro-h4yxsj?file=rollup.config.ts
What happens and why it is incorrect
In the
rollup.config.ts
, use theimport pkg from 'package.json'
statement, and the plug-in does not handle. and it is normal in <=v0.33.0Environment
Versions
v0.34.0
The text was updated successfully, but these errors were encountered: