Title: Ability to adjust module resolution for a 3rd party component · Issue #7287 · angular/angular-cli · GitHub
Open Graph Title: Ability to adjust module resolution for a 3rd party component · Issue #7287 · angular/angular-cli
X Title: Ability to adjust module resolution for a 3rd party component · Issue #7287 · angular/angular-cli
Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [X] feature request Versions. / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ...
Open Graph Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [X] feature request Versions. / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ ...
X Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [X] feature request Versions. / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | ...
Opengraph URL: https://github.com/angular/angular-cli/issues/7287
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Ability to adjust module resolution for a 3rd party component","articleBody":"### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [ ] bug report -> please search issues before submitting\r\n- [X] feature request\r\n```\r\n\r\n### Versions.\r\n```\r\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\r\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\r\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\r\n/_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\r\n |___/\r\n@angular/cli: 1.2.6\r\nnode: 8.1.3\r\nos: win32 x64\r\n```\r\n\r\n### Desired functionality.\r\nAliasing 3rd party javascript files. I want to use Fabric.js inside an Angular4 application. Fabric.js provides an additional Javascript file that is compatible with require. But in the package.json of the *fabric.js* module the \"main\" property points to another javascript file that is not compatible with the definitions of `@types/fabric`.\r\n\r\nAs stated in #6282 I used the `paths` field of `tsconfig.json` to redirect the module resolution to the correct file (`fabric.require.js`). But this leads to typescript not recognizing the type definitions of `@types/fabric` anymore. (See Microsoft/TypeScript#17583)\r\n\r\nOutside an angular-cli project it would be easy to fix with a single entry to webpacks `resolve.alias` configuration. Currently inside the angular project you can choose between a working application (with the entry in tsconfig) or working typechecks (without the entry).\r\n\r\n### Mention any other details that might be useful.\r\nReproduce my problem using a stock Angular Project with following modifications:\r\n\r\nMy `tsconfig.json`:\r\n```json\r\n{\r\n \"compileOnSave\": false,\r\n \"compilerOptions\": {\r\n \"outDir\": \"./dist/out-tsc\",\r\n \"baseUrl\": \"src\",\r\n \"paths\": {\r\n \"fabric\": [\r\n \"../node_modules/fabric/dist/fabric.require.js\"\r\n ]\r\n },\r\n \"sourceMap\": true,\r\n \"declaration\": false,\r\n \"moduleResolution\": \"node\",\r\n \"emitDecoratorMetadata\": true,\r\n \"experimentalDecorators\": true,\r\n \"target\": \"es5\",\r\n \"typeRoots\": [\r\n \"node_modules/@types\"\r\n ],\r\n \"lib\": [\r\n \"es2016\",\r\n \"dom\"\r\n ]\r\n }\r\n}\r\n```\r\n\r\nUsage inside `app.component.ts`:\r\n```typescript\r\nimport { Component, OnInit, ViewChild, ElementRef } from \"@angular/core\";\r\n\r\nimport * as fabric from \"fabric\";\r\n\r\n@Component({\r\n selector: \"app-root\",\r\n templateUrl: \"./app.component.html\",\r\n styleUrls: [\"./app.component.scss\"]\r\n})\r\nexport class AppComponent implements OnInit {\r\n\r\n @ViewChild(\"canvas\")\r\n public viewCanvas: ElementRef;\r\n\r\n private canvas: fabric.Canvas;\r\n\r\n public exportedSvg: string;\r\n\r\n public ngOnInit(): void {\r\n this.canvas = new fabric.Canvas(this.viewCanvas.nativeElement);\r\n\r\n // create a rectangle object\r\n const rect = new fabric.Rect({\r\n left: 100,\r\n top: 100,\r\n fill: \"red\",\r\n width: 20,\r\n height: 20,\r\n lockUniScaling: true\r\n });\r\n\r\n // \"add\" rectangle onto canvas\r\n this.canvas.add(rect);\r\n }\r\n\r\n public export(): void {\r\n this.exportedSvg = this.canvas.toSVG();\r\n }\r\n}\r\n```\r\nTypescript should complain about `this.canvas.toSVG()` as it is wrongly defined inside the typings, but it doesn't.\r\n","author":{"url":"https://github.com/WoMayr","@type":"Person","name":"WoMayr"},"datePublished":"2017-08-07T06:47:19Z","url":"https://github.com/angular/angular-cli/issues/7287"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:24bd8587-648f-723d-5814-4e7230476ed4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83EA:11EACE:39454CF:4C6A423:6B021B6A |
| html-safe-nonce | 1a5e73257e211689ee3a932de641c9ac0c9d846677e11dd9043208e15192781c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0VBOjExRUFDRTozOTQ1NENGOjRDNkE0MjM6NkIwMjFCNkEiLCJ2aXNpdG9yX2lkIjoiODI0MjA2NTc1MjQ0ODExMTE0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ac5664093eb9b59115fb220ca77be295d4b5a02e82af440dd3d7687d4dc5c8c0 |
| hovercard-subject-tag | issue:248321332 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/7287/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5c61fefc6f2c2bb63cbf6957c8082c6ff9079e2bf47dcea97c4966746371555b/angular/angular-cli/issues/7287 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5c61fefc6f2c2bb63cbf6957c8082c6ff9079e2bf47dcea97c4966746371555b/angular/angular-cli/issues/7287 |
| og:image:alt | Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [X] feature request Versions. / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | WoMayr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width