Closed clitetailor closed 5 years ago
Also i have one question, why don't we use let
and const
instead of var
?
Hi @clitetailor! Though I appreciate the contribution, I'd prefer to keep /dist
viewable from GitHub, and I do want to keep Squirrelly with 0 dependencies.
I love your ideas about better bundling for module formats like ejs
and cjs
-- I'll try and make those changes soon.
I do like the idea of adding a .editorConfig
and switching to Terser, though. Any chance you could create a pull request with only those 2 changes?
Thanks for the ideas!
Also i have one question, why don't we use
let
andconst
instead ofvar
?
For now, I want to keep Squirrelly completely ES5 compliant, and using Babel to transpile often leads to increased bundle size.
Thanks for the suggestion though!
Oh, terser already in the master branch. I will make another PR that update .editorconfig
only. I will keep this branch in case you need a reference! 😃
npm run build
andnpm test
Summary
Changes in this PR:
Add
files
field topackage.json
This way we can add
lib
anddist
folder to.gitignore
. If you wonder whether npm packaging works correctly, you can usenpm pack
to test.Support
commonjs
This includes changing the
main
field insidepackage.json
and usinggulp
alongsiderollup
(you can usemodule
field to supportesm
also).While we can just build a
umd
file for multi-target platforms,commonjs
is preferred for using in node because of the following reasons.commonjs
is most common module format in node.commonjs
files and let end-user and build tools decide the target format (amd, umd, iife, etc).Also, we still need to keep
umd
format for the use with CDNs or directly include script tag in JS Bin or Codepen, etc.Add
@babel/register
This adds consistency improvement to source code by using
esm
in bothsrc
folder andtest
folder. You no longer need to useconst something = require('something')
in your source code.Whenever you want to run an
esm
file directly via Node CLI, you can usenode -r @babel/register <file>
instead.Add
core-js
andregenerator-runtime
@babel/register
need this, this may also polyfill for old browser but whether this is good practice in node is unknown yet (this may polyfill old version of node but it may also increase the bundle size. notice that, the bundle size may not be a problem if the end-user use the same version of core-js).Add
.babelrc
For convenient when sharing configuration between editors and build tools.
Add
.editorconfig
standard
only runs when we build or we format project using command line..editorconfig
will add consistency between different editors and improve editing experience.Use
terser
instead ofuglifyjs
terser
is more recommended for working with ES6+ and is more preferred overuglifyjs
as i known.