File tree 6 files changed +74
-5
lines changed 6 files changed +74
-5
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ class WebpackConfig {
131
131
resolveUrlLoader : true ,
132
132
resolveUrlLoaderOptions : { }
133
133
} ;
134
+ /** @deprecated */
135
+ this . stimulusOptions = {
136
+ controllerJsonPath : null ,
137
+ } ;
134
138
this . preactOptions = {
135
139
preactCompat : false
136
140
} ;
@@ -682,6 +686,7 @@ class WebpackConfig {
682
686
this . addEntry ( name , rootDir + '/' + controllersData . entrypoints [ name ] ) ;
683
687
}
684
688
689
+ this . stimulusOptions . controllersJsonPath = controllerJsonPath ;
685
690
this . addAliases ( {
686
691
'@symfony/stimulus-bridge/controllers.json' : path . resolve ( controllerJsonPath ) ,
687
692
} ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ const friendlyErrorPluginUtil = require('./plugins/friendly-errors');
38
38
const assetOutputDisplay = require ( './plugins/asset-output-display' ) ;
39
39
const notifierPluginUtil = require ( './plugins/notifier' ) ;
40
40
const PluginPriorities = require ( './plugins/plugin-priorities' ) ;
41
+ const stimulusBridge = require ( './plugins/stimulus-bridge' ) ;
41
42
const applyOptionsCallback = require ( './utils/apply-options-callback' ) ;
42
43
const copyEntryTmpName = require ( './utils/copyEntryTmpName' ) ;
43
44
const getVueVersion = require ( './utils/get-vue-version' ) ;
@@ -422,6 +423,8 @@ class ConfigGenerator {
422
423
423
424
variableProviderPluginUtil ( plugins , this . webpackConfig ) ;
424
425
426
+ stimulusBridge ( plugins , this . webpackConfig ) ;
427
+
425
428
cleanPluginUtil ( plugins , this . webpackConfig ) ;
426
429
427
430
definePluginUtil ( plugins , this . webpackConfig ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * This file is part of the Symfony Webpack Encore package.
3
+ *
4
+ * (c) Fabien Potencier <[email protected] >
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ 'use strict' ;
11
+
12
+ const WebpackConfig = require ( '../WebpackConfig' ) ; //eslint-disable-line no-unused-vars
13
+ const loaderFeatures = require ( '../features' ) ;
14
+ const fs = require ( 'fs' ) ;
15
+ const packageHelper = require ( '../package-helper' ) ;
16
+ const semver = require ( 'semver' ) ;
17
+
18
+ /**
19
+ * Support for @symfony/stimulus-bridge 1.1 or lower.
20
+ *
21
+ * @param {Array } plugins
22
+ * @param {WebpackConfig } webpackConfig
23
+ * @deprecated
24
+ * @return {void }
25
+ */
26
+ module . exports = function ( plugins , webpackConfig ) {
27
+ if ( webpackConfig . useStimulusBridge ) {
28
+ loaderFeatures . ensurePackagesExistAndAreCorrectVersion ( 'stimulus' ) ;
29
+
30
+ const version = packageHelper . getPackageVersion ( '@symfony/stimulus-bridge' ) ;
31
+ if ( semver . satisfies ( version , '^1.2.0' ) ) {
32
+ // package is new and doesn't require this plugin
33
+
34
+ return ;
35
+ }
36
+
37
+ const createPlugin = require ( '@symfony/stimulus-bridge/webpack-helper' ) ; // eslint-disable-line node/no-unpublished-require
38
+
39
+ plugins . push ( {
40
+ plugin : createPlugin ( JSON . parse ( fs . readFileSync ( webpackConfig . stimulusOptions . controllersJsonPath ) ) ) ,
41
+ } ) ;
42
+ }
43
+ } ;
Original file line number Diff line number Diff line change 59
59
"@babel/preset-react" : " ^7.0.0" ,
60
60
"@babel/preset-typescript" : " ^7.0.0" ,
61
61
"@symfony/mock-module" : " file:fixtures/stimulus/mock-module" ,
62
- "@symfony/stimulus-bridge" : " git://github.com/symfony/stimulus-bridge#main " ,
62
+ "@symfony/stimulus-bridge" : " ^1.1.0 " ,
63
63
"@vue/babel-helper-vue-jsx-merge-props" : " ^1.0.0" ,
64
64
"@vue/babel-preset-jsx" : " ^1.0.0" ,
65
65
"@vue/compiler-sfc" : " ^3.0.2" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const path = require('path');
18
18
const testSetup = require ( './helpers/setup' ) ;
19
19
const fs = require ( 'fs-extra' ) ;
20
20
const getVueVersion = require ( '../lib/utils/get-vue-version' ) ;
21
+ const packageHelper = require ( '../lib/package-helper' ) ;
22
+ const semver = require ( 'semver' ) ;
21
23
22
24
function createWebpackConfig ( outputDirName = '' , command , argv = { } ) {
23
25
const webpackConfig = testSetup . createWebpackConfig (
@@ -1913,9 +1915,17 @@ module.exports = {
1913
1915
} ) ;
1914
1916
} ) ;
1915
1917
1916
- it ( 'Symfony - Stimulus standard app is built correctly' , ( done ) => {
1918
+ it ( 'Symfony - Stimulus standard app is built correctly' , function ( done ) {
1917
1919
const appDir = testSetup . createTestAppDir ( ) ;
1918
1920
1921
+ const version = packageHelper . getPackageVersion ( '@symfony/stimulus-bridge' ) ;
1922
+ if ( ! semver . satisfies ( version , '^1.2.0' ) ) {
1923
+ // we support the old version, but it's not tested
1924
+ this . skip ( ) ;
1925
+
1926
+ return ;
1927
+ }
1928
+
1919
1929
const config = testSetup . createWebpackConfig ( appDir , 'www/build' , 'dev' ) ;
1920
1930
config . enableSingleRuntimeChunk ( ) ;
1921
1931
config . setPublicPath ( '/build' ) ;
Original file line number Diff line number Diff line change 973
973
" @symfony/mock-module@file:fixtures/stimulus/mock-module " :
974
974
version "1.0.0"
975
975
976
- " @symfony/stimulus-bridge@git://github.com/symfony/stimulus-bridge#main " :
976
+ " @symfony/stimulus-bridge@^1.1.0 " :
977
977
version "1.1.0"
978
- resolved "git://github.com/symfony/stimulus-bridge#a720035de8c3d6f4dac6af097364ba4f92bf187f"
978
+ resolved "https://registry.yarnpkg.com/@symfony/stimulus-bridge/-/stimulus-bridge-1.1.0.tgz#34548c633fe49bcda84cc812939f63640e698af7"
979
+ integrity sha512-Sz8iwKQHBjrgCnxCGwH87S/J/Min0gX3EuXJaHi4vpibY3BjVm+WYuP8+OYPkMIROPyNZKYgTffFfJLBAFLwFQ==
979
980
dependencies :
980
- " @babel/plugin-proposal-class-properties " " ^7.12.1 "
981
+ webpack-virtual-modules "^0.3.2 "
981
982
982
983
" @types/anymatch@* " :
983
984
version "1.3.1"
@@ -8234,6 +8235,13 @@ webpack-virtual-modules@^0.2.2:
8234
8235
dependencies :
8235
8236
debug "^3.0.0"
8236
8237
8238
+ webpack-virtual-modules@^0.3.2 :
8239
+ version "0.3.2"
8240
+ resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.3.2.tgz#b7baa30971a22d99451f897db053af48ec29ad2c"
8241
+ integrity sha512-RXQXioY6MhzM4CNQwmBwKXYgBs6ulaiQ8bkNQEl2J6Z+V+s7lgl/wGvaI/I0dLnYKB8cKsxQc17QOAVIphPLDw==
8242
+ dependencies :
8243
+ debug "^3.0.0"
8244
+
8237
8245
webpack@^5.12 :
8238
8246
version "5.12.2"
8239
8247
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.12.2.tgz#f79574cdb7a4ef711c5f47f3d189e045a14217e5"
You can’t perform that action at this time.
0 commit comments