🍫 tidbits
You can get the current timezone for a website visitor with:
Intl.DateTimeFormat().resolvedOptions().timeZone;
- You can use this to pick the default preferred timezone for the user
- But do allow users to change their timezone from the default
- The current timezone may not be the user's preferred timezone (eg when traveling)
- People move around and their preferred timezone changes from time to time
Supported in all the modern browsers.
(2020-03-22)
If you're using esbuild to bundle a Node module into ESM, you may run into an error that looks like this:
throw new Error('Dynamic require of "' + x2 + '" is not supported');
ESM Node modules do not have access to require
. You're seeing this error either because your code is using require
, or more likely, your code imports 3rd party module that uses require
.
At which point you have two options:
- Use the
--external:[module]
command-line argument to tell esbuild to not bundle the 3rd party module with your module - Use the
--inject:./require_shim.js
command-line argument to shim require
// require_shim.js
import { createRequire } from "module";
global.require = createRequire(import.meta.url);
(2021-01-08)
If you're using Docusaurus.io, and you see this error when running npx docusaurus build
, make sure you have a static
directory.
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema. - options.patterns should be a non-empty array.
mkdir static
touch static/.empty
(2022-01-03)