Socket
Socket
Sign inDemoInstall

module-from-string

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-from-string - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

15

dist/index.js

@@ -37,3 +37,6 @@ 'use strict';

Error.prepareStackTrace = (_err, stackTraces) => stackTraces;
const callSites = new Error().stack.filter((callSite) => !FUNCTION_NAMES.includes(String(callSite.getFunctionName())));
const callSites = new Error().stack.filter((callSite) => {
const functionName = callSite.getFunctionName();
return functionName === null || !FUNCTION_NAMES.includes(functionName);
});
Error.prepareStackTrace = _prepareStackTrace;

@@ -45,3 +48,3 @@ const callerFilename = callSites[0].getFileName();

const specifierPath = fileURLToPath(specifier);
return new RegExp(`^[.\\${path__default['default'].sep}]`).test(specifierPath) ? path__default['default'].resolve(dirname, specifierPath) : specifier;
return /^[./\\]/.test(specifierPath) ? path__default['default'].resolve(dirname, specifierPath) : specifier;
};

@@ -114,3 +117,3 @@

const context = vm__default['default'].createContext({
__imports__: {},
__IMPORTS__: {},
...globals

@@ -135,6 +138,6 @@ });

const targetModule = await import(resolvedSpecifier);
context.__imports__[specifier] = targetModule;
context.__IMPORTS__[specifier] = targetModule;
const exportedNames = new Set(Object.getOwnPropertyNames(targetModule));
const targetModuleContent = `${exportedNames.delete("default") ? `export default __imports__['${specifier}'].default;
` : ""}export const { ${[...exportedNames].join(", ")} } = __imports__['${specifier}'];`;
const targetModuleContent = `${exportedNames.delete("default") ? `export default __IMPORTS__['${specifier}'].default;
` : ""}export const { ${[...exportedNames].join(", ")} } = __IMPORTS__['${specifier}'];`;
return new vm__default['default'].SourceTextModule(targetModuleContent, {

@@ -141,0 +144,0 @@ identifier: resolvedSpecifier,

18

package.json
{
"name": "module-from-string",
"version": "3.1.0",
"version": "3.1.1",
"description": "Load module from string using require or import.",

@@ -9,9 +9,6 @@ "main": "dist/index.js",

"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"directories": {
"test": "__tests__"
},
"scripts": {

@@ -53,3 +50,3 @@ "clean": "rm -rf .cache dist",

"dependencies": {
"esbuild": "0.12.21",
"esbuild": "0.12.24",
"nanoid": "3.1.25"

@@ -59,10 +56,11 @@ },

"@types/jest": "27.0.1",
"@types/node": "16.6.2",
"jest": "27.0.6",
"rollup": "2.56.2",
"@types/node": "16.7.4",
"jest": "27.1.0",
"rollup": "2.56.3",
"rollup-plugin-dts": "3.0.2",
"rollup-plugin-esbuild-transform": "1.1.1",
"ts-jest": "27.0.5",
"ts-standardx": "0.7.9",
"typescript": "4.3.5"
"typescript": "4.4.2"
}
}

@@ -5,5 +5,5 @@ # module-from-string

[![npm](https://img.shields.io/npm/v/module-from-string)](https://www.npmjs.com/package/module-from-string)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/exuanbo/module-from-string/Node.js%20CI/main)](https://github.com/exuanbo/module-from-string/actions?query=workflow)
[![Node.js](https://img.shields.io/badge/node-%3E%3D12.20.0-brightgreen)]()
[![npm](https://img.shields.io/npm/v/module-from-string.svg)](https://www.npmjs.com/package/module-from-string)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/exuanbo/module-from-string/Node.js%20CI/main.svg)](https://github.com/exuanbo/module-from-string/actions?query=workflow)
[![Node.js](https://img.shields.io/badge/node-%3E%3D12.20.0-brightgreen.svg)](https://nodejs.org/)
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)

@@ -10,0 +10,0 @@

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