jest : how to cheat with time

Of course I could spend some time mirroring the jest docsite, even though the description is comprehensive and the examples are relevant. (https://jestjs.io/docs/timer-mocks) jest.useFakeTimers(); jest.spyOn(global, 'setTimeout'); Once you have this code, you can freeze the time and execute tasks that should have been deferred to later in real conditionsYou can even advance in time by… Read More »

Use typescript … while exporting “.mjs” modules

Typescript offers great safety against data corruption, it verifies every part of the data flow in your app and compares it against the libraries signature.If anything seems wrong, it asks you to double check at compile time.Ecmascript modules is probably the convergence of frontend and backend javascript : it is seamless across different environments and… Read More »

jscodeshift, run programmatically

jscodeshift is a great tool for running migrations on frontend codebase. It saves days of team syncup, cross team collaboration and prioritization,my team is looking at building a tool to automatically upgrade applications that consume our libraries, instead of giving an upgrade doc and deadlines.the jscodeshift is a command line interface and works the same… Read More »

WebAssembly in javascript : load and run with ease

WebAssembly libraries looks like unicorns in the sky, but they need to be prepared to be used efficiently ;most of the time, you start by naively pass values in functions before realizing that only pointers are read. const webAssemblyModule = await WebAssembly.compile(wasmData);const instance = await WebAssembly.instantiate(webAssemblyModule,{env: {memory: newMemory}, exports: { memory: newMemory }});instance.exports.foo("bar"); // but… Read More »

next.js : dynamic site sections with just one javascript module

next.js has become a very simple and quiet tool to build showcase sites or documentation pages.The contract for writing pages only consists in writing ecmascript modules, which is widely accepted granularity in many node.js frameworks today.The next.js configuration almost resides entirely in the root directory, and you only have a few things that you have… Read More »

next.js : how to prevail against imported css in node_modules

Have you seen this message before ? https://nextjs.org/docs/messages/css-npm "One of your dependencies (node_modules) imports a CSS file." Well, what ? You are just importing styles in one of your node_modules package like this : import styles from "./file.css" Usually it is a source of frustration. css modules can only be imported from pages.When you try… Read More »