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
  1. 4
      apps/files/lib/Controller/ViewController.php
  2. 2
      apps/files/lib/Listener/LoadSidebarListener.php
  3. 3
      apps/files/src/main.js
  4. 2
      apps/files/templates/settings-personal.php
  5. 4
      apps/files_sharing/lib/AppInfo/Application.php
  6. 4
      apps/files_sharing/lib/Listener/LoadAdditionalListener.php
  7. 2
      apps/files_sharing/lib/Listener/LoadSidebarListener.php
  8. 2
      apps/files_sharing/templates/Settings/personal.php
  9. 2
      apps/systemtags/lib/AppInfo/Application.php
  10. 2
      apps/systemtags/templates/admin.php
  11. 2
      apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
  12. 2
      apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php
  13. 2
      core/Controller/ProfilePageController.php
  14. 2
      core/templates/installation.php
  15. 2
      core/templates/login.php
  16. 2
      core/templates/recommendedapps.php
  17. 2
      lib/base.php
  18. 19
      lib/private/Template/JSResourceLocator.php
  19. 4
      lib/private/TemplateLayout.php
  20. 10
      lib/private/legacy/OC_Template.php
  21. 45
      webpack.common.js
  22. 1
      webpack.modules.js

@ -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

@ -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');

@ -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">

@ -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);

@ -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');
}
}

@ -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');
}
}

@ -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">

@ -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');
}
);

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

@ -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');
}
}

@ -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',

@ -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',

@ -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']) ?>'>

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

@ -21,7 +21,7 @@
* 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
$template = new OC_Template('', 'update.user', 'guest');
OC_Util::addScript('dist/maintenance');
OC_Util::addScript('maintenance');
OC_Util::addStyle('core', 'guest');
$template->printPage();
die();

@ -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);
}
}

@ -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)

@ -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;
}

@ -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: {

@ -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: {

Loading…
Cancel
Save