Move bundles to /dist

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2021-12-02 00:08:08 +01:00 committed by John Molakvoæ
parent 8ee7c20e4d
commit b664aad7ab
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
22 changed files with 64 additions and 56 deletions

View File

@ -197,7 +197,9 @@ class ViewController extends Controller {
// Load the files we need
\OCP\Util::addStyle('files', 'merged');
\OCP\Util::addScript('files', 'merged-index');
\OCP\Util::addScript('files', 'dist/main');
\OCP\Util::addScript('files', 'templates');
\OCP\Util::addScript('files', 'files-app-settings');
\OCP\Util::addScript('files', 'legacy-filelist-search');
// mostly for the home storage's free space
// FIXME: Make non static

View File

@ -37,7 +37,7 @@ class LoadSidebarListener implements IEventListener {
return;
}
Util::addScript(Application::APP_ID, 'dist/sidebar');
Util::addScript(Application::APP_ID, 'sidebar');
// needed by the Sidebar legacy tabs
// TODO: remove when all tabs migrated to the new api
Util::addScript('files', 'fileinfomodel');

View File

@ -1,3 +0,0 @@
import './files-app-settings'
import './templates'
import './legacy/filelistSearch'

View File

@ -22,7 +22,7 @@
*/
script(\OCA\Files\AppInfo\Application::APP_ID, 'dist/personal-settings');
script(\OCA\Files\AppInfo\Application::APP_ID, 'personal-settings');
?>
<div id="files-personal-settings" class="section">

View File

@ -113,7 +113,7 @@ class Application extends App implements IBootstrap {
/**
* Always add main sharing script
*/
Util::addScript(self::APP_ID, 'dist/main');
Util::addScript(self::APP_ID, 'main');
}
@ -129,7 +129,7 @@ class Application extends App implements IBootstrap {
$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
\OCP\Util::addScript('files_sharing', 'dist/collaboration');
\OCP\Util::addScript('files_sharing', 'collaboration');
});
$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);

View File

@ -38,9 +38,9 @@ class LoadAdditionalListener implements IEventListener {
}
// After files for the files list shared content
Util::addScript(Application::APP_ID, 'dist/files_sharing', 'files');
Util::addScript(Application::APP_ID, 'files_sharing', 'files');
// After files for the breadcrumb share indicator
Util::addScript(Application::APP_ID, 'dist/additionalScripts', 'files');
Util::addScript(Application::APP_ID, 'additionalScripts', 'files');
Util::addStyle(Application::APP_ID, 'icons');
}
}

View File

@ -37,6 +37,6 @@ class LoadSidebarListener implements IEventListener {
return;
}
Util::addScript(Application::APP_ID, 'dist/files_sharing_tab', 'files');
Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
}
}

View File

@ -22,7 +22,7 @@ declare(strict_types=1);
*
*/
script(\OCA\Files_Sharing\AppInfo\Application::APP_ID, 'dist/personal-settings');
script(\OCA\Files_Sharing\AppInfo\Application::APP_ID, 'personal-settings');
?>
<div id="files-sharing-personal-settings" class="section">

View File

@ -52,7 +52,7 @@ class Application extends App implements IBootstrap {
$dispatcher->addListener(
'OCA\Files::loadAdditionalScripts',
function () {
\OCP\Util::addScript('core', 'dist/systemtags');
\OCP\Util::addScript('core', 'systemtags');
\OCP\Util::addScript(self::APP_ID, 'systemtags');
}
);

View File

@ -19,7 +19,7 @@
*
*/
script('core', 'dist/systemtags');
script('core', 'systemtags');
script('systemtags', 'admin');
style('systemtags', 'settings');

View File

@ -99,7 +99,7 @@ class BeforeTemplateRenderedListener implements IEventListener {
return ['profileEnabled' => $this->isProfileEnabled($account)];
});
\OCP\Util::addScript('user_status', 'user-status-menu');
\OCP\Util::addScript('user_status', 'user_status-menu');
\OCP\Util::addStyle('user_status', 'user-status-menu');
}
}

View File

