Last active
February 5, 2017 14:32
-
-
Save jmaicher/f696b510008adadd94d2b7fbb35c8966 to your computer and use it in GitHub Desktop.
Express fragment dependencies with tailor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- ... --> | |
<script> | |
// stub implementation in case the shell fragment fails to resolve | |
define("shell", function() { return stub; }); | |
</script> | |
</head> | |
<body> | |
<fragment src="shell.example.com"></fragment> | |
<fragment src="foo.example.com"></fragment> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="shell"> | |
<header><!-- ... --></header> | |
<aside><!-- ... --></aside> | |
</div> | |
<script> | |
require.undef('shell'); | |
// Note that the bundle url is dynamically injected from the asset manifest | |
define("shell", ["/shell.bundle.js"], function(s) { return s.api }); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var api; | |
// will be called by tailor on pipe.end | |
export default (element) => { | |
let view = new ShellView(element); | |
api = new ShellApi(view); | |
} | |
export { api }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// marked as external in webpack config | |
const shell = require('shell'); | |
// will be called by tailor on pipe.end | |
export default (element) => { | |
console.log(shell); // => ShellApi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment