Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extensionless

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extensionless - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

2

package.json
{
"name": "extensionless",
"version": "1.1.7",
"version": "1.1.8",
"type": "module",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -6,2 +6,3 @@ Node.js loader for import specifiers as file paths without extensions or as directory paths

Install:
```

@@ -14,2 +15,3 @@ npm i extensionless

Start `node` with the following flag added:
```

@@ -21,7 +23,34 @@ --experimental-loader=extensionless

You can now use import specifiers as file paths without extensions or as directory paths:
```js
import mod from './mod'
// imports from the first existing file in the candidates list as follows
// ['./mod.js', './mod.json', './mod/index.js', './mod/index.json']
```
 
If the specifier ends with a path separator, it only looks for index files in that directory:
```js
import mod from '../mod/'
// imports from the first existing file in the candidates list as follows
// ['../mod/index.js', '../mod/index.json']
```
 
To configure this package, you can add the field `extensionless` to `package.json`:
```
```json
"extensionless": {
"lookFor": ["mjs", "js", "json"] // default: ["js", "json"]
"lookFor": ["mjs", "js", "json"]
}
```
| Field | Default Value |
| -------- | -------------------- |
| lookFor | ```["js", "json"]``` |
import {access, existsSync, readFileSync} from 'fs'
import {dirname, extname, isAbsolute, join, normalize, sep} from 'path'
import {cwd} from 'process'
import {argv, cwd} from 'process'
import {fileURLToPath} from 'url'
let entrypoint = process.argv[1]
let pkgJson, curDir, upDir = isAbsolute(entrypoint ?? '') ? dirname(entrypoint) : cwd()
let pkgJson, curDir, upDir = isAbsolute(argv[1] ?? '') ? dirname(argv[1]) : cwd()
do {
let filePath = join(curDir = upDir, 'package.json')
let path = join(curDir = upDir, 'package.json')
if (existsSync(filePath)) {
pkgJson = JSON.parse(readFileSync(filePath, 'utf8'))
if (existsSync(path)) {
pkgJson = JSON.parse(readFileSync(path, 'utf8'))
}

@@ -15,0 +13,0 @@ } while (!pkgJson && curDir !== (upDir = dirname(curDir)))

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc