Skip to content

Commit 577f34a

Browse files
Replace JS toolchain by asset-mapper when testing ux-turbo
1 parent 6655a1b commit 577f34a

File tree

11 files changed

+54
-65
lines changed

11 files changed

+54
-65
lines changed

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
/.phpunit.result.cache
44
/composer.phar
55
/composer.lock
6+
/drivers/
67
/phpunit.xml
7-
/vendor/
8-
/tests/app/var
8+
/tests/app/assets/vendor/
9+
/tests/app/public/assets/
910
/tests/app/public/build/
11+
/tests/app/var/
12+
/vendor/
1013
node_modules/
11-
package-lock.json
12-
yarn.lock

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@
4141
"doctrine/doctrine-bundle": "^2.4.3",
4242
"doctrine/orm": "^2.8 | 3.0",
4343
"phpstan/phpstan": "^1.10",
44+
"symfony/asset-mapper": "^6.4|^7.0",
4445
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
4546
"symfony/form": "^5.4|^6.0|^7.0",
46-
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
47+
"symfony/framework-bundle": "^6.4|^7.0",
4748
"symfony/mercure-bundle": "^0.3.7",
4849
"symfony/messenger": "^5.4|^6.0|^7.0",
49-
"symfony/panther": "^1.0|^2.0",
50+
"symfony/panther": "^2.1",
5051
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
5152
"symfony/process": "^5.4|6.3.*|^7.0",
5253
"symfony/property-access": "^5.4|^6.0|^7.0",
5354
"symfony/security-core": "^5.4|^6.0|^7.0",
5455
"symfony/stopwatch": "^5.4|^6.0|^7.0",
5556
"symfony/ux-twig-component": "^2.21",
56-
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
57+
"symfony/twig-bundle": "^6.4|^7.0",
5758
"symfony/web-profiler-bundle": "^5.4|^6.0|^7.0",
58-
"symfony/webpack-encore-bundle": "^2.1.1",
5959
"symfony/expression-language": "^5.4|^6.0|^7.0",
6060
"dbrekelmans/bdi": "dev-main"
6161
},

tests/BroadcastTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class BroadcastTest extends PantherTestCase
2626

2727
protected function setUp(): void
2828
{
29-
if (!file_exists(__DIR__.'/app/public/build')) {
30-
throw new \Exception(\sprintf('Move into "%s" and execute Encore before running this test.', realpath(__DIR__.'/app')));
29+
if (!file_exists(__DIR__.'/app/assets/vendor/installed.php')) {
30+
throw new \Exception(\sprintf('Move into "%s" and execute `php public/index.php importmap:install` before running this test.', realpath(__DIR__.'/app')));
3131
}
3232

3333
parent::setUp();

tests/app/Kernel.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use Symfony\UX\StimulusBundle\StimulusBundle;
4040
use Symfony\UX\Turbo\TurboBundle;
4141
use Symfony\UX\TwigComponent\TwigComponentBundle;
42-
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
4342
use Twig\Environment;
4443

4544
/**
@@ -57,7 +56,6 @@ public function registerBundles(): iterable
5756
yield new MercureBundle();
5857
yield new TwigComponentBundle();
5958
yield new TurboBundle();
60-
yield new WebpackEncoreBundle();
6159
yield new StimulusBundle();
6260
yield new WebProfilerBundle();
6361
yield new DebugBundle();
@@ -67,10 +65,13 @@ protected function configureContainer(ContainerConfigurator $container): void
6765
{
6866
$container->extension('framework', [
6967
'secret' => 'ChangeMe',
70-
'test' => 'test' === ($_SERVER['APP_ENV'] ?? 'dev'),
68+
'test' => 'test' === $this->environment,
7169
'router' => [
7270
'utf8' => true,
7371
],
72+
'asset_mapper' => [
73+
'paths' => ['assets/'],
74+
],
7475
'profiler' => [
7576
'only_exceptions' => false,
7677
],
@@ -108,7 +109,6 @@ protected function configureContainer(ContainerConfigurator $container): void
108109
$container
109110
->extension('doctrine', $doctrineConfig);
110111

111-
$container->extension('webpack_encore', ['output_path' => 'build']);
112112
$container->extension('web_profiler', [
113113
'toolbar' => true,
114114
'intercept_redirects' => false,

tests/app/assets/controllers.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": {},
3+
"entrypoints": []
4+
}

tests/app/assets/controllers/.gitignore

Whitespace-only changes.

tests/app/importmap.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
return [
13+
'app' => [
14+
'path' => './assets/app.js',
15+
'entrypoint' => true,
16+
],
17+
'@hotwired/stimulus' => [
18+
'version' => '3.2.2',
19+
],
20+
'@symfony/stimulus-bundle' => [
21+
'path' => '../../vendor/symfony/stimulus-bundle/assets/dist/loader.js',
22+
],
23+
'@symfony/ux-turbo/dist/turbo_stream_controller' => [
24+
'path' => '../../assets/dist/turbo_stream_controller.js',
25+
],
26+
'@hotwired/turbo' => [
27+
'version' => '7.3.0',
28+
],
29+
];

tests/app/package.json

-27
This file was deleted.

tests/app/public/index.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111

1212
use App\Kernel;
1313
use Symfony\Bundle\FrameworkBundle\Console\Application;
14+
use Symfony\Component\ErrorHandler\Debug;
1415
use Symfony\Component\HttpFoundation\Request;
1516

1617
require __DIR__.'/../../../vendor/autoload.php';
1718

19+
Debug::enable();
20+
1821
$app = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? true);
1922

2023
if (\PHP_SAPI === 'cli') {

tests/app/templates/base.html.twig

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<meta charset="UTF-8">
55
<title>Symfony UX Turbo</title>
66
{% block stylesheets %}{% endblock %}
7-
{{ encore_entry_script_tags('app') }}
7+
{% block javascripts %}
8+
{% block importmap %}{{ importmap('app') }}{% endblock %}
9+
{% endblock %}
810
</head>
911
<body>
1012
<nav id="navigation">

tests/app/webpack.config.js

-23
This file was deleted.

0 commit comments

Comments
 (0)