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

@embroider/reverse-exports

Package Overview
Dependencies
Maintainers
9
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embroider/reverse-exports - npm Package Compare versions

Comparing version 0.0.1-unstable.9606cac to 0.0.1-unstable.d68fbec

6

package.json
{
"name": "@embroider/reverse-exports",
"version": "0.0.1-unstable.9606cac",
"version": "0.0.1-unstable.d68fbec",
"description": "",

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

"license": "ISC",
"devDependencies": {
"@types/minimatch": "^3.0.4"
},
"dependencies": {
"minimatch": "^3.0.4",
"resolve.exports": "^2.0.2"
}
}

24

src/index.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports._findPathRecursively = void 0;
exports._prepareStringForRegex = exports._findPathRecursively = void 0;
const path_1 = require("path");
const minimatch_1 = __importDefault(require("minimatch"));
const resolve_exports_1 = require("resolve.exports");

@@ -73,7 +69,4 @@ /**

const maybeKeyValuePair = _findPathRecursively(exportsObj, candidate => {
// miminatch does not treat directories as full of content without glob
if (candidate.endsWith('/')) {
candidate += '**';
}
return (0, minimatch_1.default)(relativePath, candidate);
const regex = new RegExp(_prepareStringForRegex(candidate));
return regex.test(relativePath);
});

@@ -95,2 +88,13 @@ if (!maybeKeyValuePair) {

exports.default = reversePackageExports;
function _prepareStringForRegex(input) {
let result = input
.split('*')
.map(substr => substr.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'))
.join('.*');
if (result.endsWith('/')) {
result += '.*';
}
return `^${result}$`;
}
exports._prepareStringForRegex = _prepareStringForRegex;
//# sourceMappingURL=index.js.map
import { posix } from 'path';
import minimatch from 'minimatch';
import { exports as resolveExports } from 'resolve.exports';

@@ -85,8 +84,5 @@

const maybeKeyValuePair = _findPathRecursively(exportsObj, candidate => {
// miminatch does not treat directories as full of content without glob
if (candidate.endsWith('/')) {
candidate += '**';
}
const regex = new RegExp(_prepareStringForRegex(candidate));
return minimatch(relativePath, candidate);
return regex.test(relativePath);
});

@@ -118,1 +114,14 @@

}
export function _prepareStringForRegex(input: string): string {
let result = input
.split('*')
.map(substr => substr.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'))
.join('.*');
if (result.endsWith('/')) {
result += '.*';
}
return `^${result}$`;
}

@@ -1,2 +0,2 @@

import reversePackageExports, { _findPathRecursively } from '../src';
import reversePackageExports, { _findPathRecursively, _prepareStringForRegex } from '../src';

@@ -143,2 +143,20 @@ describe('reverse exports', function () {

});
it('conditional exports: using a single asterisk as glob for nested path', function () {
const packageJson = {
name: 'my-v2-addon',
exports: {
'.': './dist/index.js',
'./*': {
types: './dist/*.d.ts',
default: './dist/*.js',
},
'./addon-main.js': './addon-main.js',
},
};
expect(reversePackageExports(packageJson, './dist/_app_/components/welcome-page.js')).toBe(
'my-v2-addon/_app_/components/welcome-page'
);
});
});

@@ -264,1 +282,14 @@

});
describe('_prepareStringForRegex', function () {
[
{ input: './foo', expected: '^\\.\\/foo$' },
{ input: './foo.js', expected: '^\\.\\/foo\\.js$' },
{ input: './foo/*.js', expected: '^\\.\\/foo\\/.*\\.js$' },
{ input: './foo/', expected: '^\\.\\/foo\\/.*$' },
].forEach(({ input, expected }) => {
it(input, function () {
expect(_prepareStringForRegex(input)).toStrictEqual(expected);
});
});
});
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