Skip to content

[symfony/webpack-encore-bundle] [symfony/webapp-pack] Collision in creation of assets/bootstrap.js leading to corrupt file #1309

Open
@msmuenchen

Description

@msmuenchen

When installing both symfony/webapp-pack and symfony/webpack-encore-bundle simultaneously, the resulting assets/bootstrap.js file is corrupt:

import { startStimulusApp } from '@symfony/stimulus-bundle';

const app = startStimulusApp();
import { startStimulusApp } from '@symfony/stimulus-bridge';

// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
    '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
    true,
    /\.[jt]sx?$/
));
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);

Attempting to compile that yields an error:

Syntax Error: Identifier 'startStimulusApp' has already been declared. (4:9)

  2 |
  3 | const app = startStimulusApp();
> 4 | import { startStimulusApp } from '@symfony/stimulus-bridge';

This should not happen in the first place given that

  • symfony/stimulus-bundle/2.13/manifest.json carries a conflict entry for symfony/webpack-encore-bundle <=2.0
  • the installed versions are 2.17.0 for stimulus-bundle and 2.1.1 for webpack-encore-bundle
  • only the 1.9 recipe for webpack-encore-bundle actually contains bootstrap.js (symfony/webpack-encore-bundle/1.9/assets/bootstrap.js) whereas the 2.0 recipe does not - but why is the 1.9 recipe then executed?

It should be noted that installing the webapp pack first and then installing webpack-encore-bundle directly afterwards works, I assume that something in the Composer interface is broken and doesn't recognize that both bundles are being installed?

Possibly it's also related to this issue, where stimulus got (finally) removed - but again, that shouldn't be the case since webpack-encore-bundle is clearly the newer version that shouldn't ship with stimulus?

Logs from composer require

  - Locking symfony/stimulus-bundle (v2.17.0)
  - Locking symfony/webapp-pack (v1.3.0)
  - Locking symfony/webpack-encore-bundle (v2.1.1)
...
  - Installing symfony/stimulus-bundle (v2.17.0): Extracting archive
  - Installing symfony/webapp-pack (v1.3.0): Extracting archive
  - Installing symfony/webpack-encore-bundle (v2.1.1): Extracting archive
...
  - Configuring symfony/stimulus-bundle (>=2.13): From github.com/symfony/recipes:main
  - Configuring symfony/webpack-encore-bundle (>=2.0): From github.com/symfony/recipes:main

Reproduce

Environment:

Composer version 2.7.4 2024-04-22 21:17:03
PHP version 8.3.6 (/opt/local/bin/php83)
  1. Create an empty skeleton project: composer create-project symfony/skeleton:"7.0.*" my_project_directory
  2. Install both the webapp pack and webpack-encore-bundle at the same time: cd my_project_directory && composer require symfony/webapp-pack symfony/webpack-encore-bundle
  3. Check content: cat assets/bootstrap.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions