You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When upgrading from preconstruct 2.2.2 to 2.8.1 our builds fail when json files are part of the project. The output from preconstruct is as follows:
> yarn preconstruct build
🎁 error Generating TypeScript declarations for packages/datalog/src/translations/datalogTranslations.en.json failed:
🎁 error
🎁 info If you want to learn more about the above error, check https://preconstruct.tools/errors
🎁 info If the error is not there and you want to learn more about it, open an issue at https://github.com/preconstruct/preconstruct/issues/new
The failure is due to the following line in the rollup plugin:
In preconstruct 2.2.2 the build would pass and the json data would be available from the main entrypoint (which is where the data was exported in my specific usecase). However, looking at the .d.ts files produced by preconstruct 2.2.2 I see it's importing the type definition for the json files by importing the json file directly (which is exactly how TypeScript handles this anyway). The json files however are not part of the package, so the type definitions for the json files are missing either way.
Regardless of the fact it wasn't perfect in preconstruct 2.2.2, the current state prevents us from building packages with newer preconstruct at all. I'm also fully aware I can replace the json files with ts files, but this is related to tooling (as you can see from the error it's about translation files). My guess is json files would need a bit of specific handling, just as TypeScript is explicitly handling json files (so yes, the situation is not great either way).
I did notice that if TypeScript declarationDir is different from outDir that the paths for josn files referenced in index.d.ts (or whatever the importing file would be) are actually pointing to the path relative to outDir, because the json files are not copied to declarationDir as well. I'm not even sure if this is properly consumed by TypeScript, but that's of course not a preconstruct issue. It probably will 'hurt' preconstruct though because the declarationDir is always separate.
Please let me know if you're open to adding support for handling json files. In that case I might be able to implement the support myself, but if you don't want to include explicit json file handling I won't attempt it.
The text was updated successfully, but these errors were encountered:
When upgrading from preconstruct 2.2.2 to 2.8.1 our builds fail when json files are part of the project. The output from preconstruct is as follows:
The failure is due to the following line in the rollup plugin:
I think this is the result of the decision in TypeScript not to emit .d.ts for json files.
In preconstruct 2.2.2 the build would pass and the json data would be available from the main entrypoint (which is where the data was exported in my specific usecase). However, looking at the .d.ts files produced by preconstruct 2.2.2 I see it's importing the type definition for the json files by importing the json file directly (which is exactly how TypeScript handles this anyway). The json files however are not part of the package, so the type definitions for the json files are missing either way.
Regardless of the fact it wasn't perfect in preconstruct 2.2.2, the current state prevents us from building packages with newer preconstruct at all. I'm also fully aware I can replace the json files with ts files, but this is related to tooling (as you can see from the error it's about translation files). My guess is json files would need a bit of specific handling, just as TypeScript is explicitly handling json files (so yes, the situation is not great either way).
I did notice that if TypeScript
declarationDir
is different fromoutDir
that the paths for josn files referenced inindex.d.ts
(or whatever the importing file would be) are actually pointing to the path relative tooutDir
, because the json files are not copied todeclarationDir
as well. I'm not even sure if this is properly consumed by TypeScript, but that's of course not a preconstruct issue. It probably will 'hurt' preconstruct though because thedeclarationDir
is always separate.Please let me know if you're open to adding support for handling json files. In that case I might be able to implement the support myself, but if you don't want to include explicit json file handling I won't attempt it.
The text was updated successfully, but these errors were encountered: