Skip to content

Commit e4bd4f2

Browse files
Replace JS toolchain by asset-mapper when testing ux-turbo
1 parent 623fe50 commit e4bd4f2

File tree

12 files changed

+61
-86
lines changed

12 files changed

+61
-86
lines changed

.github/workflows/test-turbo.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
php-version: ['8.1', '8.4']
44+
php-version: ['8.1', '8.3', '8.4']
4545
include:
4646
- php-version: '8.1'
4747
dependency-version: 'lowest'
48+
- php-version: '8.3'
49+
dependency-version: 'highest'
4850
- php-version: '8.4'
4951
dependency-version: 'highest'
5052

@@ -65,8 +67,6 @@ jobs:
6567
- name: Checkout
6668
uses: actions/checkout@v4
6769

68-
- run: corepack enable
69-
7070
- name: Setup PHP
7171
uses: shivammathur/setup-php@v2
7272
with:
@@ -75,31 +75,17 @@ jobs:
7575
- name: Install symfony/flex
7676
run: composer global config allow-plugins.symfony/flex true && composer global require symfony/flex
7777

78-
- name: Install Turbo packages
78+
- name: Install dependencies with composer
7979
uses: ramsey/composer-install@v3
8080
with:
8181
working-directory: src/Turbo
8282
dependency-versions: ${{ matrix.dependency-version }}
8383

84-
- name: Get yarn cache directory path
85-
id: yarn-cache-dir-path
86-
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
87-
88-
- uses: actions/cache@v4
89-
id: yarn-cache
90-
with:
91-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
92-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
93-
restore-keys: |
94-
${{ runner.os }}-yarn-
95-
9684
- name: Install JavaScript dependencies
9785
working-directory: src/Turbo/tests/app
98-
run: touch yarn.lock && yarn install --mode update-lockfile && yarn install
99-
100-
- name: Build JavaScript
101-
working-directory: src/Turbo/tests/app
102-
run: yarn build
86+
run: |
87+
php public/index.php importmap:install
88+
php public/index.php asset-map:compile
10389
10490
- name: Create DB
10591
working-directory: src/Turbo/tests/app

src/Turbo/.gitignore

Lines changed: 5 additions & 4 deletions
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

src/Turbo/composer.json

Lines changed: 4 additions & 4 deletions
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
},

src/Turbo/tests/BroadcastTest.php

Lines changed: 2 additions & 2 deletions
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();

src/Turbo/tests/app/Kernel.php

Lines changed: 4 additions & 4 deletions
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,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": {},
3+
"entrypoints": []
4+
}

src/Turbo/tests/app/assets/controllers/.gitignore

Whitespace-only changes.

src/Turbo/tests/app/importmap.php

Lines changed: 29 additions & 0 deletions
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 <fabien@symfony.com>
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+
];

src/Turbo/tests/app/package.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Turbo/tests/app/public/index.php

Lines changed: 3 additions & 0 deletions
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') {

src/Turbo/tests/app/templates/base.html.twig

Lines changed: 3 additions & 1 deletion
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">

src/Turbo/tests/app/webpack.config.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)