Skip to content

Commit 369a608

Browse files
committed
bug #910 Fix stimulus version bug (weaverryan)
This PR was squashed before being merged into the main branch. Discussion ---------- Fix stimulus version bug stimulus-bridge 2.0 has been released! This fixes a bug where I forgot to allow v2. It also stops relying on the version (which wouldn't work when v3 comes out) to determine if the plugin (from v1) should be used or not. It also issues a deprecation warning to help users upgrade. Commits ------- 0808705 Fix stimulus version bug
2 parents 909f56d + 0808705 commit 369a608

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

fixtures/stimulus/assets/controllers.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"controllers": {
33
"@symfony/mock-module": {
44
"mock": {
5-
"webpackMode": "lazy",
5+
"fetch": "lazy",
66
"enabled": true,
77
"autoimport": {
88
"@symfony/mock-module/dist/style.css": true

lib/plugins/stimulus-bridge.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,32 @@ const loaderFeatures = require('../features');
1414
const fs = require('fs');
1515
const packageHelper = require('../package-helper');
1616
const semver = require('semver');
17+
const logger = require('../logger');
1718

1819
/**
1920
* Support for @symfony/stimulus-bridge 1.1 or lower.
2021
*
2122
* @param {Array} plugins
2223
* @param {WebpackConfig} webpackConfig
23-
* @deprecated
2424
* @return {void}
2525
*/
2626
module.exports = function(plugins, webpackConfig) {
2727
if (webpackConfig.useStimulusBridge) {
2828
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('stimulus');
2929

30-
const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge');
31-
if (semver.satisfies(version, '^2.0.0')) {
30+
try {
31+
require.resolve('@symfony/stimulus-bridge/webpack-helper'); // eslint-disable-line node/no-unpublished-require, node/no-missing-require
32+
} catch (e) {
3233
// package is new and doesn't require this plugin
34+
const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge');
35+
if (semver.satisfies(version, '^1.0.0')) {
36+
logger.deprecation('Your version of @symfony/stimulus-bridge is out-of-date. Please upgrade to the latest version');
37+
}
3338

3439
return;
3540
}
3641

37-
const createPlugin = require('@symfony/stimulus-bridge/webpack-helper'); // eslint-disable-line node/no-unpublished-require
42+
const createPlugin = require('@symfony/stimulus-bridge/webpack-helper'); // eslint-disable-line node/no-unpublished-require, node/no-missing-require
3843

3944
plugins.push({
4045
plugin: createPlugin(JSON.parse(fs.readFileSync(webpackConfig.stimulusOptions.controllersJsonPath))),

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@babel/preset-react": "^7.0.0",
5858
"@babel/preset-typescript": "^7.0.0",
5959
"@symfony/mock-module": "file:fixtures/stimulus/mock-module",
60-
"@symfony/stimulus-bridge": "^1.1.0",
60+
"@symfony/stimulus-bridge": "^1.1.0 || ^2.0.0",
6161
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
6262
"@vue/babel-preset-jsx": "^1.0.0",
6363
"@vue/compiler-sfc": "^3.0.2",

yarn.lock

+7-14
Original file line numberDiff line numberDiff line change
@@ -995,12 +995,12 @@
995995
"@symfony/mock-module@file:fixtures/stimulus/mock-module":
996996
version "1.0.0"
997997

998-
"@symfony/stimulus-bridge@^1.1.0":
999-
version "1.1.0"
1000-
resolved "https://registry.yarnpkg.com/@symfony/stimulus-bridge/-/stimulus-bridge-1.1.0.tgz#34548c633fe49bcda84cc812939f63640e698af7"
1001-
integrity sha512-Sz8iwKQHBjrgCnxCGwH87S/J/Min0gX3EuXJaHi4vpibY3BjVm+WYuP8+OYPkMIROPyNZKYgTffFfJLBAFLwFQ==
998+
"@symfony/stimulus-bridge@^1.1.0 || ^2.0.0":
999+
version "2.0.0"
1000+
resolved "https://registry.yarnpkg.com/@symfony/stimulus-bridge/-/stimulus-bridge-2.0.0.tgz#52cbf5c8524dec1a6c154a535bc82fedf1987b06"
1001+
integrity sha512-sq8FMQDmG5rtcmXwK+SQ2o5dEEqjaxpFjP/EYzl3qbGnED099XxOQDPnbrtVSIRRPlWEsuoTalD9B1fAdeFp0Q==
10021002
dependencies:
1003-
webpack-virtual-modules "^0.3.2"
1003+
acorn "^8.0.5"
10041004

10051005
"@types/anymatch@*":
10061006
version "1.3.1"
@@ -1473,7 +1473,7 @@ acorn@^7.4.0:
14731473
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
14741474
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
14751475

1476-
acorn@^8.0.4:
1476+
acorn@^8.0.4, acorn@^8.0.5:
14771477
version "8.0.5"
14781478
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.0.5.tgz#a3bfb872a74a6a7f661bc81b9849d9cac12601b7"
14791479
integrity sha512-v+DieK/HJkJOpFBETDJioequtc3PfxsWMaxIdIwujtF7FEV/MAyDQLlm6/zPvr7Mix07mLh6ccVwIsloceodlg==
@@ -2616,7 +2616,7 @@ [email protected]:
26162616
dependencies:
26172617
ms "2.1.2"
26182618

2619-
debug@^3.0.0, debug@^3.1.1, debug@^3.2.6:
2619+
debug@^3.1.1, debug@^3.2.6:
26202620
version "3.2.7"
26212621
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
26222622
integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
@@ -7579,13 +7579,6 @@ webpack-sources@^2.1.1, webpack-sources@^2.2.0:
75797579
source-list-map "^2.0.1"
75807580
source-map "^0.6.1"
75817581

7582-
webpack-virtual-modules@^0.3.2:
7583-
version "0.3.2"
7584-
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.3.2.tgz#b7baa30971a22d99451f897db053af48ec29ad2c"
7585-
integrity sha512-RXQXioY6MhzM4CNQwmBwKXYgBs6ulaiQ8bkNQEl2J6Z+V+s7lgl/wGvaI/I0dLnYKB8cKsxQc17QOAVIphPLDw==
7586-
dependencies:
7587-
debug "^3.0.0"
7588-
75897582
webpack@^5.12:
75907583
version "5.18.0"
75917584
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.18.0.tgz#bbcf13094aa0da0534d513f27d7ee72d74e499c6"

0 commit comments

Comments
 (0)