Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fixtures/stimulus/assets/controllers.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
}
}
},
"entrypoints": []
"entrypoints": {
"@symfony/mock-module/entrypoint": "@symfony/mock-module/dist/entrypoint.js"
}
}
1 change: 1 addition & 0 deletions fixtures/stimulus/mock-module/dist/entrypoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello from the mock module entrypoint!');
3 changes: 3 additions & 0 deletions fixtures/stimulus/mock-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"@symfony/mock-module/dist/style.css": true
}
}
},
"entrypoints": {
"@symfony/mock-module/entrypoint": "@symfony/mock-module/dist/entrypoint.js"
}
}
}
6 changes: 6 additions & 0 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,12 @@ class WebpackConfig {
const rootDir = path.dirname(path.resolve(controllerJsonPath));

for (let name in controllersData.entrypoints) {
// Imported entrypoint (e.g. from node_modules) should be used as-is
if (controllersData.entrypoints[name].startsWith('@')) {

@Kocal Kocal Feb 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this one, only scoped-packages are supported? What if the package name is tototata? It can't define aliases?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my guess yes @Kocal

This is for package.json imported from a bundle, not for a dependency imported directly in the app package.json (unless i'm wrong)

We already recommend to use the @ in the package.json name of a bundle:
image

The entrypoint section that package.json is read by symfony flex and added in /assets/controllers.json of the app as it.

I'm not sure of the purpose, maybe it was to be completed by a recipe that would copy that entrypoint inside assets folder to be used directly ?

By adding these line, we allow to reference to the assets from the bundle, and yes only if the package name start with @.

Maybe an other option could be "if not start by ./" but maybe it could break somewhere.

Or improve flex to add some directive telling the entrypoint added came from a bundle?

WDYT ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, but to be honest I'm not sure about everything here and I can't give you a yes or no, or a better alternative... 😬

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kocal maybe we should invert the check instead.

First, resolve the entrypoint relative to the controllers.json root dir and use it if the file exists, like before. Otherwise, pass the entrypoint as-is to webpack and let webpack resolve it.

This should cover both scoped packages (@acme/package/...) and non-scoped packages (tototata/...). If webpack cannot resolve it, it will raise the usual module resolution error.

I will work on a patch update for this

this.addEntry(name, controllersData.entrypoints[name]);
continue;
}

this.addEntry(name, rootDir + '/' + controllersData.entrypoints[name]);
}

Expand Down
4 changes: 3 additions & 1 deletion test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ module.exports = {
const appDir = testSetup.createTestAppDir();

const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge');
if (!semver.satisfies(version, '^3.0.0')) {
if (!semver.satisfies(version, '>3.0.0')) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had the v4.0.0 on my side, so this test wasn't triggered. That's why I changed the comparison here

// we support the old version, but it's not tested
this.skip();

Expand All @@ -2045,12 +2045,14 @@ module.exports = {
'node_modules_symfony_mock-module_dist_controller_js.js',
'entrypoints.json',
'runtime.js',
'@symfony/mock-module/entrypoint.js'
]);

// test controllers and style are shipped
webpackAssert.assertOutputFileContains('main.js', 'app-controller');
webpackAssert.assertOutputFileContains('node_modules_symfony_mock-module_dist_controller_js.js', 'mock-module-controller');
webpackAssert.assertOutputFileContains('main.css', 'body {}');
webpackAssert.assertOutputFileContains('entrypoints.json', '@symfony/mock-module/entrypoint');

done();
});
Expand Down
Loading