Skip to content

Commit 2909057

Browse files
committed
Tweaks from review
1 parent 27aa1fb commit 2909057

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Remove the following line in the mentioned file: it's not needed anymore:
5757

5858
The bridge works by reading a `controllers.json` file that is automatically
5959
updated by Symfony Flex whenever you download a UX-powered package. For
60-
example, after running `composer require symfony/ux-dropzone.js`, it will
60+
example, after running `composer require symfony/ux-dropzone`, it will
6161
look like this:
6262

6363
```json
@@ -81,15 +81,17 @@ Each item under `controllers` will cause a Stimulus controller to be
8181
registered with a specific name - in this case the controller would
8282
be called `symfony--ux-dropzone--dropzone` (the `/` becomes `--`).
8383

84-
By default, the new controller will be always be included in your
84+
By default, the new controller will always be included in your
8585
JavaScript package. You can control that with the `webpackMode` option,
8686
ordered from least to most lazy:
8787

88-
* `webpackMode: 'eager'`: include in JavaScript that is downloaded on page load
89-
* `webpackMode: 'lazy'`: isolate into a separate JavaScript file, but immediately
90-
download this after the page is loaded.
91-
* `webpackMode: 'controller-lazy'`: wait until this controller HTML is
92-
first included on the page and *then* download the controller and execute it.
88+
* `webpackMode: 'eager'`: controller & dependencies are included in the JavaScript
89+
that's downloaded when the page is loaded.
90+
* `webpackMode: 'lazy'`: controller & dependencies are isolated into a separate
91+
JavaScript file, but immediately downloaded asynchronously after the page is loaded.
92+
* `webpackMode: 'controller-lazy'`: controller & dependencies are isolated into a
93+
separate file and only downloaded asynchronously if (and when) the `data-controller`
94+
HTML appears on the page.
9395

9496
## Run tests
9597

src/webpack/create-controllers-module.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = function createControllersModule(config) {
4949
const controllerMain = packageName + '/' + controllerPackageConfig.main;
5050
const webpackMode = controllerUserConfig.webpackMode;
5151

52-
let moduleValueContents = '';
52+
let moduleValueContents = `import(/* webpackMode: "${webpackMode}" */ '${controllerMain}')`;
5353
if (webpackMode === 'lazy-controller') {
5454
hasLazyControllers = true;
5555
moduleValueContents = `
@@ -63,8 +63,6 @@ new Promise((resolve, reject) => resolve({ default:
6363
}
6464
}))
6565
`.trim();
66-
} else {
67-
moduleValueContents = `import(/* webpackMode: "${webpackMode}" */ '${controllerMain}')`;
6866
}
6967

7068
controllerContents += `\n '${controllerNormalizedName}': ${moduleValueContents},`;

0 commit comments

Comments
 (0)