@ -41,7 +41,7 @@ class LoadAdditionalSettingsScriptsListener implements IEventListener {
class_exists(Template::class, true);
}
script('core', 'dist/systemtags');
script('core', 'systemtags');
script(Application::APP_ID, [
'workflowengine',

View File

@ -143,7 +143,7 @@ class ProfilePageController extends Controller {
$this->profileManager->getProfileParams($targetUser, $visitingUser),
);
\OCP\Util::addScript('core', 'dist/profile');
\OCP\Util::addScript('core', 'profile');
return new TemplateResponse(
'core',

View File

@ -1,5 +1,5 @@
<?php
script('core', 'dist/install');
script('core', 'install');
?>
<input type='hidden' id='hasMySQL' value='<?php p($_['hasMySQL']) ?>'>
<input type='hidden' id='hasSQLite' value='<?php p($_['hasSQLite']) ?>'>

View File

@ -1,6 +1,6 @@
<?php /** @var \OCP\IL10N $l */ ?>
<?php
script('core', 'dist/login');
script('core', 'login');
?>
<div id="login"></div>

View File

@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
script('core', 'dist/recommendedapps');
script('core', 'recommendedapps');
?>

View File

@ -292,7 +292,7 @@ class OC {
// render error page
$template = new OC_Template('', 'update.user', 'guest');
OC_Util::addScript('dist/maintenance');
OC_Util::addScript('maintenance');
OC_Util::addStyle('core', 'guest');
$template->printPage();
die();

View File

@ -48,11 +48,14 @@ class JSResourceLocator extends ResourceLocator {
return;
}
// Extracting the appId and the script file name
$app = substr($script, 0, strpos($script, '/'));
$scriptName = basename($script);
if (strpos($script, '/l10n/') !== false) {
// For language files we try to load them all, so themes can overwrite
// single l10n strings without having to translate all of them.
$found = 0;
$found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js');
$found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js');
$found += $this->appendIfExist($this->serverroot, $script.'.js');
$found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js');
@ -65,16 +68,16 @@ class JSResourceLocator extends ResourceLocator {
} elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js')
|| $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js')
|| $this->appendIfExist($this->serverroot, $script.'.js')
|| $this->appendIfExist($this->serverroot, "dist/$app-$scriptName.js")
|| $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json')
|| $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js')
|| $this->appendIfExist($this->serverroot, 'core/'.$script.'.js')
|| $this->appendIfExist($this->serverroot, "dist/core-$scriptName.js")
|| $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json')
) {
return;
}
$app = substr($script, 0, strpos($script, '/'));
$script = substr($script, strpos($script, '/') + 1);
$app_path = \OC_App::getAppPath($app);
$app_url = \OC_App::getAppWebPath($app);
@ -86,21 +89,21 @@ class JSResourceLocator extends ResourceLocator {
}
// missing translations files fill be ignored
if (strpos($script, 'l10n/') === 0) {
$this->appendIfExist($app_path, $script . '.js', $app_url);
if (strpos($scriptName, 'l10n/') === 0) {
$this->appendIfExist($app_path, $scriptName . '.js', $app_url);
return;
}
if ($app_path === false && $app_url === false) {
$this->logger->error('Could not find resource {resource} to load', [
'resource' => $app . '/' . $script . '.js',
'resource' => $app . '/' . $scriptName . '.js',
'app' => 'jsresourceloader',
]);
return;
}
if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) {
$this->append($app_path, $script . '.js', $app_url);
if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $scriptName.'.json', $app)) {
$this->append($app_path, $scriptName . '.js', $app_url);
}
}

View File

@ -96,7 +96,7 @@ class TemplateLayout extends \OC_Template {
$this->initialState->provideInitialState('core', 'active-app', $this->navigationManager->getActiveEntry());
$this->initialState->provideInitialState('unified-search', 'limit-default', SearchQuery::LIMIT_DEFAULT);
Util::addScript('core', 'dist/unified-search', 'core');
Util::addScript('core', 'unified-search', 'core');
// Add navigation entry
$this->assign('application', '');
@ -209,7 +209,7 @@ class TemplateLayout extends \OC_Template {
}
// Add the js files
$jsFiles = self::findJavascriptFiles(array_merge(\OC_Util::$scripts, Util::getScripts()));
$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
$this->assign('jsfiles', []);
if ($this->config->getSystemValue('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) {
// this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call)

View File

@ -106,7 +106,7 @@ class OC_Template extends \OC\Template\Base {
//meaning the last script/style in this list will be loaded first
if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== TemplateResponse::RENDER_AS_ERROR && !\OCP\Util::needUpgrade()) {
if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
OC_Util::addScript('backgroundjobs', null, true);
OC_Util::addScript('core', 'backgroundjobs', true);
}
}
OC_Util::addStyle('css-variables', null, true);
@ -114,11 +114,11 @@ class OC_Template extends \OC\Template\Base {
OC_Util::addTranslations('core', null, true);
if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
OC_Util::addScript('merged-template-prepend', null, true);
OC_Util::addScript('dist/files_client', null, true);
OC_Util::addScript('dist/files_fileinfo', null, true);
OC_Util::addScript('core', 'merged-template-prepend', true);
OC_Util::addScript('core', 'files_client', true);
OC_Util::addScript('core', 'files_fileinfo', true);
}
OC_Util::addScript('core', 'dist/main', true);
OC_Util::addScript('core', 'main', true);
self::$initTemplateEngineFirstRun = false;
}

View File

@ -7,40 +7,45 @@ const ESLintPlugin = require('eslint-webpack-plugin')
const modules = require('./webpack.modules.js')
const formatOutputFromModules = (modules) => {
// merge all configs into one object, and use AppID to generate the fileNames
// with the following format:
// AppId-fileName: path/to/js-file.js
const moduleEntries = Object.keys(modules).map(moduleKey => {
const module = modules[moduleKey]
const entries = Object.keys(module).map(entryKey => {
const entry = module[entryKey]
return { [`${moduleKey}-${entryKey}`]: entry }
})
return Object.assign({}, ...Object.values(entries))
})
return Object.assign({}, ...Object.values(moduleEntries))
}
const modulesToBuild = () => {
const MODULE = process.env.MODULE
if (MODULE) {
if (!modules[MODULE]) {
throw new Error(`No module "${MODULE}" found`)
}
return modules[MODULE]
return formatOutputFromModules({
[MODULE]: modules[MODULE]
})
}
// merge all configs into one object
return Object.assign({}, ...Object.values(modules))
return formatOutputFromModules(modules)
}
module.exports = {
entry: modulesToBuild(),
output: {
// Step away from the src folder and extract to the js folder
path: path.join(__dirname),
path: path.join(__dirname, 'dist'),
publicPath: '/dist/',
filename: (chunkData) => {
// Get relative path of the src folder
let srcPath = chunkData.chunk.entryModule.context
if (srcPath === null) {
srcPath = chunkData.chunk.entryModule.rootModule.context
}
const relativePath = path.relative(__dirname, srcPath)
// If this is a core source, output in core dist folder
if (relativePath.indexOf('core/src') > -1) {
return path.join('core/js/dist/', '[name].js?v=[contenthash]')
}
// Get out of the shared dist folder and output inside apps js folder
return path.join(relativePath, '..', 'js') + '/[name].js?v=[contenthash]'
},
chunkFilename: 'dist/[name]-[id].js?v=[contenthash]',
filename: '[name].js?v=[contenthash]',
chunkFilename: '[name]-[id].js?v=[contenthash]',
},
module: {

View File

@ -52,6 +52,7 @@ module.exports = {
sidebar: path.join(__dirname, 'apps/files/src', 'sidebar.js'),
templates: path.join(__dirname, 'apps/files/src', 'templates.js'),
'files-app-settings': path.join(__dirname, 'apps/files/src', 'files-app-settings.js'),
'legacy-filelist-search': path.join(__dirname, 'apps/files/src', 'legacy/filelistSearch.js'),
'personal-settings': path.join(__dirname, 'apps/files/src', 'main-personal-settings.js'),
},
files_sharing: {