├── .gitignore ├── .travis.yml ├── README.md ├── package.json ├── polyfill.js ├── rollup.config.js ├── src ├── msg.js ├── vendor │ ├── acorn.js │ └── escodegen.browser.js ├── window │ ├── cluster.js │ ├── dom.js │ ├── eval.js │ ├── execute.js │ ├── index.js │ ├── module-tools.js │ ├── modules.js │ ├── registry.js │ ├── spawn.js │ └── utils.js └── worker │ ├── acorn.js │ ├── assignment-expression.js │ ├── call-expression.js │ ├── export-all-declaration.js │ ├── export-default-declaration.js │ ├── export-named-declaration.js │ ├── export-set.js │ ├── identifier.js │ ├── import-call-identifier.js │ ├── import-declaration.js │ ├── index.js │ ├── module-tools.js │ ├── property.js │ ├── source-maps.js │ ├── utils.js │ └── visitors.js ├── test ├── all.html ├── circular.html ├── errors.html ├── everything.html ├── export-syntax.html ├── import-dynamic.html ├── import-syntax.html ├── inline-everything.html ├── perf │ └── app │ │ ├── config.js │ │ ├── generate.js │ │ ├── package.json │ │ ├── polyfill.html │ │ ├── steal.html │ │ ├── steal.js │ │ └── systemjs.html ├── scope.html └── tests │ ├── circular │ ├── basics.js │ ├── src │ │ ├── a.js │ │ ├── b.js │ │ ├── one.js │ │ ├── three.js │ │ └── two.js │ └── threeway.js │ ├── errors │ ├── ref │ │ ├── bad.js │ │ └── index.js │ └── sloppy │ │ └── index.js │ ├── everything │ ├── bar.js │ ├── folder │ │ ├── thing.js │ │ └── yet-another.js │ ├── foo.js │ ├── index.html │ └── other.js │ ├── exports │ ├── default.js │ ├── from.js │ ├── let.js │ ├── object.js │ └── src │ │ ├── default-expr.js │ │ ├── default-fn.js │ │ ├── default-obj-alias.js │ │ ├── default-object.js │ │ ├── from-as.js │ │ ├── from-name.js │ │ ├── from-source.js │ │ ├── from-source2.js │ │ ├── from-star.js │ │ ├── let-equal.js │ │ ├── let-use-export.js │ │ ├── let-var.js │ │ └── object-as.js │ ├── import-fn │ ├── dynamic.js │ ├── multi-arg.js │ ├── spread.js │ └── src │ │ ├── bar.js │ │ ├── baz.js │ │ ├── foo.js │ │ └── qux.js │ ├── imports │ ├── default-and-member.js │ ├── default-and-star.js │ ├── default.js │ ├── member-alias.js │ ├── members.js │ ├── side-effect.js │ ├── src │ │ ├── default-and-member.js │ │ ├── default-and-star.js │ │ ├── default.js │ │ ├── members.js │ │ ├── side-effect.js │ │ └── star.js │ └── star.js │ └── scope │ ├── main.js │ ├── src │ └── foo.js │ └── var.js └── worker.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | test/perf/app/src/ 3 | test/perf/app/node_modules/ 4 | test/perf/app/jspm_packages/ 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: node_js 3 | node_js: 6.3 4 | before_script: 5 | - npm install -g testee 6 | script: npm test 7 | before_install: 8 | - "export DISPLAY=:99.0" 9 | - "sh -e /etc/init.d/xvfb start" 10 | addons: 11 | firefox: "49.0" 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # <script type=module> - the polyfill! 2 | 3 | An attempt to build a polyfill for [\ 26 | 27 | 28 | ``` 29 | 30 | ### Dynamic import 31 | 32 | The [stage 2 import()](https://github.com/domenic/proposal-dynamic-import) proposal allows you to dynamically import code based on runtime considerations. This is useful if you want to delay loading parts of the application for any reason (such as based on user input). 33 | 34 | This polyfill includes support for `import()`. Here's an example usage: 35 | 36 | **/pages/home.js** 37 | 38 | ```js 39 | export function page(){ 40 | let section = document.createElement('section'); 41 | section.innerHTML = ` 42 |
Welcome home!
45 | `; 46 | 47 | return section; 48 | } 49 | ``` 50 | 51 | **index.html** 52 | 53 | ```html 54 | 55 | 56 | 57 | 58 | 65 | ``` 66 | 67 | In this case we are dynamically inserting DOM based on the `location.hash`, so that if the URL is `http://example.com#home` the `/pages/home.js` module is dynamically imported and inserted into `