🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@preact/signals-react-transform

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals-react-transform - npm Package Compare versions

Comparing version

to
0.4.0

6

CHANGELOG.md
# @preact/signals-react-transform
## 0.4.0
### Minor Changes
- [#584](https://github.com/preactjs/signals/pull/584) [`726e417`](https://github.com/preactjs/signals/commit/726e41727014722e7de1d7e6e276e28bf0bec2fd) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Support `require()` syntax in the Babel transform
## 0.3.2

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

54

dist/signals-transform.js

@@ -306,25 +306,37 @@ var core=require('@babel/core'),helperModuleImports=require('@babel/helper-module-imports'),debug=require('debug');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var debug__default=/*#__PURE__*/_interopDefaultLegacy(debug);function _taggedTemplateLiteralLoose(strings, raw) {

return function () {
if (!helperModuleImports.isModule(path)) {
throw new Error("Cannot import " + importName + " outside of an ESM module file");
}
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
if (helperModuleImports.isModule(path)) {
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
}
}
return reference;
} else {
// This code originates from
// https://github.com/XantreDev/preact-signals/blob/%40preact-signals/safe-react%400.6.1/packages/react/src/babel.ts#L390-L400
var _reference = get(pass, "requires/" + importName);
if (_reference) {
_reference = types.cloneNode(_reference);
} else {
_reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled"
});
set(pass, "requires/" + importName, _reference);
}
return _reference;
}
return reference;
};

@@ -331,0 +343,0 @@ }

@@ -306,25 +306,37 @@ import {template}from'@babel/core';import {isModule,addNamed}from'@babel/helper-module-imports';import debug from'debug';function _taggedTemplateLiteralLoose(strings, raw) {

return function () {
if (!isModule(path)) {
throw new Error("Cannot import " + importName + " outside of an ESM module file");
}
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
if (isModule(path)) {
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
}
}
return reference;
} else {
// This code originates from
// https://github.com/XantreDev/preact-signals/blob/%40preact-signals/safe-react%400.6.1/packages/react/src/babel.ts#L390-L400
var _reference = get(pass, "requires/" + importName);
if (_reference) {
_reference = types.cloneNode(_reference);
} else {
_reference = addNamed(path, importName, source, {
importedInterop: "uncompiled"
});
set(pass, "requires/" + importName, _reference);
}
return _reference;
}
return reference;
};

@@ -331,0 +343,0 @@ }

@@ -306,25 +306,37 @@ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f(require('@babel/core'),require('@babel/helper-module-imports'),require('debug')):typeof define==='function'&&define.amd?define(['@babel/core','@babel/helper-module-imports','debug'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,g.signalsReactTransform=f(g.core,g.helperModuleImports,g.debug));})(this,(function(core,helperModuleImports,debug){function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var debug__default=/*#__PURE__*/_interopDefaultLegacy(debug);function _taggedTemplateLiteralLoose(strings, raw) {

return function () {
if (!helperModuleImports.isModule(path)) {
throw new Error("Cannot import " + importName + " outside of an ESM module file");
}
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
if (helperModuleImports.isModule(path)) {
var reference = get(pass, "imports/" + importName);
if (reference) return types.cloneNode(reference);
reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after"
});
set(pass, "imports/" + importName, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
var matchesImportName = function matchesImportName(s) {
if (s.type !== "ImportSpecifier") return false;
return s.imported.type === "Identifier" && s.imported.name === importName || s.imported.type === "StringLiteral" && s.imported.value === importName;
};
for (var _iterator = _createForOfIteratorHelperLoose(path.get("body")), _step; !(_step = _iterator()).done;) {
var statement = _step.value;
if (statement.isImportDeclaration() && statement.node.source.value === source && statement.node.specifiers.some(matchesImportName)) {
path.scope.registerDeclaration(statement);
break;
}
}
return reference;
} else {
// This code originates from
// https://github.com/XantreDev/preact-signals/blob/%40preact-signals/safe-react%400.6.1/packages/react/src/babel.ts#L390-L400
var _reference = get(pass, "requires/" + importName);
if (_reference) {
_reference = types.cloneNode(_reference);
} else {
_reference = helperModuleImports.addNamed(path, importName, source, {
importedInterop: "uncompiled"
});
set(pass, "requires/" + importName, _reference);
}
return _reference;
}
return reference;
};

@@ -331,0 +343,0 @@ }

{
"name": "@preact/signals-react-transform",
"version": "0.3.2",
"version": "0.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Manage state with style in React",

@@ -425,39 +425,51 @@ import {

return () => {
if (!isModule(path)) {
throw new Error(
`Cannot import ${importName} outside of an ESM module file`
);
}
if (isModule(path)) {
let reference: BabelTypes.Identifier = get(pass, `imports/${importName}`);
if (reference) return types.cloneNode(reference);
reference = addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after",
});
set(pass, `imports/${importName}`, reference);
let reference: BabelTypes.Identifier = get(pass, `imports/${importName}`);
if (reference) return types.cloneNode(reference);
reference = addNamed(path, importName, source, {
importedInterop: "uncompiled",
importPosition: "after",
});
set(pass, `imports/${importName}`, reference);
/** Helper function to determine if an import declaration's specifier matches the given importName */
const matchesImportName = (
s: BabelTypes.ImportDeclaration["specifiers"][0]
) => {
if (s.type !== "ImportSpecifier") return false;
return (
(s.imported.type === "Identifier" &&
s.imported.name === importName) ||
(s.imported.type === "StringLiteral" &&
s.imported.value === importName)
);
};
/** Helper function to determine if an import declaration's specifier matches the given importName */
const matchesImportName = (
s: BabelTypes.ImportDeclaration["specifiers"][0]
) => {
if (s.type !== "ImportSpecifier") return false;
return (
(s.imported.type === "Identifier" && s.imported.name === importName) ||
(s.imported.type === "StringLiteral" && s.imported.value === importName)
);
};
for (let statement of path.get("body")) {
if (
statement.isImportDeclaration() &&
statement.node.source.value === source &&
statement.node.specifiers.some(matchesImportName)
) {
path.scope.registerDeclaration(statement);
break;
}
}
for (let statement of path.get("body")) {
if (
statement.isImportDeclaration() &&
statement.node.source.value === source &&
statement.node.specifiers.some(matchesImportName)
) {
path.scope.registerDeclaration(statement);
break;
return reference;
} else {
// This code originates from
// https://github.com/XantreDev/preact-signals/blob/%40preact-signals/safe-react%400.6.1/packages/react/src/babel.ts#L390-L400
let reference = get(pass, `requires/${importName}`);
if (reference) {
reference = types.cloneNode(reference);
} else {
reference = addNamed(path, importName, source, {
importedInterop: "uncompiled",
});
set(pass, `requires/${importName}`, reference);
}
return reference;
}
return reference;
};

@@ -464,0 +476,0 @@ }

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

Sorry, the diff of this file is not supported yet