├── .gitignore
├── 404.html
├── LICENSE
├── README.md
├── index.html
├── loading-code
├── amd-modules
│ ├── index.html
│ ├── lib
│ │ ├── neptune.js
│ │ └── saturn.js
│ ├── package.json
│ └── src
│ │ ├── neptune.js
│ │ └── saturn.js
├── react-hello-world
│ ├── .babelrc
│ ├── README.md
│ ├── dist
│ │ ├── react-hello-world.js
│ │ └── react-hello-world.js.map
│ ├── index.html
│ ├── package.json
│ └── src
│ │ └── react-hello-world.js
├── typescript-default-extension
│ ├── dist
│ │ ├── helpers
│ │ │ ├── planet-helpers.js
│ │ │ └── planet-helpers.js.map
│ │ ├── planets.js
│ │ ├── planets.js.map
│ │ ├── systemjs-hooks
│ │ │ ├── resolve.js
│ │ │ └── resolve.js.map
│ │ ├── typescript-example.js
│ │ └── typescript-example.js.map
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── helpers
│ │ │ └── planet-helpers.ts
│ │ ├── planets.ts
│ │ ├── systemjs-hooks
│ │ │ └── resolve.ts
│ │ └── typescript-example.ts
│ └── tsconfig.json
└── typescript
│ ├── dist
│ ├── typescript-example.js
│ └── typescript-example.js.map
│ ├── index.html
│ ├── package.json
│ ├── src
│ └── typescript-example.ts
│ └── tsconfig.json
├── loading-dependencies
├── amd-dependencies
│ ├── index.html
│ ├── lib
│ │ └── titan.js
│ ├── package.json
│ └── src
│ │ └── titan.js
└── webpack-externals
│ ├── dist
│ ├── bundle.js
│ └── bundle.js.map
│ ├── index.html
│ ├── package.json
│ ├── src
│ └── entry.js
│ └── webpack.config.js
├── optimized-builds
├── basic-webpack
│ ├── dist
│ │ ├── bundle.js
│ │ └── bundle.js.map
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ └── entry.js
│ └── webpack.config.js
└── webpack-code-splits
│ ├── dist
│ ├── 0.bundle.js
│ ├── 0.bundle.js.map
│ ├── bundle.js
│ └── bundle.js.map
│ ├── index.html
│ ├── package.json
│ ├── src
│ ├── entry.js
│ ├── sentient-aliens.js
│ └── set-public-path.js
│ └── webpack.config.js
├── starter-kits
└── .gitkeep
└── systemjs-features
├── basic-import-map
├── index.html
└── mercury.js
├── dynamic-import
├── index.html
├── neptune.js
└── triton.js
├── import-map-scopes
├── dep-v1.js
├── dep-v2.js
├── index.html
└── main
│ └── main.js
└── nodejs-loader
├── README.md
├── antarctica.js
├── index.html
├── index.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | package-lock.json
4 | .vscode
--------------------------------------------------------------------------------
/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | SystemJS examples
8 |
9 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2019 Guy Bedford
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # systemjs-examples
2 |
3 | Examples demonstrating various use cases with SystemJS.
4 |
5 | ## Live demo
6 |
7 | [Live demo](https://systemjs.github.io/systemjs-examples/)
8 |
9 | ## Running locally
10 |
11 | After cloning the repo, run the following in the root directory:
12 | ```sh
13 | git clone https://github.com/systemjs/systemjs-examples.git
14 | cd systemjs-examples
15 |
16 | npx serve
17 | ```
18 |
19 | ## Contributing
20 |
21 | Please adhere to the following guidelines:
22 |
23 | 1. Do not require an npm install or build step for running locally or for github pages deployment. This means you should push all built files to github and update the built files every time you change the source files.
24 | 2. Please follow the directory structure that is already established. Each example should be a directory with a descriptive name. The example directory must contain an index.html file.
25 | 3. Please do not lock your example to a specific version of system.js or s.js. You can link to the latest version of system.js and its extras with `https://cdn.jsdelivr.net/npm/systemjs/dist/system.js`.
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SystemJS examples
7 |
8 |
13 |
14 |
15 | SystemJS Examples
16 |
17 | This website is a live demo of a variety of SystemJS applications and use cases.
18 |
19 |
41 |
42 |
--------------------------------------------------------------------------------
/loading-code/amd-modules/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AMD Modules - SystemJS Example
7 |
8 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/loading-code/amd-modules/lib/neptune.js:
--------------------------------------------------------------------------------
1 | define(["exports"], function (_exports) {
2 | "use strict";
3 |
4 | Object.defineProperty(_exports, "__esModule", {
5 | value: true
6 | });
7 | _exports.showDistanceFromSun = showDistanceFromSun;
8 |
9 | function showDistanceFromSun() {
10 | document.body.appendChild(Object.assign(document.createElement('p'), {
11 | textContent: "Neptune is 4,503,443,661 km from the Sun, on average."
12 | }));
13 | }
14 | });
--------------------------------------------------------------------------------
/loading-code/amd-modules/lib/saturn.js:
--------------------------------------------------------------------------------
1 | define(["./neptune.js"], function (neptune) {
2 | "use strict";
3 |
4 | neptune = _interopRequireWildcard(neptune);
5 |
6 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
7 |
8 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9 |
10 | document.body.appendChild(Object.assign(document.createElement('p'), {
11 | textContent: "Saturn is 1,433,449,370 km from the Sun, on average."
12 | }));
13 | neptune.showDistanceFromSun();
14 | });
--------------------------------------------------------------------------------
/loading-code/amd-modules/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "amd-modules",
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-amd"
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-amd": "^7.7.5"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/loading-code/amd-modules/src/neptune.js:
--------------------------------------------------------------------------------
1 | export function showDistanceFromSun() {
2 | document.body.appendChild(Object.assign(
3 | document.createElement('p'),
4 | {textContent: "Neptune is 4,503,443,661 km from the Sun, on average."}
5 | ));
6 | }
--------------------------------------------------------------------------------
/loading-code/amd-modules/src/saturn.js:
--------------------------------------------------------------------------------
1 | import * as neptune from './neptune.js'
2 |
3 | document.body.appendChild(Object.assign(
4 | document.createElement('p'),
5 | {textContent: "Saturn is 1,433,449,370 km from the Sun, on average."}
6 | ));
7 |
8 | neptune.showDistanceFromSun();
--------------------------------------------------------------------------------
/loading-code/react-hello-world/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/preset-react",
4 | ],
5 | "plugins": [
6 | "@babel/plugin-transform-modules-systemjs"
7 | ],
8 | }
--------------------------------------------------------------------------------
/loading-code/react-hello-world/README.md:
--------------------------------------------------------------------------------
1 | # react-hello-world
2 |
3 | The react-hello-world example demonstrates the following:
4 |
5 | - Loading React and ReactDOM from a CDN. This is accomplished with an import map and allows for multiple modules to share the same React instance.
6 | - Using [Babel CLI](https://babeljs.io/docs/en/babel-cli) to compile all modules in the `src` directory into the `dist` directory using the [System.register format](https://github.com/systemjs/systemjs/blob/master/docs/system-register.md). This is done with the [`@babel/plugin-transform-modules-systemjs`](https://babeljs.io/docs/en/babel-plugin-transform-modules-systemjs) plugin.
7 | - Loading javascript modules with `
16 |
17 |
18 |
19 |
20 |
21 |
22 |