- π in node.js version 20 and above
- π in typescript and javascript
- π in Git Commit Message
- π in package.json file
- π in next@^15 with App-Router
- π in astro@^4 and astro@^5
- π Common Tasks
π₯ when you need to resolve a file path, use fileURLToPath(new URL(relativePath), import.meta.url)
-
π₯ always use esm format (export/import) as the main module system, instead of amd and commonjs (cjs) code.
-
π₯ the value of
compiler.moduleResolution
in thetsconfig.json
file should beBundler
{ "compilerOptions": { + "moduleResolution": "Bundler", }, }
Note
also see https://www.conventionalcommits.org/
Tip
why? see https://www.typescriptlang.org/docs/handbook/modules/reference.html#example-explicit-types-condition
Important
π£ you can consider using the command npx publint
to check
- always make sure that "types" is listed first (entry-point for TypeScript resolution - must occur first!)
- always make sure that "default" is listed at the end (as generic fallback that always matches)
- there must be a
type
field, and its value should be"module"
. - remove the
main
,module
, andtypes
fields. - there must be an "exports" field.
for example:
{
+ "type": "module",
+ "exports": {
+ ".": {
+ "types": "./index.d.ts",
+ "import": "./index.mjs",
+ "default": "./index.cjs"
+ }
+ },
- "main": "./index.cjs",
- "module": "./index.mjs",
- "types": "./index.d.ts",
}
-
just reorder the keys in the file, do not change the values of the keys
-
the order of the keys should be as follows:
- license
- private
- name
- version
- description
- files
- exports
- author
- repository
- homepage
- bugs
- peerDependencies
- dependencies
- devDependencies
- keywords
- scripts
Tip
also see chakra-ui get-started
-
run in the terminal
pnpm add @chakra-ui/react @emotion/react -S
as dependencies -
run in the terminal
pnpm add @chakra-ui/cli -D
as devDependencies -
add the following script in
package.json#scripts
{ "scripts": { + "chakra": "chakra" } }
-
find the
<html></html>
element in the./app/layout.{tsx,jsx}
file and add thesuppressHydrationWarning
attribute to it<html lang='en' + suppressHydrationWarning >
- if the
./@chakra-ui/theme
folder already exists, skip the steps below - you run
pnpm chakra eject --outdir @chakra-ui/theme
in the project folder to create the default theme design and components
Tip
WHY?
The Astro TypeScript plugin can be installed separately when you are not using the official Astro VS Code extension. This plugin is automatically installed and configured by the VSCode extension, and you do not need to install both.
see https://docs.astro.build/en/guides/typescript/#typescript-editor-plugin
-
remove
@astrojs/ts-plugin
from thetsconfig.json
file, for example:{ "compilerOptions": { "baseUrl": ".", "plugins": [ - { "name": "@astrojs/ts-plugin" }, { "name": "other-ts-plugin" } ] } }
-
remove
@astrojs/ts-plugin
frompackage.json
dependencies -
run
pnpm remove @astrojs/ts-plugin
in the terminal
please follow the steps below:
-
add package
dotenv
to thedevDependencies
ofpackage.json
pnpm add dotenv -D
-
introduce and call the
dotenv.config()
method where neededimport 'dotenv/config'
-
make sure the
env.d.ts
file exists. if it does not, create one in the./app
or./src
folder -
make sure
env.d.ts
is list in theinclude
field oftsconfig.json
-
make sure the
env.d.ts
has following code is thereinterface EnvVarables { // VITE_ENV_VARIABLE1: string // VITE_ENV_VARIABLE2: string } declare namespace NodeJS { interface ProcessEnv extends EnvVarables {} } interface ImportMeta { readonly env: EnvVarables }