8
0

load__amd.js 634 B

12345678910111213141516171819202122232425
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. // We import the 'require' module, so Require.JS gives us a localized version of require().
  7. // Otherwise we would use the global one which resolves paths relatively to the base dir.
  8. import require from 'require';
  9. // NOTE: modulePath MUST BE RELATIVE to this module.
  10. export default function load( modulePath ) {
  11. return new Promise( ( resolve, reject ) => {
  12. require(
  13. [ modulePath ],
  14. ( module ) => {
  15. resolve( module );
  16. },
  17. ( err ) => {
  18. reject( err );
  19. }
  20. );
  21. } );
  22. }