├── .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 | -------------------------------------------------------------------------------- /loading-code/react-hello-world/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-hello-world", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "build": "babel src --out-dir dist --source-maps" 6 | }, 7 | "license": "MIT", 8 | "devDependencies": { 9 | "@babel/cli": "^7.6.0", 10 | "@babel/core": "^7.6.2", 11 | "@babel/plugin-transform-modules-systemjs": "^7.5.0", 12 | "@babel/preset-react": "^7.0.0" 13 | }, 14 | "dependencies": {} 15 | } 16 | -------------------------------------------------------------------------------- /loading-code/react-hello-world/src/react-hello-world.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | ReactDOM.render(, document.getElementById('react-root')); -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/helpers/planet-helpers.js: -------------------------------------------------------------------------------- 1 | System.register(["../planets"], function (exports_1, context_1) { 2 | "use strict"; 3 | var planets_1; 4 | var __moduleName = context_1 && context_1.id; 5 | function isPlanet(planetName) { 6 | if (planets_1.RealPlanets[planetName]) { 7 | console.log(`${planetName} is a planet!`); 8 | return true; 9 | } 10 | else if (planets_1.NotRealPlanets[planetName]) { 11 | console.log(`${planetName} is not a planet!`); 12 | return false; 13 | } 14 | else { 15 | throw Error(`Unknown planetName ${planetName}`); 16 | } 17 | } 18 | exports_1("isPlanet", isPlanet); 19 | return { 20 | setters: [ 21 | function (planets_1_1) { 22 | planets_1 = planets_1_1; 23 | } 24 | ], 25 | execute: function () { 26 | } 27 | }; 28 | }); 29 | //# sourceMappingURL=planet-helpers.js.map -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/helpers/planet-helpers.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"planet-helpers.js","sourceRoot":"","sources":["../../src/helpers/planet-helpers.ts"],"names":[],"mappings":";;;;IAEA,SAAgB,QAAQ,CAAC,UAA+B;QACtD,IAAI,qBAAW,CAAC,UAAU,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,eAAe,CAAC,CAAA;YACzC,OAAO,IAAI,CAAA;SACZ;aAAM,IAAI,wBAAc,CAAC,UAAU,CAAC,EAAE;YACrC,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,mBAAmB,CAAC,CAAA;YAC7C,OAAO,KAAK,CAAA;SACb;aAAM;YACL,MAAM,KAAK,CAAC,sBAAsB,UAAU,EAAE,CAAC,CAAA;SAChD;IACH,CAAC;;;;;;;;;QACD,CAAC"} -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/planets.js: -------------------------------------------------------------------------------- 1 | System.register([], function (exports_1, context_1) { 2 | "use strict"; 3 | var RealPlanets, NotRealPlanets; 4 | var __moduleName = context_1 && context_1.id; 5 | return { 6 | setters: [], 7 | execute: function () { 8 | (function (RealPlanets) { 9 | RealPlanets["Mercury"] = "Mercury"; 10 | RealPlanets["Venus"] = "Venus"; 11 | RealPlanets["Earth"] = "Earth"; 12 | RealPlanets["Mars"] = "Mars"; 13 | RealPlanets["Jupiter"] = "Jupiter"; 14 | RealPlanets["Saturn"] = "Saturn"; 15 | RealPlanets["Uranus"] = "Uranus"; 16 | RealPlanets["Neptune"] = "Neptune"; 17 | })(RealPlanets || (RealPlanets = {})); 18 | exports_1("RealPlanets", RealPlanets); 19 | (function (NotRealPlanets) { 20 | NotRealPlanets["Pluto"] = "Pluto"; 21 | })(NotRealPlanets || (NotRealPlanets = {})); 22 | exports_1("NotRealPlanets", NotRealPlanets); 23 | } 24 | }; 25 | }); 26 | //# sourceMappingURL=planets.js.map -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/planets.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"planets.js","sourceRoot":"","sources":["../src/planets.ts"],"names":[],"mappings":";;;;;;;YAGA,WAAY,WAAW;gBACrB,kCAAmB,CAAA;gBACnB,8BAAe,CAAA;gBACf,8BAAe,CAAA;gBACf,4BAAa,CAAA;gBACb,kCAAmB,CAAA;gBACnB,gCAAiB,CAAA;gBACjB,gCAAiB,CAAA;gBACjB,kCAAmB,CAAA;YACrB,CAAC,EATW,WAAW,KAAX,WAAW,QAStB;;YAED,WAAY,cAAc;gBACxB,iCAAe,CAAA;YACjB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;;QACD,CAAC"} -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/systemjs-hooks/resolve.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | const endsWithFileExtension = /\/?\.[a-zA-Z]{2,}$/; 3 | const originalResolve = System.constructor.prototype.resolve; 4 | System.constructor.prototype.resolve = function () { 5 | // apply original resolve to make sure importmaps are resolved first 6 | const url = originalResolve.apply(this, arguments); 7 | // append .js file extension if url is missing a file extension 8 | return endsWithFileExtension.test(url) ? url : url + ".js"; 9 | }; 10 | })(); 11 | //# sourceMappingURL=resolve.js.map -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/systemjs-hooks/resolve.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/systemjs-hooks/resolve.ts"],"names":[],"mappings":"AAAA,CAAC;IACC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;IACnD,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC;IAC7D,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG;QACrC,oEAAoE;QACpE,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnD,+DAA+D;QAC/D,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"} -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/typescript-example.js: -------------------------------------------------------------------------------- 1 | System.register(["lodash", "./helpers/planet-helpers", "./planets"], function (exports_1, context_1) { 2 | "use strict"; 3 | var lodash_1, planet_helpers_1, planets_1; 4 | var __moduleName = context_1 && context_1.id; 5 | return { 6 | setters: [ 7 | function (lodash_1_1) { 8 | lodash_1 = lodash_1_1; 9 | }, 10 | function (planet_helpers_1_1) { 11 | planet_helpers_1 = planet_helpers_1_1; 12 | }, 13 | function (planets_1_1) { 14 | planets_1 = planets_1_1; 15 | } 16 | ], 17 | execute: function () { 18 | document.body.appendChild(Object.assign(document.createElement('p'), { 19 | textContent: 'Pluto is no longer considered a planet. (Check you console for more information).' 20 | })); 21 | /* In a browser console, you can use the isPlanet function with the following code: 22 | 23 | System.import('planet-checker').then(planetChecker => { 24 | const isPlanet = planetChecker.isPlanet('thing'); 25 | }) 26 | 27 | */ 28 | // Planet operations 29 | planet_helpers_1.isPlanet(planets_1.RealPlanets.Earth); 30 | planet_helpers_1.isPlanet(planets_1.NotRealPlanets.Pluto); 31 | // Just a demonstration that lodash is available, since the systemjs-importmap in index.html 32 | // specifies where to fetch lodash 33 | console.log('Real Planets'); 34 | lodash_1.default.each(planets_1.RealPlanets, planet => console.log(planet)); 35 | } 36 | }; 37 | }); 38 | //# sourceMappingURL=typescript-example.js.map -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/dist/typescript-example.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"typescript-example.js","sourceRoot":"","sources":["../src/typescript-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;YAKA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;gBACnE,WAAW,EAAE,mFAAmF;aACjG,CAAC,CAAC,CAAA;YAEH;;;;;;cAME;YAEF,oBAAoB;YACpB,yBAAQ,CAAC,qBAAW,CAAC,KAAK,CAAC,CAAA;YAC3B,yBAAQ,CAAC,wBAAc,CAAC,KAAK,CAAC,CAAA;YAE9B,4FAA4F;YAC5F,kCAAkC;YAClC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;YAC3B,gBAAC,CAAC,IAAI,CAAC,qBAAW,EAAE,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;QAClD,CAAC"} -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Basic Typescript SystemJS Example 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-default-extension-example", 3 | "scripts": { 4 | "build": "tsc" 5 | }, 6 | "devDependencies": { 7 | "@types/lodash": "^4.14.149", 8 | "@types/systemjs": "^6.1.0", 9 | "typescript": "^3.8.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/src/helpers/planet-helpers.ts: -------------------------------------------------------------------------------- 1 | import { InterstellarObjects, NotRealPlanets, RealPlanets } from '../planets' 2 | 3 | export function isPlanet(planetName: InterstellarObjects) { 4 | if (RealPlanets[planetName]) { 5 | console.log(`${planetName} is a planet!`) 6 | return true 7 | } else if (NotRealPlanets[planetName]) { 8 | console.log(`${planetName} is not a planet!`) 9 | return false 10 | } else { 11 | throw Error(`Unknown planetName ${planetName}`) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/src/planets.ts: -------------------------------------------------------------------------------- 1 | 2 | export type InterstellarObjects = RealPlanets | NotRealPlanets 3 | 4 | export enum RealPlanets { 5 | Mercury = 'Mercury', 6 | Venus = 'Venus', 7 | Earth = 'Earth', 8 | Mars = 'Mars', 9 | Jupiter = 'Jupiter', 10 | Saturn = 'Saturn', 11 | Uranus = 'Uranus', 12 | Neptune = 'Neptune', 13 | } 14 | 15 | export enum NotRealPlanets { 16 | Pluto = 'Pluto', 17 | } 18 | -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/src/systemjs-hooks/resolve.ts: -------------------------------------------------------------------------------- 1 | (function () { 2 | const endsWithFileExtension = /\/?\.[a-zA-Z]{2,}$/; 3 | const originalResolve = System.constructor.prototype.resolve; 4 | System.constructor.prototype.resolve = function () { 5 | // apply original resolve to make sure importmaps are resolved first 6 | const url = originalResolve.apply(this, arguments); 7 | // append .js file extension if url is missing a file extension 8 | return endsWithFileExtension.test(url) ? url : url + ".js"; 9 | }; 10 | })(); -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/src/typescript-example.ts: -------------------------------------------------------------------------------- 1 | import _ from 'lodash'; 2 | 3 | import { isPlanet } from './helpers/planet-helpers'; 4 | import { RealPlanets, NotRealPlanets } from './planets'; 5 | 6 | document.body.appendChild(Object.assign(document.createElement('p'), { 7 | textContent: 'Pluto is no longer considered a planet. (Check you console for more information).' 8 | })) 9 | 10 | /* In a browser console, you can use the isPlanet function with the following code: 11 | 12 | System.import('planet-checker').then(planetChecker => { 13 | const isPlanet = planetChecker.isPlanet('thing'); 14 | }) 15 | 16 | */ 17 | 18 | // Planet operations 19 | isPlanet(RealPlanets.Earth) 20 | isPlanet(NotRealPlanets.Pluto) 21 | 22 | // Just a demonstration that lodash is available, since the systemjs-importmap in index.html 23 | // specifies where to fetch lodash 24 | console.log('Real Planets') 25 | _.each(RealPlanets, planet => console.log(planet)) 26 | -------------------------------------------------------------------------------- /loading-code/typescript-default-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "sourceMap": true, 5 | "target": "es2015", 6 | "module": "system", 7 | "lib": ["es2015", "dom"] 8 | } 9 | } -------------------------------------------------------------------------------- /loading-code/typescript/dist/typescript-example.js: -------------------------------------------------------------------------------- 1 | System.register([], function (exports_1, context_1) { 2 | "use strict"; 3 | var RealPlanets, NotRealPlanets; 4 | var __moduleName = context_1 && context_1.id; 5 | /* In a browser console, you can use the isPlanet function with the following code: 6 | 7 | System.import('planet-checker').then(planetChecker => { 8 | const isPlanet = planetChecker.isPlanet('thing'); 9 | }) 10 | 11 | */ 12 | function isPlanet(planetName) { 13 | if (RealPlanets[planetName]) { 14 | console.log(`${planetName} is a planet!`); 15 | return true; 16 | } 17 | else if (NotRealPlanets[planetName]) { 18 | console.log(`${planetName} is not a planet!`); 19 | return false; 20 | } 21 | else { 22 | throw Error(`Unknown planetName ${planetName}`); 23 | } 24 | } 25 | exports_1("isPlanet", isPlanet); 26 | return { 27 | setters: [], 28 | execute: function () { 29 | document.body.appendChild(Object.assign(document.createElement('p'), { 30 | textContent: 'Pluto is no longer considered a planet.' 31 | })); 32 | (function (RealPlanets) { 33 | RealPlanets["Mercury"] = "Mercury"; 34 | RealPlanets["Venus"] = "Venus"; 35 | RealPlanets["Earth"] = "Earth"; 36 | RealPlanets["Mars"] = "Mars"; 37 | RealPlanets["Jupiter"] = "Jupiter"; 38 | RealPlanets["Saturn"] = "Saturn"; 39 | RealPlanets["Uranus"] = "Uranus"; 40 | RealPlanets["Neptune"] = "Neptune"; 41 | })(RealPlanets || (RealPlanets = {})); 42 | (function (NotRealPlanets) { 43 | NotRealPlanets["Pluto"] = "Pluto"; 44 | })(NotRealPlanets || (NotRealPlanets = {})); 45 | isPlanet(RealPlanets.Earth); 46 | isPlanet(NotRealPlanets.Pluto); 47 | } 48 | }; 49 | }); 50 | //# sourceMappingURL=typescript-example.js.map -------------------------------------------------------------------------------- /loading-code/typescript/dist/typescript-example.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"typescript-example.js","sourceRoot":"","sources":["../src/typescript-example.ts"],"names":[],"mappings":";;;;IAIA;;;;;;MAME;IAEF,SAAgB,QAAQ,CAAC,UAA+B;QACtD,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,eAAe,CAAC,CAAA;YACzC,OAAO,IAAI,CAAA;SACZ;aAAM,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;YACrC,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,mBAAmB,CAAC,CAAA;YAC7C,OAAO,KAAK,CAAA;SACb;aAAM;YACL,MAAM,KAAK,CAAC,sBAAsB,UAAU,EAAE,CAAC,CAAA;SAChD;IACH,CAAC;;;;;YAtBD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;gBACnE,WAAW,EAAE,yCAAyC;aACvD,CAAC,CAAC,CAAA;YAwBH,WAAK,WAAW;gBACd,kCAAmB,CAAA;gBACnB,8BAAe,CAAA;gBACf,8BAAe,CAAA;gBACf,4BAAa,CAAA;gBACb,kCAAmB,CAAA;gBACnB,gCAAiB,CAAA;gBACjB,gCAAiB,CAAA;gBACjB,kCAAmB,CAAA;YACrB,CAAC,EATI,WAAW,KAAX,WAAW,QASf;YAED,WAAK,cAAc;gBACjB,iCAAe,CAAA;YACjB,CAAC,EAFI,cAAc,KAAd,cAAc,QAElB;YAED,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAC3B,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QAAA,CAAC"} -------------------------------------------------------------------------------- /loading-code/typescript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Basic Webpack SystemJS Example 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /loading-code/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-example", 3 | "scripts": { 4 | "build": "tsc" 5 | }, 6 | "devDependencies": { 7 | "typescript": "^3.6.4" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /loading-code/typescript/src/typescript-example.ts: -------------------------------------------------------------------------------- 1 | document.body.appendChild(Object.assign(document.createElement('p'), { 2 | textContent: 'Pluto is no longer considered a planet.' 3 | })) 4 | 5 | /* In a browser console, you can use the isPlanet function with the following code: 6 | 7 | System.import('planet-checker').then(planetChecker => { 8 | const isPlanet = planetChecker.isPlanet('thing'); 9 | }) 10 | 11 | */ 12 | 13 | export function isPlanet(planetName: InterstellarObjects) { 14 | if (RealPlanets[planetName]) { 15 | console.log(`${planetName} is a planet!`) 16 | return true 17 | } else if (NotRealPlanets[planetName]) { 18 | console.log(`${planetName} is not a planet!`) 19 | return false 20 | } else { 21 | throw Error(`Unknown planetName ${planetName}`) 22 | } 23 | } 24 | 25 | type InterstellarObjects = RealPlanets | NotRealPlanets 26 | 27 | enum RealPlanets { 28 | Mercury = 'Mercury', 29 | Venus = 'Venus', 30 | Earth = 'Earth', 31 | Mars = 'Mars', 32 | Jupiter = 'Jupiter', 33 | Saturn = 'Saturn', 34 | Uranus = 'Uranus', 35 | Neptune = 'Neptune', 36 | } 37 | 38 | enum NotRealPlanets { 39 | Pluto = 'Pluto', 40 | } 41 | 42 | isPlanet(RealPlanets.Earth) 43 | isPlanet(NotRealPlanets.Pluto) -------------------------------------------------------------------------------- /loading-code/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "sourceMap": true, 5 | "target": "es2015", 6 | "module": "system", 7 | "lib": ["es2015", "dom"] 8 | } 9 | } -------------------------------------------------------------------------------- /loading-dependencies/amd-dependencies/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | AMD Dependencies - SystemJS Example 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 26 | 27 | -------------------------------------------------------------------------------- /loading-dependencies/amd-dependencies/lib/titan.js: -------------------------------------------------------------------------------- 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 | }); -------------------------------------------------------------------------------- /loading-dependencies/amd-dependencies/package.json: -------------------------------------------------------------------------------- 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 | } 17 | -------------------------------------------------------------------------------- /loading-dependencies/amd-dependencies/src/titan.js: -------------------------------------------------------------------------------- 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 | ); -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/dist/bundle.js: -------------------------------------------------------------------------------- 1 | System.register(["vue"], function(__WEBPACK_DYNAMIC_EXPORT__) { 2 | var __WEBPACK_EXTERNAL_MODULE_vue__; 3 | return { 4 | setters: [ 5 | function(module) { 6 | __WEBPACK_EXTERNAL_MODULE_vue__ = module; 7 | } 8 | ], 9 | execute: function() { 10 | __WEBPACK_DYNAMIC_EXPORT__( 11 | /******/ (function(modules) { // webpackBootstrap 12 | /******/ // The module cache 13 | /******/ var installedModules = {}; 14 | /******/ 15 | /******/ // The require function 16 | /******/ function __webpack_require__(moduleId) { 17 | /******/ 18 | /******/ // Check if module is in cache 19 | /******/ if(installedModules[moduleId]) { 20 | /******/ return installedModules[moduleId].exports; 21 | /******/ } 22 | /******/ // Create a new module (and put it into the cache) 23 | /******/ var module = installedModules[moduleId] = { 24 | /******/ i: moduleId, 25 | /******/ l: false, 26 | /******/ exports: {} 27 | /******/ }; 28 | /******/ 29 | /******/ // Execute the module function 30 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31 | /******/ 32 | /******/ // Flag the module as loaded 33 | /******/ module.l = true; 34 | /******/ 35 | /******/ // Return the exports of the module 36 | /******/ return module.exports; 37 | /******/ } 38 | /******/ 39 | /******/ 40 | /******/ // expose the modules object (__webpack_modules__) 41 | /******/ __webpack_require__.m = modules; 42 | /******/ 43 | /******/ // expose the module cache 44 | /******/ __webpack_require__.c = installedModules; 45 | /******/ 46 | /******/ // define getter function for harmony exports 47 | /******/ __webpack_require__.d = function(exports, name, getter) { 48 | /******/ if(!__webpack_require__.o(exports, name)) { 49 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 50 | /******/ } 51 | /******/ }; 52 | /******/ 53 | /******/ // define __esModule on exports 54 | /******/ __webpack_require__.r = function(exports) { 55 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 56 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 57 | /******/ } 58 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 59 | /******/ }; 60 | /******/ 61 | /******/ // create a fake namespace object 62 | /******/ // mode & 1: value is a module id, require it 63 | /******/ // mode & 2: merge all properties of value into the ns 64 | /******/ // mode & 4: return value when already ns object 65 | /******/ // mode & 8|1: behave like require 66 | /******/ __webpack_require__.t = function(value, mode) { 67 | /******/ if(mode & 1) value = __webpack_require__(value); 68 | /******/ if(mode & 8) return value; 69 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 70 | /******/ var ns = Object.create(null); 71 | /******/ __webpack_require__.r(ns); 72 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 73 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 74 | /******/ return ns; 75 | /******/ }; 76 | /******/ 77 | /******/ // getDefaultExport function for compatibility with non-harmony modules 78 | /******/ __webpack_require__.n = function(module) { 79 | /******/ var getter = module && module.__esModule ? 80 | /******/ function getDefault() { return module['default']; } : 81 | /******/ function getModuleExports() { return module; }; 82 | /******/ __webpack_require__.d(getter, 'a', getter); 83 | /******/ return getter; 84 | /******/ }; 85 | /******/ 86 | /******/ // Object.prototype.hasOwnProperty.call 87 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 88 | /******/ 89 | /******/ // __webpack_public_path__ 90 | /******/ __webpack_require__.p = ""; 91 | /******/ 92 | /******/ 93 | /******/ // Load entry module and return exports 94 | /******/ return __webpack_require__(__webpack_require__.s = "./src/entry.js"); 95 | /******/ }) 96 | /************************************************************************/ 97 | /******/ ({ 98 | 99 | /***/ "./src/entry.js": 100 | /*!**********************!*\ 101 | !*** ./src/entry.js ***! 102 | \**********************/ 103 | /*! no exports provided */ 104 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 105 | 106 | "use strict"; 107 | __webpack_require__.r(__webpack_exports__); 108 | /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "vue"); 109 | /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); 110 | 111 | 112 | console.log('Vue', vue__WEBPACK_IMPORTED_MODULE_0___default.a); 113 | 114 | const App = vue__WEBPACK_IMPORTED_MODULE_0___default.a.default.extend({ 115 | template: '

Jupiter has {{numMoons}} moons', 116 | data: () => ({ 117 | numMoons: 79, 118 | }) 119 | }); 120 | 121 | new App().$mount('#vue-container'); 122 | 123 | /***/ }), 124 | 125 | /***/ "vue": 126 | /*!**********************!*\ 127 | !*** external "vue" ***! 128 | \**********************/ 129 | /*! no static exports found */ 130 | /***/ (function(module, exports) { 131 | 132 | module.exports = __WEBPACK_EXTERNAL_MODULE_vue__; 133 | 134 | /***/ }) 135 | 136 | /******/ }) 137 | ); 138 | } 139 | }; 140 | }); 141 | //# sourceMappingURL=bundle.js.map -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/dist/bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/entry.js","webpack:///external \"vue\""],"names":[],"mappings":";;;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFA;AAAA;AAAA;AAAsB;;AAEtB,mBAAmB,0CAAG;;AAEtB,YAAY,0CAAG;AACf,8BAA8B,UAAU;AACxC;AACA;AACA,GAAG;AACH,CAAC;;AAED,mC;;;;;;;;;;;ACXA,iD","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/entry.js\");\n","import Vue from 'vue';\n\nconsole.log('Vue', Vue);\n\nconst App = Vue.default.extend({\n template: '

Jupiter has {{numMoons}} moons',\n data: () => ({\n numMoons: 79,\n })\n});\n\nnew App().$mount('#vue-container');","module.exports = __WEBPACK_EXTERNAL_MODULE_vue__;"],"sourceRoot":""} -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Webpack Externals - SystemJS Example 7 | 8 | 16 | 17 | 18 | 19 | 20 |

21 | 24 | 25 | -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-externals", 3 | "scripts": { 4 | "build": "webpack" 5 | }, 6 | "license": "MIT", 7 | "devDependencies": { 8 | "clean-webpack-plugin": "^3.0.0", 9 | "webpack": "^4.41.2", 10 | "webpack-cli": "^3.3.10" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/src/entry.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | console.log('Vue', Vue); 4 | 5 | const App = Vue.default.extend({ 6 | template: '

Jupiter has {{numMoons}} moons', 7 | data: () => ({ 8 | numMoons: 79, 9 | }) 10 | }); 11 | 12 | new App().$mount('#vue-container'); -------------------------------------------------------------------------------- /loading-dependencies/webpack-externals/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { CleanWebpackPlugin } = require('clean-webpack-plugin') 3 | 4 | module.exports = { 5 | entry: path.resolve(__dirname, 'src/entry.js'), 6 | mode: 'development', 7 | output: { 8 | filename: 'bundle.js', 9 | path: path.resolve(__dirname, 'dist'), 10 | libraryTarget: 'system', 11 | }, 12 | devtool: 'sourcemap', 13 | plugins: [new CleanWebpackPlugin()], 14 | // Webpack externals will be shared across bundles and come from the import map and systemjs 15 | externals: ['vue', 'vue-router'], 16 | }; -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/dist/bundle.js: -------------------------------------------------------------------------------- 1 | System.register([], function(__WEBPACK_DYNAMIC_EXPORT__) { 2 | 3 | return { 4 | 5 | execute: function() { 6 | __WEBPACK_DYNAMIC_EXPORT__( 7 | /******/ (function(modules) { // webpackBootstrap 8 | /******/ // The module cache 9 | /******/ var installedModules = {}; 10 | /******/ 11 | /******/ // The require function 12 | /******/ function __webpack_require__(moduleId) { 13 | /******/ 14 | /******/ // Check if module is in cache 15 | /******/ if(installedModules[moduleId]) { 16 | /******/ return installedModules[moduleId].exports; 17 | /******/ } 18 | /******/ // Create a new module (and put it into the cache) 19 | /******/ var module = installedModules[moduleId] = { 20 | /******/ i: moduleId, 21 | /******/ l: false, 22 | /******/ exports: {} 23 | /******/ }; 24 | /******/ 25 | /******/ // Execute the module function 26 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 27 | /******/ 28 | /******/ // Flag the module as loaded 29 | /******/ module.l = true; 30 | /******/ 31 | /******/ // Return the exports of the module 32 | /******/ return module.exports; 33 | /******/ } 34 | /******/ 35 | /******/ 36 | /******/ // expose the modules object (__webpack_modules__) 37 | /******/ __webpack_require__.m = modules; 38 | /******/ 39 | /******/ // expose the module cache 40 | /******/ __webpack_require__.c = installedModules; 41 | /******/ 42 | /******/ // define getter function for harmony exports 43 | /******/ __webpack_require__.d = function(exports, name, getter) { 44 | /******/ if(!__webpack_require__.o(exports, name)) { 45 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 46 | /******/ } 47 | /******/ }; 48 | /******/ 49 | /******/ // define __esModule on exports 50 | /******/ __webpack_require__.r = function(exports) { 51 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 52 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 53 | /******/ } 54 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 55 | /******/ }; 56 | /******/ 57 | /******/ // create a fake namespace object 58 | /******/ // mode & 1: value is a module id, require it 59 | /******/ // mode & 2: merge all properties of value into the ns 60 | /******/ // mode & 4: return value when already ns object 61 | /******/ // mode & 8|1: behave like require 62 | /******/ __webpack_require__.t = function(value, mode) { 63 | /******/ if(mode & 1) value = __webpack_require__(value); 64 | /******/ if(mode & 8) return value; 65 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 66 | /******/ var ns = Object.create(null); 67 | /******/ __webpack_require__.r(ns); 68 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 69 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 70 | /******/ return ns; 71 | /******/ }; 72 | /******/ 73 | /******/ // getDefaultExport function for compatibility with non-harmony modules 74 | /******/ __webpack_require__.n = function(module) { 75 | /******/ var getter = module && module.__esModule ? 76 | /******/ function getDefault() { return module['default']; } : 77 | /******/ function getModuleExports() { return module; }; 78 | /******/ __webpack_require__.d(getter, 'a', getter); 79 | /******/ return getter; 80 | /******/ }; 81 | /******/ 82 | /******/ // Object.prototype.hasOwnProperty.call 83 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 84 | /******/ 85 | /******/ // __webpack_public_path__ 86 | /******/ __webpack_require__.p = ""; 87 | /******/ 88 | /******/ 89 | /******/ // Load entry module and return exports 90 | /******/ return __webpack_require__(__webpack_require__.s = "./src/entry.js"); 91 | /******/ }) 92 | /************************************************************************/ 93 | /******/ ({ 94 | 95 | /***/ "./src/entry.js": 96 | /*!**********************!*\ 97 | !*** ./src/entry.js ***! 98 | \**********************/ 99 | /*! exports provided: doAlert */ 100 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 101 | 102 | "use strict"; 103 | __webpack_require__.r(__webpack_exports__); 104 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doAlert", function() { return doAlert; }); 105 | document.body.appendChild(Object.assign(document.createElement('p'), { 106 | textContent: "Earth is a planet that revolves around the sun" 107 | })) 108 | 109 | /* To use the doAlert function, run the following in the browser console: 110 | System.import('earth').then(earthModule => { 111 | earthModule.doAlert(); 112 | }) 113 | */ 114 | function doAlert() { 115 | alert("Earth is home to billions of humans and other life forms."); 116 | } 117 | 118 | /***/ }) 119 | 120 | /******/ }) 121 | ); 122 | } 123 | }; 124 | }); 125 | //# sourceMappingURL=bundle.js.map -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/dist/bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/entry.js"],"names":[],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFA;AAAA;AAAA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACO;AACP;AACA,C","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/entry.js\");\n","document.body.appendChild(Object.assign(document.createElement('p'), {\n textContent: \"Earth is a planet that revolves around the sun\"\n}))\n\n/* To use the doAlert function, run the following in the browser console:\nSystem.import('earth').then(earthModule => {\n earthModule.doAlert();\n})\n*/\nexport function doAlert() {\n alert(\"Earth is home to billions of humans and other life forms.\");\n}"],"sourceRoot":""} -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Basic Webpack SystemJS Example 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-webpack", 3 | "scripts": { 4 | "build": "webpack" 5 | }, 6 | "license": "MIT", 7 | "devDependencies": { 8 | "clean-webpack-plugin": "^3.0.0", 9 | "webpack": "^4.41.2", 10 | "webpack-cli": "^3.3.10" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/src/entry.js: -------------------------------------------------------------------------------- 1 | document.body.appendChild(Object.assign(document.createElement('p'), { 2 | textContent: "Earth is a planet that revolves around the sun" 3 | })) 4 | 5 | /* To use the doAlert function, run the following in the browser console: 6 | System.import('earth').then(earthModule => { 7 | earthModule.doAlert(); 8 | }) 9 | */ 10 | export function doAlert() { 11 | alert("Earth is home to billions of humans and other life forms."); 12 | } -------------------------------------------------------------------------------- /optimized-builds/basic-webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { CleanWebpackPlugin } = require('clean-webpack-plugin') 3 | 4 | module.exports = { 5 | entry: path.resolve(__dirname, 'src/entry.js'), 6 | mode: 'development', 7 | output: { 8 | filename: 'bundle.js', 9 | path: path.resolve(__dirname, 'dist'), 10 | libraryTarget: 'system', 11 | }, 12 | devtool: 'sourcemap', 13 | plugins: [new CleanWebpackPlugin()], 14 | }; -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/dist/0.bundle.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ 2 | 3 | /***/ "./src/sentient-aliens.js": 4 | /*!********************************!*\ 5 | !*** ./src/sentient-aliens.js ***! 6 | \********************************/ 7 | /*! no static exports found */ 8 | /***/ (function(module, exports) { 9 | 10 | document.body.appendChild(Object.assign(document.createElement('pre'), { 11 | textContent: ` 12 | .-""""-. .-""""-. 13 | / \\ / \\ 14 | /_ _\\ /_ _\\ 15 | // \\ / \\\\ // \\ / \\\\ 16 | |\\__\\ /__/| |\\__\\ /__/| 17 | \\ || / \\ || / 18 | \\ / \\ / 19 | \\ __ / \\ __ / 20 | '.__.' '.__.' 21 | | | | | 22 | | | | | 23 | `, 24 | })) 25 | 26 | /***/ }) 27 | 28 | }]); 29 | //# sourceMappingURL=0.bundle.js.map -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/dist/0.bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./src/sentient-aliens.js"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,E","file":"0.bundle.js","sourcesContent":["document.body.appendChild(Object.assign(document.createElement('pre'), {\n textContent: `\n .-\"\"\"\"-. .-\"\"\"\"-.\n / \\\\ / \\\\\n /_ _\\\\ /_ _\\\\\n // \\\\ / \\\\\\\\ // \\\\ / \\\\\\\\\n |\\\\__\\\\ /__/| |\\\\__\\\\ /__/|\n \\\\ || / \\\\ || /\n \\\\ / \\\\ /\n \\\\ __ / \\\\ __ / \n '.__.' '.__.'\n | | | |\n | | | |\n `,\n}))"],"sourceRoot":""} -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/dist/bundle.js: -------------------------------------------------------------------------------- 1 | System.register([], function(__WEBPACK_DYNAMIC_EXPORT__) { 2 | 3 | return { 4 | 5 | execute: function() { 6 | __WEBPACK_DYNAMIC_EXPORT__( 7 | /******/ (function(modules) { // webpackBootstrap 8 | /******/ // install a JSONP callback for chunk loading 9 | /******/ function webpackJsonpCallback(data) { 10 | /******/ var chunkIds = data[0]; 11 | /******/ var moreModules = data[1]; 12 | /******/ 13 | /******/ 14 | /******/ // add "moreModules" to the modules object, 15 | /******/ // then flag all "chunkIds" as loaded and fire callback 16 | /******/ var moduleId, chunkId, i = 0, resolves = []; 17 | /******/ for(;i < chunkIds.length; i++) { 18 | /******/ chunkId = chunkIds[i]; 19 | /******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) { 20 | /******/ resolves.push(installedChunks[chunkId][0]); 21 | /******/ } 22 | /******/ installedChunks[chunkId] = 0; 23 | /******/ } 24 | /******/ for(moduleId in moreModules) { 25 | /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { 26 | /******/ modules[moduleId] = moreModules[moduleId]; 27 | /******/ } 28 | /******/ } 29 | /******/ if(parentJsonpFunction) parentJsonpFunction(data); 30 | /******/ 31 | /******/ while(resolves.length) { 32 | /******/ resolves.shift()(); 33 | /******/ } 34 | /******/ 35 | /******/ }; 36 | /******/ 37 | /******/ 38 | /******/ // The module cache 39 | /******/ var installedModules = {}; 40 | /******/ 41 | /******/ // object to store loaded and loading chunks 42 | /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 43 | /******/ // Promise = chunk loading, 0 = chunk loaded 44 | /******/ var installedChunks = { 45 | /******/ "main": 0 46 | /******/ }; 47 | /******/ 48 | /******/ 49 | /******/ 50 | /******/ // script path function 51 | /******/ function jsonpScriptSrc(chunkId) { 52 | /******/ return __webpack_require__.p + "" + chunkId + ".bundle.js" 53 | /******/ } 54 | /******/ 55 | /******/ // The require function 56 | /******/ function __webpack_require__(moduleId) { 57 | /******/ 58 | /******/ // Check if module is in cache 59 | /******/ if(installedModules[moduleId]) { 60 | /******/ return installedModules[moduleId].exports; 61 | /******/ } 62 | /******/ // Create a new module (and put it into the cache) 63 | /******/ var module = installedModules[moduleId] = { 64 | /******/ i: moduleId, 65 | /******/ l: false, 66 | /******/ exports: {} 67 | /******/ }; 68 | /******/ 69 | /******/ // Execute the module function 70 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 71 | /******/ 72 | /******/ // Flag the module as loaded 73 | /******/ module.l = true; 74 | /******/ 75 | /******/ // Return the exports of the module 76 | /******/ return module.exports; 77 | /******/ } 78 | /******/ 79 | /******/ // This file contains only the entry chunk. 80 | /******/ // The chunk loading function for additional chunks 81 | /******/ __webpack_require__.e = function requireEnsure(chunkId) { 82 | /******/ var promises = []; 83 | /******/ 84 | /******/ 85 | /******/ // JSONP chunk loading for javascript 86 | /******/ 87 | /******/ var installedChunkData = installedChunks[chunkId]; 88 | /******/ if(installedChunkData !== 0) { // 0 means "already installed". 89 | /******/ 90 | /******/ // a Promise means "currently loading". 91 | /******/ if(installedChunkData) { 92 | /******/ promises.push(installedChunkData[2]); 93 | /******/ } else { 94 | /******/ // setup Promise in chunk cache 95 | /******/ var promise = new Promise(function(resolve, reject) { 96 | /******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; 97 | /******/ }); 98 | /******/ promises.push(installedChunkData[2] = promise); 99 | /******/ 100 | /******/ // start chunk loading 101 | /******/ var script = document.createElement('script'); 102 | /******/ var onScriptComplete; 103 | /******/ 104 | /******/ script.charset = 'utf-8'; 105 | /******/ script.timeout = 120; 106 | /******/ if (__webpack_require__.nc) { 107 | /******/ script.setAttribute("nonce", __webpack_require__.nc); 108 | /******/ } 109 | /******/ script.src = jsonpScriptSrc(chunkId); 110 | /******/ 111 | /******/ // create error before stack unwound to get useful stacktrace later 112 | /******/ var error = new Error(); 113 | /******/ onScriptComplete = function (event) { 114 | /******/ // avoid mem leaks in IE. 115 | /******/ script.onerror = script.onload = null; 116 | /******/ clearTimeout(timeout); 117 | /******/ var chunk = installedChunks[chunkId]; 118 | /******/ if(chunk !== 0) { 119 | /******/ if(chunk) { 120 | /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); 121 | /******/ var realSrc = event && event.target && event.target.src; 122 | /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; 123 | /******/ error.name = 'ChunkLoadError'; 124 | /******/ error.type = errorType; 125 | /******/ error.request = realSrc; 126 | /******/ chunk[1](error); 127 | /******/ } 128 | /******/ installedChunks[chunkId] = undefined; 129 | /******/ } 130 | /******/ }; 131 | /******/ var timeout = setTimeout(function(){ 132 | /******/ onScriptComplete({ type: 'timeout', target: script }); 133 | /******/ }, 120000); 134 | /******/ script.onerror = script.onload = onScriptComplete; 135 | /******/ document.head.appendChild(script); 136 | /******/ } 137 | /******/ } 138 | /******/ return Promise.all(promises); 139 | /******/ }; 140 | /******/ 141 | /******/ // expose the modules object (__webpack_modules__) 142 | /******/ __webpack_require__.m = modules; 143 | /******/ 144 | /******/ // expose the module cache 145 | /******/ __webpack_require__.c = installedModules; 146 | /******/ 147 | /******/ // define getter function for harmony exports 148 | /******/ __webpack_require__.d = function(exports, name, getter) { 149 | /******/ if(!__webpack_require__.o(exports, name)) { 150 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 151 | /******/ } 152 | /******/ }; 153 | /******/ 154 | /******/ // define __esModule on exports 155 | /******/ __webpack_require__.r = function(exports) { 156 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 157 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 158 | /******/ } 159 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 160 | /******/ }; 161 | /******/ 162 | /******/ // create a fake namespace object 163 | /******/ // mode & 1: value is a module id, require it 164 | /******/ // mode & 2: merge all properties of value into the ns 165 | /******/ // mode & 4: return value when already ns object 166 | /******/ // mode & 8|1: behave like require 167 | /******/ __webpack_require__.t = function(value, mode) { 168 | /******/ if(mode & 1) value = __webpack_require__(value); 169 | /******/ if(mode & 8) return value; 170 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 171 | /******/ var ns = Object.create(null); 172 | /******/ __webpack_require__.r(ns); 173 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 174 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 175 | /******/ return ns; 176 | /******/ }; 177 | /******/ 178 | /******/ // getDefaultExport function for compatibility with non-harmony modules 179 | /******/ __webpack_require__.n = function(module) { 180 | /******/ var getter = module && module.__esModule ? 181 | /******/ function getDefault() { return module['default']; } : 182 | /******/ function getModuleExports() { return module; }; 183 | /******/ __webpack_require__.d(getter, 'a', getter); 184 | /******/ return getter; 185 | /******/ }; 186 | /******/ 187 | /******/ // Object.prototype.hasOwnProperty.call 188 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 189 | /******/ 190 | /******/ // __webpack_public_path__ 191 | /******/ __webpack_require__.p = ""; 192 | /******/ 193 | /******/ // on error function for async loading 194 | /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; 195 | /******/ 196 | /******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; 197 | /******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); 198 | /******/ jsonpArray.push = webpackJsonpCallback; 199 | /******/ jsonpArray = jsonpArray.slice(); 200 | /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); 201 | /******/ var parentJsonpFunction = oldJsonpFunction; 202 | /******/ 203 | /******/ 204 | /******/ // Load entry module and return exports 205 | /******/ return __webpack_require__(__webpack_require__.s = "./src/entry.js"); 206 | /******/ }) 207 | /************************************************************************/ 208 | /******/ ({ 209 | 210 | /***/ "./node_modules/systemjs-webpack-interop/src/public-path-system-resolve.js": 211 | /*!*********************************************************************************!*\ 212 | !*** ./node_modules/systemjs-webpack-interop/src/public-path-system-resolve.js ***! 213 | \*********************************************************************************/ 214 | /*! exports provided: setPublicPath */ 215 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 216 | 217 | "use strict"; 218 | __webpack_require__.r(__webpack_exports__); 219 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setPublicPath", function() { return setPublicPath; }); 220 | function setPublicPath(systemjsModuleName, rootDirectoryLevel = 1) { 221 | if ( 222 | typeof systemjsModuleName !== "string" || 223 | systemjsModuleName.trim().length === 0 224 | ) { 225 | throw Error( 226 | "systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'" 227 | ); 228 | } 229 | 230 | if ( 231 | typeof rootDirectoryLevel !== "number" || 232 | rootDirectoryLevel <= 0 || 233 | !Number.isInteger(rootDirectoryLevel) 234 | ) { 235 | throw Error( 236 | "systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'" 237 | ); 238 | } 239 | 240 | let moduleUrl; 241 | try { 242 | moduleUrl = window.System.resolve(systemjsModuleName); 243 | if (!moduleUrl) { 244 | throw Error(); 245 | } 246 | } catch (err) { 247 | throw Error( 248 | "systemjs-webpack-interop: There is no such module '" + 249 | systemjsModuleName + 250 | "' in the SystemJS registry. Did you misspell the name of your module?" 251 | ); 252 | } 253 | 254 | __webpack_require__.p = resolveDirectory(moduleUrl, rootDirectoryLevel); 255 | } 256 | 257 | function resolveDirectory(urlString, rootDirectoryLevel) { 258 | const url = new URL(urlString); 259 | const pathname = new URL(urlString).pathname; 260 | let numDirsProcessed = 0, 261 | index = pathname.length; 262 | while (numDirsProcessed !== rootDirectoryLevel && index >= 0) { 263 | const char = pathname[--index]; 264 | if (char === "/") { 265 | numDirsProcessed++; 266 | } 267 | } 268 | 269 | if (numDirsProcessed !== rootDirectoryLevel) { 270 | throw Error( 271 | "systemjs-webpack-interop: rootDirectoryLevel (" + 272 | rootDirectoryLevel + 273 | ") is greater than the number of directories (" + 274 | numDirsProcessed + 275 | ") in the URL path " + 276 | fullUrl 277 | ); 278 | } 279 | 280 | url.pathname = url.pathname.slice(0, index + 1); 281 | 282 | return url.href; 283 | } 284 | 285 | 286 | /***/ }), 287 | 288 | /***/ "./node_modules/systemjs-webpack-interop/src/systemjs-webpack-interop.js": 289 | /*!*******************************************************************************!*\ 290 | !*** ./node_modules/systemjs-webpack-interop/src/systemjs-webpack-interop.js ***! 291 | \*******************************************************************************/ 292 | /*! exports provided: setPublicPath */ 293 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 294 | 295 | "use strict"; 296 | __webpack_require__.r(__webpack_exports__); 297 | /* harmony import */ var _public_path_system_resolve__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./public-path-system-resolve */ "./node_modules/systemjs-webpack-interop/src/public-path-system-resolve.js"); 298 | /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setPublicPath", function() { return _public_path_system_resolve__WEBPACK_IMPORTED_MODULE_0__["setPublicPath"]; }); 299 | 300 | 301 | 302 | 303 | /***/ }), 304 | 305 | /***/ "./src/entry.js": 306 | /*!**********************!*\ 307 | !*** ./src/entry.js ***! 308 | \**********************/ 309 | /*! exports provided: findAliens */ 310 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 311 | 312 | "use strict"; 313 | __webpack_require__.r(__webpack_exports__); 314 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findAliens", function() { return findAliens; }); 315 | /* harmony import */ var _set_public_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./set-public-path */ "./src/set-public-path.js"); 316 | 317 | 318 | document.body.appendChild(Object.assign(document.createElement('div'), {textContent: "Are there aliens on Mars?"})) 319 | document.body.appendChild(Object.assign(document.createElement('button'), {textContent: "Click to find out", onclick: findAliens})) 320 | 321 | /* This function can be called with the following code: 322 | System.import('mars').then(marsModule => { 323 | marsModule.findAlens(); 324 | }) 325 | */ 326 | function findAliens() { 327 | __webpack_require__.e(/*! import() */ 0).then(__webpack_require__.t.bind(null, /*! ./sentient-aliens.js */ "./src/sentient-aliens.js", 7)) 328 | } 329 | 330 | /***/ }), 331 | 332 | /***/ "./src/set-public-path.js": 333 | /*!********************************!*\ 334 | !*** ./src/set-public-path.js ***! 335 | \********************************/ 336 | /*! no exports provided */ 337 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 338 | 339 | "use strict"; 340 | __webpack_require__.r(__webpack_exports__); 341 | /* harmony import */ var systemjs_webpack_interop__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! systemjs-webpack-interop */ "./node_modules/systemjs-webpack-interop/src/systemjs-webpack-interop.js"); 342 | 343 | 344 | // equivalent to __webpack_public_path__ = System.resolve('mars').slice(0, System.resolve('mars').lastIndexOf('/') + 1) 345 | Object(systemjs_webpack_interop__WEBPACK_IMPORTED_MODULE_0__["setPublicPath"])('mars') 346 | 347 | /***/ }) 348 | 349 | /******/ }) 350 | ); 351 | } 352 | }; 353 | }); 354 | //# sourceMappingURL=bundle.js.map -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/dist/bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/systemjs-webpack-interop/src/public-path-system-resolve.js","webpack:///./node_modules/systemjs-webpack-interop/src/systemjs-webpack-interop.js","webpack:///./src/entry.js","webpack:///./src/set-public-path.js"],"names":[],"mappings":";;;;;;;QAAA;QACA;QACA;QACA;;;QAGA;QACA;QACA;QACA,QAAQ,oBAAoB;QAC5B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;;QAEA;;;QAGA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;;;QAIA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;QAEA;QACA;QACA;QACA;;;QAGA;;QAEA;QACA,iCAAiC;;QAEjC;QACA;QACA;QACA,KAAK;QACL;QACA;QACA;QACA,MAAM;QACN;;QAEA;QACA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,wBAAwB,kCAAkC;QAC1D,MAAM;QACN;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA,0CAA0C,oBAAoB,WAAW;;QAEzE;QACA;QACA;QACA;QACA,gBAAgB,uBAAuB;QACvC;;;QAGA;QACA;;;;;;;;;;;;;ACrMA;AAAA;AAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAE,qBAAuB;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;;;;;;;;;;;AC/DA;AAAA;AAAA;AAAA;AAA6D;;;;;;;;;;;;;ACA7D;AAAA;AAAA;AAA0B;;AAE1B,wEAAwE,yCAAyC;AACjH,2EAA2E,sDAAsD;;AAEjI;AACA;AACA;AACA,CAAC;AACD;AACO;AACP,EAAE,0IAA8B;AAChC,C;;;;;;;;;;;;ACZA;AAAA;AAAwD;;AAExD;AACA,8EAAa,Q","file":"bundle.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t};\n\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"main\": 0\n \t};\n\n\n\n \t// script path function\n \tfunction jsonpScriptSrc(chunkId) {\n \t\treturn __webpack_require__.p + \"\" + chunkId + \".bundle.js\"\n \t}\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar promises = [];\n\n\n \t\t// JSONP chunk loading for javascript\n\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n \t\t\t// a Promise means \"currently loading\".\n \t\t\tif(installedChunkData) {\n \t\t\t\tpromises.push(installedChunkData[2]);\n \t\t\t} else {\n \t\t\t\t// setup Promise in chunk cache\n \t\t\t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t\t\t});\n \t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n \t\t\t\t// start chunk loading\n \t\t\t\tvar script = document.createElement('script');\n \t\t\t\tvar onScriptComplete;\n\n \t\t\t\tscript.charset = 'utf-8';\n \t\t\t\tscript.timeout = 120;\n \t\t\t\tif (__webpack_require__.nc) {\n \t\t\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t\t\t}\n \t\t\t\tscript.src = jsonpScriptSrc(chunkId);\n\n \t\t\t\t// create error before stack unwound to get useful stacktrace later\n \t\t\t\tvar error = new Error();\n \t\t\t\tonScriptComplete = function (event) {\n \t\t\t\t\t// avoid mem leaks in IE.\n \t\t\t\t\tscript.onerror = script.onload = null;\n \t\t\t\t\tclearTimeout(timeout);\n \t\t\t\t\tvar chunk = installedChunks[chunkId];\n \t\t\t\t\tif(chunk !== 0) {\n \t\t\t\t\t\tif(chunk) {\n \t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n \t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n \t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n \t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n \t\t\t\t\t\t\terror.type = errorType;\n \t\t\t\t\t\t\terror.request = realSrc;\n \t\t\t\t\t\t\tchunk[1](error);\n \t\t\t\t\t\t}\n \t\t\t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t\t\t}\n \t\t\t\t};\n \t\t\t\tvar timeout = setTimeout(function(){\n \t\t\t\t\tonScriptComplete({ type: 'timeout', target: script });\n \t\t\t\t}, 120000);\n \t\t\t\tscript.onerror = script.onload = onScriptComplete;\n \t\t\t\tdocument.head.appendChild(script);\n \t\t\t}\n \t\t}\n \t\treturn Promise.all(promises);\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/entry.js\");\n","export function setPublicPath(systemjsModuleName, rootDirectoryLevel = 1) {\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n !Number.isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n let moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n}\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n const url = new URL(urlString);\n const pathname = new URL(urlString).pathname;\n let numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n const char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n fullUrl\n );\n }\n\n url.pathname = url.pathname.slice(0, index + 1);\n\n return url.href;\n}\n","export { setPublicPath } from \"./public-path-system-resolve\";\n","import './set-public-path'\n\ndocument.body.appendChild(Object.assign(document.createElement('div'), {textContent: \"Are there aliens on Mars?\"}))\ndocument.body.appendChild(Object.assign(document.createElement('button'), {textContent: \"Click to find out\", onclick: findAliens}))\n\n/* This function can be called with the following code:\nSystem.import('mars').then(marsModule => {\n marsModule.findAlens();\n})\n*/\nexport function findAliens() {\n import('./sentient-aliens.js')\n}","import { setPublicPath } from 'systemjs-webpack-interop'\n\n// equivalent to __webpack_public_path__ = System.resolve('mars').slice(0, System.resolve('mars').lastIndexOf('/') + 1)\nsetPublicPath('mars')"],"sourceRoot":""} -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SystemJS Example - Webpack Code Splits 7 | 8 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-code-splits", 3 | "scripts": { 4 | "build": "webpack" 5 | }, 6 | "license": "MIT", 7 | "devDependencies": { 8 | "clean-webpack-plugin": "^3.0.0", 9 | "webpack": "^4.41.2", 10 | "webpack-cli": "^3.3.10" 11 | }, 12 | "dependencies": { 13 | "systemjs-webpack-interop": "^1.1.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/src/entry.js: -------------------------------------------------------------------------------- 1 | import './set-public-path' 2 | 3 | document.body.appendChild(Object.assign(document.createElement('div'), {textContent: "Are there aliens on Mars?"})) 4 | document.body.appendChild(Object.assign(document.createElement('button'), {textContent: "Click to find out", onclick: findAliens})) 5 | 6 | /* This function can be called with the following code: 7 | System.import('mars').then(marsModule => { 8 | marsModule.findAlens(); 9 | }) 10 | */ 11 | export function findAliens() { 12 | import('./sentient-aliens.js') 13 | } -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/src/sentient-aliens.js: -------------------------------------------------------------------------------- 1 | document.body.appendChild(Object.assign(document.createElement('pre'), { 2 | textContent: ` 3 | .-""""-. .-""""-. 4 | / \\ / \\ 5 | /_ _\\ /_ _\\ 6 | // \\ / \\\\ // \\ / \\\\ 7 | |\\__\\ /__/| |\\__\\ /__/| 8 | \\ || / \\ || / 9 | \\ / \\ / 10 | \\ __ / \\ __ / 11 | '.__.' '.__.' 12 | | | | | 13 | | | | | 14 | `, 15 | })) -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/src/set-public-path.js: -------------------------------------------------------------------------------- 1 | import { setPublicPath } from 'systemjs-webpack-interop' 2 | 3 | // equivalent to __webpack_public_path__ = System.resolve('mars').slice(0, System.resolve('mars').lastIndexOf('/') + 1) 4 | setPublicPath('mars') -------------------------------------------------------------------------------- /optimized-builds/webpack-code-splits/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { CleanWebpackPlugin } = require('clean-webpack-plugin') 3 | 4 | module.exports = { 5 | entry: path.resolve(__dirname, 'src/entry.js'), 6 | mode: 'development', 7 | output: { 8 | filename: 'bundle.js', 9 | path: path.resolve(__dirname, 'dist'), 10 | libraryTarget: 'system', 11 | }, 12 | devtool: 'sourcemap', 13 | plugins: [new CleanWebpackPlugin()], 14 | }; -------------------------------------------------------------------------------- /starter-kits/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/systemjs/systemjs-examples/bf70097688e4c062683d31c9f58399aee6747a49/starter-kits/.gitkeep -------------------------------------------------------------------------------- /systemjs-features/basic-import-map/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Basic SystemJS Example 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /systemjs-features/basic-import-map/mercury.js: -------------------------------------------------------------------------------- 1 | System.register([], function (_export, _context) { 2 | return { 3 | execute: function() { 4 | document.body.appendChild(Object.assign(document.createElement('p'), {textContent: "Mercury is the planet nearest to the sun"})) 5 | 6 | /* The doAlert function is exported and can be used like this: 7 | System.import('mercury').then(mercuryModule => { 8 | mercuryModule.doAlert(); 9 | }) 10 | */ 11 | _export('doAlert', doAlert); 12 | 13 | function doAlert() { 14 | alert("I hear it's quite warm on Mercury"); 15 | } 16 | } 17 | } 18 | }) -------------------------------------------------------------------------------- /systemjs-features/dynamic-import/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SystemJS Dynamic Import Example 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /systemjs-features/dynamic-import/neptune.js: -------------------------------------------------------------------------------- 1 | System.register([], function (_export, _context) { 2 | return { 3 | execute: function() { 4 | document.body.appendChild(Object.assign(document.createElement('p'), { 5 | textContent: 'Neptune is a planet that revolves around the Sun' 6 | })); 7 | 8 | // Dynamic import within a module calculates a url relative to the current module 9 | _context.import('./triton.js').then(function (triton) { 10 | console.log("Triton was discovered on", triton.discoveryDate); 11 | }); 12 | } 13 | }; 14 | }); -------------------------------------------------------------------------------- /systemjs-features/dynamic-import/triton.js: -------------------------------------------------------------------------------- 1 | System.register([], function (_export, _context) { 2 | return { 3 | execute: function() { 4 | document.body.appendChild(Object.assign(document.createElement('p'), { 5 | textContent: 'Triton is a moon that revolves around Neptune.' 6 | })); 7 | _export("discoveryDate", "Oct. 10, 1846"); 8 | } 9 | }; 10 | }); -------------------------------------------------------------------------------- /systemjs-features/import-map-scopes/dep-v1.js: -------------------------------------------------------------------------------- 1 | System.register([], function (_export) { 2 | return { 3 | execute: function() { 4 | _export('version', 'v1'); 5 | } 6 | }; 7 | }); -------------------------------------------------------------------------------- /systemjs-features/import-map-scopes/dep-v2.js: -------------------------------------------------------------------------------- 1 | System.register([], function (_export) { 2 | return { 3 | execute: function() { 4 | _export('version', 'v2'); 5 | } 6 | }; 7 | }); -------------------------------------------------------------------------------- /systemjs-features/import-map-scopes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Import Map Scopes SystemJS Example 7 | 8 | 21 | 22 | 23 | 40 | 41 | 42 |

Check browser console for details

43 | 44 | -------------------------------------------------------------------------------- /systemjs-features/import-map-scopes/main/main.js: -------------------------------------------------------------------------------- 1 | System.register(['dep'], function (_export) { 2 | let dep; 3 | 4 | return { 5 | setters: [ 6 | function (ns) { 7 | dep = ns; 8 | } 9 | ], 10 | execute: function () { 11 | console.log('main is executing. dep version is', dep.version); 12 | _export('default', 'main'); 13 | } 14 | } 15 | }) -------------------------------------------------------------------------------- /systemjs-features/nodejs-loader/README.md: -------------------------------------------------------------------------------- 1 | # SystemJS nodejs example 2 | 3 | This example shows SystemJS running in the browser. 4 | 5 | ## Running locally 6 | 7 | ``` 8 | cd nodejs-loader 9 | npm install 10 | npm start 11 | ``` -------------------------------------------------------------------------------- /systemjs-features/nodejs-loader/antarctica.js: -------------------------------------------------------------------------------- 1 | System.register([], (_export) => ({ 2 | execute() { 3 | _export('default', "Antarctica is the southern continent"); 4 | } 5 | })); -------------------------------------------------------------------------------- /systemjs-features/nodejs-loader/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SystemJS NodeJS extra 7 | 8 | 9 |

NodeJS extra

10 |

11 | This project does not run in the browser, but in NodeJS. To run the project, clone this repository, run npm install, and run npm start. See README.md in the github repository for more details. 12 |

13 | 14 | -------------------------------------------------------------------------------- /systemjs-features/nodejs-loader/index.js: -------------------------------------------------------------------------------- 1 | const url = require('url'); 2 | const { System, applyImportMap, setBaseUrl } = require('systemjs'); 3 | 4 | // Setting base URL is optional - the default is to use process.cwd() 5 | // so the code here is redundant 6 | const basePath = url.pathToFileURL(process.cwd()).href; 7 | setBaseUrl(System, basePath); 8 | 9 | applyImportMap(System, { 10 | imports: { 11 | "antarctica": "./antarctica.js" 12 | } 13 | }); 14 | 15 | System.import('antarctica').then(ns => { 16 | console.log('antarctica module', ns); 17 | }); -------------------------------------------------------------------------------- /systemjs-features/nodejs-loader/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-loader", 3 | "version": "1.0.0", 4 | "description": "This example shows SystemJS running in the browser.", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "systemjs": "latest" 13 | } 14 | } 15 | --------------------------------------------------------------------------------