Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ModuleLoader/browser-es-module-loader
ES Module Loader browser loading example
https://github.com/ModuleLoader/browser-es-module-loader
Last synced: 3 months ago
JSON representation
ES Module Loader browser loading example
- Host: GitHub
- URL: https://github.com/ModuleLoader/browser-es-module-loader
- Owner: ModuleLoader
- Archived: true
- Created: 2016-08-10T22:00:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-22T10:18:56.000Z (about 7 years ago)
- Last Synced: 2024-07-18T15:30:29.929Z (4 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 104
- Watchers: 9
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Browser ES Module Loader
===Loads ES modules in the browser via Babel just like the WhatWG HTML specification for modules.
Also supports the `` tag with both `src` and inline forms.
Throws when loading bare / plain names.
See the `example` folder for a demonstration.
Built with the ES Module Loader polyfill 1.0 branch at https://github.com/ModuleLoader/es-module-loader.
### How it works
Fetches module sources in the browser, then uses Babel to transform them into System.register modules.
The loader polyfill then handles the loading and execution pipeline as in the loader spec.
**This project is only suitable for demonstrations / experimentation and is not designed for any production workflows at all.**
### Installation
```
npm install browser-es-module-loader
```### Usage
```html
<script src="dist/babel-browser-build.js">import {x} from './y.js';
// this case throws as plain / bare names are not supported as in the WhatWG spec
import thisWillThrow from 'x';// dynamic import also supported
import('./x').then(function (m) {
// ...
});var loader = new BrowserESModuleLoader();
// relative path or URL syntax is necessary as plain resolution throws
loader.import('./path/to/file.js').then(function(m) {
// ...
});```
LICENSE
---MIT