Skip to content

Commit 73fc1c5

Browse files
author
Joel Denning
authored
Adding amd dependencies example, including named-exports extra. (#11)
1 parent 1d5df1d commit 73fc1c5

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en-US">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>AMD Dependencies - SystemJS Example</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<script type="systemjs-importmap">
9+
{
10+
"imports": {
11+
"titan": "./lib/titan.js",
12+
"rxjs": "https://cdn.jsdelivr.net/npm/rxjs/bundles/rxjs.umd.min.js"
13+
}
14+
}
15+
</script>
16+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/system.js"></script>
17+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/extras/amd.js"></script>
18+
<!-- The named-exports extra is important to avoid having to rxjs.default.of() (and similar for all other rxjs functions) -->
19+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/extras/named-exports.js"></script>
20+
</head>
21+
<body>
22+
<div id="react-container"></div>
23+
<script>
24+
System.import('titan')
25+
</script>
26+
</body>
27+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
System.register(["rxjs"], function (_export, _context) {
2+
"use strict";
3+
4+
var of, from, titanFacts;
5+
return {
6+
setters: [function (_rxjs) {
7+
of = _rxjs.of;
8+
from = _rxjs.from;
9+
}],
10+
execute: function () {
11+
of("Saturn").subscribe(planet => {
12+
document.body.appendChild(Object.assign(document.createElement('p'), {
13+
textContent: `Titan is a moon orbiting ${planet}.`
14+
}));
15+
});
16+
titanFacts = ["Titan is 50% more massive than Earth's moon, and 80% more massive.", "Titan is the only moon known to have a dense atmosphere, and the only known body in space, other than Earth, where clear evidence of stable bodies of surface liquid has been found."];
17+
from(titanFacts).subscribe(fact => {
18+
document.body.appendChild(Object.assign(document.createElement('p'), {
19+
textContent: fact
20+
}));
21+
});
22+
}
23+
};
24+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "amd-dependencies",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "babel src --out-dir lib --plugins=@babel/plugin-transform-modules-systemjs"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"@babel/cli": "^7.7.5",
13+
"@babel/core": "^7.7.5",
14+
"@babel/plugin-transform-modules-systemjs": "^7.7.4"
15+
}
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { of, from } from 'rxjs';
2+
3+
of("Saturn").subscribe(
4+
planet => {
5+
document.body.appendChild(Object.assign(
6+
document.createElement('p'),
7+
{textContent: `Titan is a moon orbiting ${planet}.`}
8+
))
9+
}
10+
)
11+
12+
const titanFacts = [
13+
"Titan is 50% more massive than Earth's moon, and 80% more massive.",
14+
"Titan is the only moon known to have a dense atmosphere, and the only known body in space, other than Earth, where clear evidence of stable bodies of surface liquid has been found."
15+
];
16+
17+
from(titanFacts).subscribe(
18+
fact => {
19+
document.body.appendChild(Object.assign(
20+
document.createElement('p'),
21+
{textContent: fact}
22+
))
23+
}
24+
);

0 commit comments

Comments
 (0)