JSPM

  • Created
  • Published
  • Downloads 31233
  • Score
    100M100P100Q143170F
  • License MIT

import html and get the exports of entry

Package Exports

  • import-html-entry

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (import-html-entry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

import-html-entry

Treats the index html as manifest and loads the assets(css,js), and get the entry script exports.

<!-- subApp/index.html -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
</head>
<body>

<!-- mark the entry script with entry attribute -->
<script src="https://unpkg.com/mobx@5.0.3/lib/mobx.umd.js" entry></script>
<script src="https://unpkg.com/react@16.4.2/umd/react.production.min.js"></script>
</body>
</html>
import importHTML from 'html-import-entry';

importHTML('./subApp/index.html')
    .then(res => {
        console.log(res.template);

        res.loadScripts().then(exports => {
            const mobx = exports;
            const { observable } = mobx;
            observable({
                name: 'kuitos'
            })	
        })
});