Add extension JS as a file to allow sourcemap detection

Fixes #1538
This commit is contained in:
Toby Zerner 2018-08-18 12:13:17 +09:30
parent c16ddf24f2
commit 5f83285442

View File

@ -47,9 +47,18 @@ class ExtensionAssets implements AssetInterface
{
if ($this->js) {
$sources->addString(function () {
$name = $this->extension->getId();
return 'var module={}';
});
return 'var module={};'.$this->getContent($this->js).";flarum.extensions['$name']=module.exports";
if (is_callable($this->js)) {
$sources->addString($this->js);
} else {
$sources->addFile($this->js);
}
$sources->addString(function () {
$name = $this->extension->getId();
return "flarum.extensions['$name']=module.exports";
});
}
}
@ -65,11 +74,6 @@ class ExtensionAssets implements AssetInterface
}
}
private function getContent($asset)
{
return is_callable($asset) ? $asset() : file_get_contents($asset);
}
public function localeJs(SourceCollector $sources, string $locale)
{
}