-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to specify a jsx compiler option in the ng-package.json schema. This allows for libraries to bundle tsx/jsx files, and take depedencies on vendors like React components
- Loading branch information
1 parent
918766d
commit 4068664
Showing
13 changed files
with
226 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "../../../src/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public_api.ts", | ||
"externals": { | ||
"react": "React", | ||
"react-dom": "ReactDOM" | ||
}, | ||
"jsx": "react" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "@sample/jsx", | ||
"description": "A sample library with jsx/tsx dependencies.", | ||
"version": "1.0.0-pre.0", | ||
"private": true, | ||
"repository": "https://github.com/dherges/ng-packagr.git", | ||
"peerDependencies": { | ||
"@angular/common": "^4.1.3", | ||
"@angular/core": "^4.1.3", | ||
"@angular/router": "^4.1.3", | ||
"rxjs": "^5.0.1", | ||
"zone.js": "^0.8.4", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './src/react-integration.component'; | ||
export * from './src/react-integration.module'; |
34 changes: 34 additions & 0 deletions
34
integration/samples/jsx/src/react-integration.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Component, OnInit, AfterViewInit, ElementRef } from '@angular/core'; | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
// Simulating the use of an external library that contains React Components | ||
class ReactLabel extends React.Component { | ||
render() { | ||
return ( | ||
<label>Look JSX!</label> | ||
); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'react-integration-test', | ||
template: ` | ||
<div></div> | ||
`, | ||
styles: [``] | ||
}) | ||
export class AngularReactLabel implements AfterViewInit { | ||
|
||
constructor(private hostRef: ElementRef) {} | ||
|
||
ngAfterViewInit(): void { | ||
const hostElement = this.hostRef.nativeElement; | ||
const LabelToShow = () => ( | ||
// Actual use here, might include data-binding in a real world scenario | ||
<ReactLabel></ReactLabel> | ||
); | ||
ReactDOM.render(<LabelToShow />, hostElement); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { AngularReactLabel } from './react-integration.component'; | ||
|
||
@NgModule({ | ||
declarations: [ AngularReactLabel ], | ||
imports: [ CommonModule ], | ||
exports: [ AngularReactLabel ], | ||
providers: [], | ||
}) | ||
export class ReactIntegrationModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ | |
"mocha", | ||
"node", | ||
"sinon" | ||
] | ||
], | ||
"jsx": "react" | ||
}, | ||
"exclude": [ | ||
"dist", | ||
|
Oops, something went wrong.