chenos/v8js-module-loader

There is no license information available for the latest version (v0.4.0) of this package.

v0.4.0 2018-02-07 06:29 UTC

This package is not auto-updated.

Last update: 2024-11-04 08:08:04 UTC


README

Build Status Coverage Status

Requirements

  • PHP 7.0+
  • V8Js extension 2.0+

Installation

composer require chenos/v8js-module-loader

Dependents

Testing

make test

Example

make example

Access http://127.0.0.1:8888

Usage

use Chenos\V8JsModuleLoader\ModuleLoader;

// entry directory
$loader = new ModuleLoader(__DIR__);

$loader->setExtensions('.js', '.json');

$loader->setEntryDir(__DIR__);

// array
$loader->addOverride(['vue' => 'vue/dist/vue.runtime.common.js']);

// key, value
$loader->addOverride('vue', 'vue/dist/vue.runtime.common.js');

// v8js version > 2.1.0+
$loader->addOverride(['fn' => function (...$args) {}]);
$loader->addOverride('obj', new stdClass());

$loader->addVendorDir(__DIR__.'/node_modules', __DIR__.'/bower_components');

$v8 = new V8Js();

$v8->setModuleNormaliser([$loader, 'normaliseIdentifier']);
$v8->setModuleLoader([$loader, 'loadModule']);