1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

12 commits

Author SHA1 Message Date
Ross Kaffenberger
04cbaa1475 Use ES module syntax for application.js.tt and docs
This change swaps the CommonJS require() syntax in the Webpacker
application.js pack template file and in documentation examples with ES
module import syntax.

Benefits of this change include:

Provides continuity with the larger frontend community: Arguably, one of
the main draws in adopting Webpacker is its integration with Babel to
support ES module syntax. For a fresh Rails install with Webpacker, the
application.js file will be the first impression most Rails developers
have with webpack and Webpacker.  Most of the recent documentation and
examples they will find online for using other libraries will be based
on ES module syntax.

Reduces confusion: Developers commonly add ES imports to their
application.js pack, typically by following online examples, which means
mixing require() and import statements in a single file. This leads to
confusion and unnecessary friction about differences between require()
and import.

Embraces browser-friendliness: The ES module syntax forward-looking and
is meant to be supported in browsers. On the other hand, require()
syntax is synchronous by design and not browser-supported as CommonJS
originally was adopted in Node.js for server-side JavaScript. That
webpack supports require() syntax is merely a convenience.

Encourages best practices regarding optimization: webpack can statically
analyze ES modules and "tree-shake", i.e., strip out unused exports from
the final build (given certain conditions are met, including
`sideEffects: false` designation in package.json).
2020-06-16 15:12:12 -04:00
Xavier Noria
65f9e0c4bb NPM -> npm [ci skip]
According to https://www.npmjs.com/.
2019-05-12 12:00:03 +02:00
Abhay Nikam
476abd403b Updated links from http to https in guides, docs, etc 2019-03-09 16:43:47 +05:30
Javan Makhmali
385d31d209 Minimize boilerplate setup code for JavaScript libraries 2019-01-16 16:15:43 -05:00
Javan Makhmali
86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
Yuto SASAKI
266994240d
Update rails-ujs readme
Add a note on using `yarn autoclean`.
2018-02-04 14:19:28 +09:00
Mike Fiedler
0ae2476acd
Update rails-ujs readme
Link to W3C reference was broken, this uses the latest URL, along with HTTPS.
2018-01-29 19:18:35 -05:00
Elliot Winkler
f01f2e648d rails-ujs: Update README
Make various wording tweaks to cater to users who are viewing the README
on NPM. Notably, don't highlight Yarn specifically in the installation
instructions -- even though this is the preferred tool of choice
especially in the Ruby community, some people still use NPM (and,
really, ES2015+ syntax has nothing to do with NPM or Yarn).
2017-10-02 16:51:59 -05:00
Jon Moss
48f2a0c566 Grammar fixes
[ci skip]
2017-05-29 19:33:44 -04:00
Adrian Stainforth
b8d0a08832
Update to rails-ujs documentation for yarn install 2017-05-26 18:34:24 -04:00
Josef Šimánek
b0a258fa21 Update test link in ActionView javascripts README.md.
[ci skip]
2017-05-22 09:57:00 +02:00
Rafael Mendonça França
f24c2f09f8
Move rails-ujs README and LICENCE to actionview
We are going to make rails/rails the official repository
2017-02-22 13:49:27 -05:00