Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
msmuenchen opened this issue Apr 25, 2024 · 0 comments

Comments

@msmuenchen
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant