From b3c7400c74b5af8cd6ce4f5e474e9d32b920e955 Mon Sep 17 00:00:00 2001 From: Khiet Tam Nguyen Date: Fri, 20 Oct 2023 18:19:06 +1100 Subject: [PATCH] Updated documentation to accommodate module import --- README.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8be7376..063b3b7 100644 --- a/README.md +++ b/README.md @@ -131,15 +131,15 @@ const { someFunction } = importSync(
-### 2.1. relativePath +### 2.1. id -Path to the module relative to the current file, similar to CommonJS [require](https://nodejs.org/api/modules.html#requireid). For example, +Module name or relative path similar to CommonJS [require](https://nodejs.org/api/modules.html#requireid). For example, - `'../animals/cats.js'` - `'./dogs.mjs'` -- `'minimal'` +- `'./minimal'` - `importSync` will look for `'./minimal.js'` before `'./minimal.mjs'` - -Note that `option.basePath` can be provided to alter this behaviour. +- `'node-fetch'` + - `importSync` can import pure-esm [node-fetch](https://github.com/node-fetch/node-fetch) (v3) in your cjs project ### 2.2. options @@ -153,7 +153,19 @@ Note that `option.basePath` can be provided to alter this behaviour. basePath - Absolute path to the module's directory + + Absolute path to the module's directory. The basePath option will only take effect if the given id starts with ./ or ../. For example, + + and not + +
 process.cwd()