0.0.6 • Published 7 years ago

wrap-define v0.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

wrap-define

Usage

In a browser:

<html>
<head>
    <title>define</title>
    <script type="text/javascript" src="dist/bundle.js"></script>
    <script type="text/javascript" src="//cdn.bootcss.com/require.js/2.3.2/require.js"></script>
</head>
<body>
    <h1>hi, there</h1>
    <script type="text/javascript">
        window.addEventListener('error', function (e) {
            console.log('error module is:', e.error && e.error.moduleId);
        });
    </script>
    <script type="text/javascript">
        define('preload', [], function () {
            //throw new Error('preload error');
            console.log('preload');
        });
        define('load', ['preload'], function () {
            window.addEventListener('click', function (e) {
                throw new Error('click error');
            });
            console.log('load');
        });

        define('last', [], function () {
            console.log('last');
        });

        require(['load']);
        //require(['last']);
    </script>
</body>
</html>