Example #1
0
 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     if ($this->str_endswith($asset->getSourcePath(), ['.js'])) {
         $moduleName = basename($asset->getSourcePath(), '.js');
         $delivery = $this->delivery->create(['includes' => [$asset->getSourceRoot()]]);
         $delivery->addModule($moduleName);
         $delivery->setMainModule($moduleName);
         $asset->setContent($delivery->getOutput());
     }
 }
Example #2
0
 /**
  * @author Simaranjit Singh <*****@*****.**>
  * CommonJS constructor.
  */
 public function __construct()
 {
     $includes = array('../source/modules');
     $this->delivery = Delivery::create(array('includes' => $includes));
     $this->delivery->addModule('../source/main');
     $this->delivery->setMainModule('../source/main');
 }
Example #3
0
 public function testGetOutputCanExportRequire()
 {
     $delivery = Delivery::create();
     $toplevelidentifier = CJSD_TESTMODS_DIR . '/apple/index';
     $delivery->addModule($toplevelidentifier);
     $exportrequire = 'justaverylongname';
     $this->assertTrue(strpos($delivery->getOutput($exportrequire), $exportrequire) !== false);
 }