esbuild Learnings
Minify all *.js Files
Continue reading β
toFixed
- JavaScript Decimal Places
> (26).toFixed(1)
"26.0"
> (26.5).toFixed(1)
"26.5"
While working on
pico-tester
I realized I am not as knowledgable in nodejs' support
for ECMAScript Modules (esm).
I think it's very simple in the browser.
There is
<script type=module>
which understands import
and there is
<script nomodule>
which nicely gradually falls back to before ESM times. But what about nodejs?
There is a package.json
with properties such as
main: <filename>
, exports: {}
type: module
, type: commonjs
,
and any combination of them. For a long time I am using
the package esm
to allow me to use ESM on nodejs, but when publishing a package such as
pico-tester, I must be compatible with as many ways as possible, in which nodejs can be used.
So first there is terminology to get right (esm, cjs, ...) and than provide the right type of package or packaging
so it can be used there. I might update this over time with more learnings.
Continue reading β
The article
Node.js, Dependency Injection, Layered Architecture, and TDD: A Practical Example, Part 1
by @Carlos GonzΓ‘lez
gives a very good introduction of how to structure a (TypeScript/JavaScript) app.
He links articles that allow one to dive deeper into underlying concepts and still explains the
big picture very well. Great job Carlos!
Continue reading β
Lea's article Todayβs Javascript, from an outsiderβs perspective
states yet another time that our JavaScript environment needs a reboot.
I also mentioned the topic a couple of times.
But what shall we do?
Continue reading β
Lately I am coming a across a couple of those tools that promise to remove the
bundling overhead and pain from our projects.
I already mentioned snowpack.
Continue reading β
With latest privacy awareness I believe cookies are also one sensitive topic. I have no numbers,
but I guess there are more people who have cookies disabled then we believe. If not, I learned something here.
Continue reading β
@Peter Coles wrote
"HTTP Cookies: What's the difference between Max-age and Expires?"
in 2009, but he has updated the article later and there is the answer for wether to use "expires" and/or "max-age"
when you set cookies.
Continue reading β
I wish to have a type system where I only need to type-hint the published parts (of a module/file)
and let the type system infer all internal types. Though, I learned that even in Haskell land it is referred to
as good practice to still type every function, no matter if public or private.
Flow sounds to be doing what I want.
Continue reading β
Looking around for resource for JavaScript developers that get into TypeScript I found this
TypeScript for JavaScript Programmers
in the TypeScript handbook.
Continue reading β
TypeScript 3.9 was released. Since I am basically a fan of making code safer and better to understand,
that's what I use types for, I see nothing interesting to me in this release. But I also use TypeScript
in a much simpler way than the cracks and fans.
https://devblogs.microsoft.com/typescript/announcing-typescript-3-9/
Continue reading β
<script>
Tag
I wanted to scriptNode.cloneNode(true)
and expected it to re-evaluate the JS
of the node, but it didn't.
Continue reading β
Bundler like webpack take up too much of our intention, imho. We spend a lot of time configuring them and waiting for them to build so we can see our site. Snowpack moves the bundler out of the way so you can develop without worrying about it locally.
Continue reading β
arr[0]
Fail Safe
I was just filtering a list list.filter(someCondition)
and I only wanted the first element in case there is one.
Doing list.filter(someCondition)[0]
fails when the filtered list
is empty. So I am using slice(0, 1)
, which returns the first element
if there is one, an empty list otherwise.
Now I do list.filter(someCondition).slice(0, 1)
and never list.filter(someCondition)[0]
.
Such small things.
Continue reading β
Run npm install <package>@latest
to update to the latest version of a package,
no matter the minor, major version, it always goes to the latest.
process.cpuUsage
and process.memoryUsage
Learning stuff about nodejs (or v8) while writing tests that ensure runtime behaviour,
using process.cpuUsage and process.memoryUsage. Curious how brittle those tests become over time.
Glad the app ALWAYS runs in the same docker container (dev and prod).
Continue reading β
done
Parameter
Why a #mocha #test times out, when I write it like this: it('...', _ => {});
but it does NOT time out,
when I write: it('...', () => {});
? Exactly, because the _
is the magic done
, that one needs to call.
Continue reading β
If I look at all the code (tests=learnings) we created at our #jslang meetups, I think this is quite some knowledge.
Feel free to dig deeper into it and learn from it, find it all at https://gitlab.com/wolframkriesing/jslang-meetups
Continue reading β