Skip to content
Snippets Groups Projects
Commit c422d77b authored by Joshua Sedler's avatar Joshua Sedler :cartwheel_tone2:
Browse files

Merge branch '3490266-regression-newest-3.2.x' into '3.x'

Issue #3490266: Regression: Newest 3.2.x version uses vue.runtime.global.prod.js instead of vue.global.prod.js

See merge request !10
parents 4d4faa5e 4b39ff8c
No related branches found
No related tags found
No related merge requests found
Pipeline #352871 passed with warnings
......@@ -22,7 +22,7 @@ The Vue.js Drupal module provides a bridge between Drupal and the Vue.js framewo
3. Update the vuejs module via composer: `composer update 'drupal/vuejs'`
4. Navigate to the `admin/config/development/vue` page.
5. Set the installation type to "Local library".
6. Set the library path to `/package/dist/vue.runtime.global.prod.js` if not already defined so.
6. Set the library path to `/package/dist/vue.global.prod.js` if not already defined so.
### Library installation via manual download
......@@ -31,7 +31,7 @@ The Vue.js Drupal module provides a bridge between Drupal and the Vue.js framewo
2. Extract the tar inside the drupal `libraries/vue` folder.
3. Navigate to the `admin/config/development/vuejs` page.
4. Set the installation type to "Local library".
5. Set the library path to `/libraries/vue/package/dist/vue.runtime.global.prod.js` if not already defined so.
5. Set the library path to `/libraries/vue/package/dist/vue.global.prod.js` if not already defined so.
#### Vue 2
1. Download `https://registry.npmjs.org/vue/-/vue-2.7.16.tgz`
......
vue:
enabled: true
installation: cdn
path: //unpkg.com/vue@3.5.13/dist/vue.runtime.global.prod.js
path: //unpkg.com/vue@3.5.13/dist/vue.global.prod.js
cdn_provider: unpkg
cdn_version: 3.5.13
petitevue:
......
......@@ -97,7 +97,7 @@ final class SettingsForm extends ConfigFormBase {
'#title' => $this->t('Library path'),
'#default_value' => $vueSettings['path'],
'#attributes' => [
'placeholder' => '/libraries/vue/package/dist/vue.runtime.global.prod.js',
'placeholder' => '/libraries/vue/package/dist/vue.global.prod.js',
],
'#description' => $this->t('The path to the library file. See <a href=:link>here</a> for more infos on how to setup the vue library locally. Leave empty to disable the library.', [':link' => Url::fromRoute('help.page', ['name' => 'vuejs'])->toString()]),
'#states' => [
......@@ -255,7 +255,7 @@ final class SettingsForm extends ConfigFormBase {
if ($vueFormValues['installation'] === 'cdn' && (bool) $enableVueLibrary) {
// The file name differs from Vue 2 to Vue 3, so we need to do a version
// compare here:
$fileName = version_compare($vueFormValues['cdn_version'], '3.0.0', '>=') ? 'vue.runtime.global.prod.js' : 'vue.global.prod.js';
$fileName = version_compare($vueFormValues['cdn_version'], '3.0.0', '>=') ? 'vue.global.prod.js' : 'vue.min.js';
switch ($vueFormValues['cdn_provider']) {
case 'jsdelivr':
$vueFormValues['path'] = '//cdn.jsdelivr.net/npm/vue@' . $vueFormValues['cdn_version'] . '/dist/' . $fileName;
......
......@@ -7,6 +7,8 @@
* @ingroup vuejs
*/
use Drupal\Core\Url;
/**
* Implements hook_requirements().
*/
......@@ -137,3 +139,41 @@ function vuejs_update_93003(&$sandbox) {
// Clear library discovery cache, so the new settings are picked up:
\Drupal::service('library.discovery')->clearCachedDefinitions();
}
/**
* Fixes regression.
*
* Introduced in https://www.drupal.org/project/vuejs/issues/3488596.
*/
function vuejs_update_93004(&$sandbox) {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('vuejs.settings');
// Set the vue config:
$vueConfig = $config->get('vue');
$oldPath = $vueConfig['path'];
$newPath = NULL;
$changed = FALSE;
if (str_contains($oldPath, 'vue.runtime.global.prod.js')) {
$newPath = str_replace('vue.runtime.global.prod.js', 'vue.global.prod.js', $oldPath);
$changed = TRUE;
}
elseif (str_contains($oldPath, 'vue.global.prod.js') && version_compare($vueConfig['cdn_version'], '3.0.0', '<')) {
$newPath = str_replace('vue.global.prod.js', 'vue.min.js', $oldPath);
$changed = TRUE;
}
if ($changed) {
$config->set('vue.path', $newPath);
$config->save(TRUE);
// Clear library discovery cache, so the new settings are picked up:
\Drupal::service('library.discovery')->clearCachedDefinitions();
\Drupal::logger('vuejs')->info(t("Fixed vue.js path in the settings from %oldPath to %newPath, because the old file isn't supported. See :route to modify the path if the new path is undesired", [
'%oldPath' => $oldPath,
'%newPath' => $newPath,
':route' => Url::fromRoute('vuejs.settings')->toString(),
]));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment