Library that imports JSON file breaks the application build
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
Consuming the library containing a JSON import fails on application build with the following error (library itself is built successfully with both Ivy and ViewEngine):
ERROR in dist/library/public-api.d.ts:1:36 - error TS2307: Cannot find module './example.json' or its corresponding type declarations.
1 export { default as numbers } from './example.json';
Adding "skipLibCheck": true,
to tsconfig.base.json
silences this error. Ivy built library works fine after that, ViewEngine built library fails with following error:
ERROR in The target entry-point "library" has missing dependencies:
- ./example.json
How To Reproduce
Checkout the repository: https://github.com/klemenoslaj/ng-package-json-import
Execute: yarn && build:lib-ivy
- This works fine!
Execute: yarn && build:lib-ve
- This breaks!
Remove skipLibCheck
from tsconfig.base.json
to fail for both Ivy and ViewEngine.
Expected Behaviour
Application should successfully compile when consuming a library with imported JSON.
Version Information
ng-packagr: 10.0.3
@angular/compiler: 10.0.5
rollup: 2.22.2
tsickle:
typescript: 3.9.7
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
internal json import in a library breaks when ... - Stack Overflow
Have you tried to add a types file to your app ( typings.d.ts )? declare module '*.json' { const value: any; export default...
Read more >How to Import JSON file as a Module - Bits and Pieces
Learn how to import JSON as a module using Import Assert, a TC39 Stage 3 feature.
Read more >ng build library doesn't include json files like normal app #11931
I tried out to import the component directly in the app via public_api.ts and it will work. It also build the app including...
Read more >Working With JSON Data in Python
In this tutorial you'll learn how to read and write JSON-encoded data using Python. You'll see hands-on examples of working with Python's built-in...
Read more >Content Types - ESBuild
Imported variables are live bindings to variables in another file. They are not copies of those variables. So when esbuild bundles your code,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Are you sure? I am on a phone but i can see the resolveJsonModule in tsconfig.base.json: https://www.github.com/klemenoslaj/ng-package-json-import/tree/master/tsconfig.base.json
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
This action has been performed automatically by a bot.