Move bundles to /dist

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
pull/30020/head
John Molakvoæ (skjnldsv) 3 years ago committed by John Molakvoæ
parent 8ee7c20e4d
commit b664aad7ab
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF

@ -197,7 +197,9 @@ class ViewController extends Controller {
// Load the files we need // Load the files we need
\OCP\Util::addStyle('files', 'merged'); \OCP\Util::addStyle('files', 'merged');
\OCP\Util::addScript('files', 'merged-index'); \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 // mostly for the home storage's free space
// FIXME: Make non static // FIXME: Make non static

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

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

@ -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"> <div id="files-personal-settings" class="section">

@ -113,7 +113,7 @@ class Application extends App implements IBootstrap {
/** /**
* Always add main sharing script * 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(LoadSidebar::class, LoadSidebarListener::class);
$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () { $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(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);

@ -38,9 +38,9 @@ class LoadAdditionalListener implements IEventListener {
} }
// After files for the files list shared content // 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 // 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'); Util::addStyle(Application::APP_ID, 'icons');
} }
} }

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

@ -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"> <div id="files-sharing-personal-settings" class="section">

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

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

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

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

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

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

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

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

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

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

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

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

@ -7,40 +7,45 @@ const ESLintPlugin = require('eslint-webpack-plugin')
const modules = require('./webpack.modules.js') 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 modulesToBuild = () => {
const MODULE = process.env.MODULE const MODULE = process.env.MODULE
if (MODULE) { if (MODULE) {
if (!modules[MODULE]) { if (!modules[MODULE]) {
throw new Error(`No module "${MODULE}" found`) 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 = { module.exports = {
entry: modulesToBuild(), entry: modulesToBuild(),
output: { output: {
// Step away from the src folder and extract to the js folder // Step away from the src folder and extract to the js folder
path: path.join(__dirname), path: path.join(__dirname, 'dist'),
publicPath: '/dist/', publicPath: '/dist/',
filename: (chunkData) => { filename: '[name].js?v=[contenthash]',
// Get relative path of the src folder chunkFilename: '[name]-[id].js?v=[contenthash]',
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]',
}, },
module: { module: {

@ -52,6 +52,7 @@ module.exports = {
sidebar: path.join(__dirname, 'apps/files/src', 'sidebar.js'), sidebar: path.join(__dirname, 'apps/files/src', 'sidebar.js'),
templates: path.join(__dirname, 'apps/files/src', 'templates.js'), templates: path.join(__dirname, 'apps/files/src', 'templates.js'),
'files-app-settings': path.join(__dirname, 'apps/files/src', 'files-app-settings.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'), 'personal-settings': path.join(__dirname, 'apps/files/src', 'main-personal-settings.js'),
}, },
files_sharing: { files_sharing: {

Loading…
Cancel
Save