Commit 4353f91
committed
minor #10692 Changing the wording around module.exports (ProtonScott, javiereguiluz)
This PR was submitted for the 4.1 branch but it was merged into the 3.4 branch instead (closes #10692).
Discussion
----------
Changing the wording around module.exports
Hello!
I just want to point something out here:
Using the commonjs format (require() and module.exports, though node does add some additional things on top of that spec) *is not* the same, or even roughly the same, which is implied/stated by this line here:
>Instead of using require and module.exports like shown above, JavaScript has an alternate syntax, which is a more accepted standard. Choose whichever you want: they do the same thing.
I propose a minor edit here, which is that we actually want to clarify that the ECMAScript standard that has been finalized (often this is known as ES6 or ES2015. There was a minor revision in there but thats long since passed in either case) and one of the purposes, per the Module spec, is that this is the standard for which modules will be *native to the browser*. (In the evergreen versions of Safari, Chrome, Firefox, and I think even Edge now, you can use `<script type="module" src="somemodule.js">` and it will work fine). They are also the only official way of using dynamic imports, as highlighted [in your own documentation](https://symfony.com/doc/current/frontend/encore/code-splitting.html) in a way that I think gets the point across very well.
I think this is very misleading otherwise. You do in fact see a performance decoupling bundling the commonjs modules, as webpack can't take advantage of code splitting with dynamic imports without using ECMAScript modules (more or less, from a high level view).
Of course I'm okay changing whatever wording as needed, but I think we should really point out that require() and import are two *very* different beasts, and I am happy to write up as to way, give links, etc.
<!--
If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/roadmap for the list of maintained branches).
If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `master` for features of unreleased versions).
-->
Commits
-------
d8ba869 Minor tweaks
577e35e Changing the wording around module.exports1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
184 | | - | |
| 183 | + | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
0 commit comments