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

@rollup/plugin-esm-shim

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-esm-shim - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

30

dist/cjs/index.js

@@ -26,19 +26,21 @@ 'use strict';

}
let idx = 0;
for (let i = 0; i < result.length; i++) {
output.push(result[i].match(new RegExp(pattern)) || []);
const match = [result[i]];
match.index = idx;
idx += result[i].length;
output.push(match);
}
return output;
}
function matchAll(regex, input, addition) {
const matches = [];
for (const match of matchAllPolyfill(input, regex)) {
matches.push({
...addition,
...match.groups,
code: match[0],
start: match.index,
end: (match.index || 0) + match[0].length
});
function findPositionToInsertShim(input, pattern) {
let lastImport;
// mimicking behavior of `String.matchAll` as it returns an iterator, not an array
for (const match of matchAllPolyfill(input, pattern)) {
lastImport = match;
}
return matches;
if (!lastImport) {
return 0;
}
return (lastImport.index || 0) + lastImport[0].length;
}

@@ -49,4 +51,3 @@ function provideCJSSyntax(code) {

}
const lastESMImport = matchAll(ESMStaticImportRegex, code, { type: 'static' }).pop();
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
const indexToAppend = findPositionToInsertShim(code, ESMStaticImportRegex);
const s = new MagicString(code);

@@ -95,5 +96,4 @@ s.appendRight(indexToAppend, ESMShim);

exports.default = esmShim;
exports.matchAll = matchAll;
exports.provideCJSSyntax = provideCJSSyntax;
module.exports = Object.assign(exports.default, exports);
//# sourceMappingURL=index.js.map

@@ -22,19 +22,21 @@ import MagicString from 'magic-string';

}
let idx = 0;
for (let i = 0; i < result.length; i++) {
output.push(result[i].match(new RegExp(pattern)) || []);
const match = [result[i]];
match.index = idx;
idx += result[i].length;
output.push(match);
}
return output;
}
function matchAll(regex, input, addition) {
const matches = [];
for (const match of matchAllPolyfill(input, regex)) {
matches.push({
...addition,
...match.groups,
code: match[0],
start: match.index,
end: (match.index || 0) + match[0].length
});
function findPositionToInsertShim(input, pattern) {
let lastImport;
// mimicking behavior of `String.matchAll` as it returns an iterator, not an array
for (const match of matchAllPolyfill(input, pattern)) {
lastImport = match;
}
return matches;
if (!lastImport) {
return 0;
}
return (lastImport.index || 0) + lastImport[0].length;
}

@@ -45,4 +47,3 @@ function provideCJSSyntax(code) {

}
const lastESMImport = matchAll(ESMStaticImportRegex, code, { type: 'static' }).pop();
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
const indexToAppend = findPositionToInsertShim(code, ESMStaticImportRegex);
const s = new MagicString(code);

@@ -90,3 +91,3 @@ s.appendRight(indexToAppend, ESMShim);

export { esmShim as default, matchAll, provideCJSSyntax };
export { esmShim as default, provideCJSSyntax };
//# sourceMappingURL=index.js.map
{
"name": "@rollup/plugin-esm-shim",
"version": "0.1.1",
"version": "0.1.2",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -16,4 +16,8 @@ import MagicString from 'magic-string';

let idx = 0;
for (let i = 0; i < result.length; i++) {
output.push(result[i].match(new RegExp(pattern)) || []);
const match: RegExpMatchArray = [result[i]];
match.index = idx;
idx += result[i].length;
output.push(match);
}

@@ -23,14 +27,13 @@ return output;

export function matchAll(regex: RegExp, input: string, addition: Record<string, any>) {
const matches = [];
for (const match of matchAllPolyfill(input, regex)) {
matches.push({
...addition,
...match.groups,
code: match[0],
start: match.index,
end: (match.index || 0) + match[0].length
});
function findPositionToInsertShim(input: string, pattern: RegExp) {
let lastImport;
// mimicking behavior of `String.matchAll` as it returns an iterator, not an array
for (const match of matchAllPolyfill(input, pattern)) {
lastImport = match;
}
return matches;
if (!lastImport) {
return 0;
}
return (lastImport.index || 0) + lastImport[0].length;
}

@@ -43,4 +46,3 @@

const lastESMImport = matchAll(ESMStaticImportRegex, code, { type: 'static' }).pop();
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
const indexToAppend = findPositionToInsertShim(code, ESMStaticImportRegex);
const s = new MagicString(code);

@@ -47,0 +49,0 @@ s.appendRight(indexToAppend, ESMShim);

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