New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

import-sync

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

import-sync - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

dist/cjs/config.d.ts

10

dist/cjs/files.d.ts

@@ -10,1 +10,11 @@ /**

export declare const getCallerFilePath: () => string;
/**
* Find the module file path by checking for available extensions
* as defined by VALID_FILE_EXTENSIONS
*
* @param {string} modulePath - The path to the module
* @param {string} basePath - The base path for the module
* @returns {string} The resolved file path
* @throws {Error} If the file is not found
*/
export declare const findModuleFile: (modulePath: string, basePath: string) => string;

33

dist/cjs/files.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCallerFilePath = void 0;
exports.findModuleFile = exports.getCallerFilePath = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const config_1 = require("./config");
/**

@@ -22,2 +28,27 @@ * Get the file path of the caller function.

exports.getCallerFilePath = getCallerFilePath;
/**
* Find the module file path by checking for available extensions
* as defined by VALID_FILE_EXTENSIONS
*
* @param {string} modulePath - The path to the module
* @param {string} basePath - The base path for the module
* @returns {string} The resolved file path
* @throws {Error} If the file is not found
*/
const findModuleFile = (modulePath, basePath) => {
const filePath = path_1.default.join(basePath, modulePath);
if (fs_1.default.existsSync(filePath)) {
return filePath;
}
if (!path_1.default.extname(filePath)) {
for (const ext of config_1.VALID_FILE_EXTENSIONS) {
const extFilePath = path_1.default.join(basePath, `${modulePath}${ext}`);
if (fs_1.default.existsSync(extFilePath)) {
return extFilePath;
}
}
}
throw new Error(`No such file '${filePath}' with matching extensions [${config_1.VALID_FILE_EXTENSIONS}]`);
};
exports.findModuleFile = findModuleFile;
//# sourceMappingURL=files.js.map

5

dist/cjs/import.js

@@ -52,6 +52,3 @@ "use strict";

const opts = Object.assign(Object.assign({}, defaultOptions), options);
let modulePath = id;
if (/^\.\.?\//.test(id)) {
modulePath = path_1.default.join(opts.basePath, id);
}
const modulePath = /^\.\.?\//.test(id) ? (0, files_1.findModuleFile)(id, opts.basePath) : id;
const es6Require = createEs6Require(opts.esmOptions);

@@ -58,0 +55,0 @@ try {

@@ -10,1 +10,11 @@ /**

export declare const getCallerFilePath: () => string;
/**
* Find the module file path by checking for available extensions
* as defined by VALID_FILE_EXTENSIONS
*
* @param {string} modulePath - The path to the module
* @param {string} basePath - The base path for the module
* @returns {string} The resolved file path
* @throws {Error} If the file is not found
*/
export declare const findModuleFile: (modulePath: string, basePath: string) => string;

@@ -0,1 +1,4 @@

import fs from 'fs';
import path from 'path';
import { VALID_FILE_EXTENSIONS } from './config';
/**

@@ -18,2 +21,26 @@ * Get the file path of the caller function.

};
/**
* Find the module file path by checking for available extensions
* as defined by VALID_FILE_EXTENSIONS
*
* @param {string} modulePath - The path to the module
* @param {string} basePath - The base path for the module
* @returns {string} The resolved file path
* @throws {Error} If the file is not found
*/
export const findModuleFile = (modulePath, basePath) => {
const filePath = path.join(basePath, modulePath);
if (fs.existsSync(filePath)) {
return filePath;
}
if (!path.extname(filePath)) {
for (const ext of VALID_FILE_EXTENSIONS) {
const extFilePath = path.join(basePath, `${modulePath}${ext}`);
if (fs.existsSync(extFilePath)) {
return extFilePath;
}
}
}
throw new Error(`No such file '${filePath}' with matching extensions [${VALID_FILE_EXTENSIONS}]`);
};
//# sourceMappingURL=files.js.map
import esm from 'esm';
import path from 'path';
import fs from 'fs';
import { getCallerFilePath } from './files';
import { findModuleFile, getCallerFilePath } from './files';
/**

@@ -47,6 +47,3 @@ * Creates an esm-compatible require function that can import ES Modules

const opts = Object.assign(Object.assign({}, defaultOptions), options);
let modulePath = id;
if (/^\.\.?\//.test(id)) {
modulePath = path.join(opts.basePath, id);
}
const modulePath = /^\.\.?\//.test(id) ? findModuleFile(id, opts.basePath) : id;
const es6Require = createEs6Require(opts.esmOptions);

@@ -53,0 +50,0 @@ try {

@@ -7,3 +7,3 @@ {

},
"version": "2.0.5",
"version": "2.0.6",
"files": [

@@ -51,4 +51,4 @@ "dist"

"@typescript-eslint/parser": "^6.8.0",
"eslint": "^8.51.0",
"eslint-plugin-jest": "^27.4.2",
"eslint": "^8.52.0",
"eslint-plugin-jest": "^27.4.3",
"jest": "^29.7.0",

@@ -55,0 +55,0 @@ "node-fetch": "^3.3.2",

@@ -39,3 +39,3 @@ <div align="center">

&nbsp;
[![Downloads Total](https://badgen.net/npm/dy/import-sync)](https://moiva.io/?npm=import-sync)
[![Downloads Yearly](https://badgen.net/npm/dy/import-sync)](https://moiva.io/?npm=import-sync)
&nbsp;

@@ -148,2 +148,3 @@ [![Downloads Monthly](https://badgen.net/npm/dm/import-sync)](https://moiva.io/?npm=import-sync)

- `importSync` will look for `'./minimal.js'` before `'./minimal.mjs'`
- `importSync` will look for matching extensions in the order `[.js, .mjs, .cjs]`
- `'node-fetch'`

@@ -150,0 +151,0 @@ - `importSync` can import pure-esm [node-fetch](https://github.com/node-fetch/node-fetch) (v3) in your cjs project

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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