@linaria/utils
Advanced tools
Comparing version 4.5.1 to 4.5.2
import { createId } from './createId'; | ||
import { reference } from './scopeHelpers'; | ||
function getOrAddLinariaPreval(scope) { | ||
export function getOrAddLinariaPreval(scope) { | ||
const rootScope = scope.getProgramParent(); | ||
@@ -9,22 +9,45 @@ let object = rootScope.getData('__linariaPreval'); | ||
} | ||
const prevalExport = { | ||
type: 'ExpressionStatement', | ||
expression: { | ||
type: 'AssignmentExpression', | ||
operator: '=', | ||
left: { | ||
type: 'MemberExpression', | ||
object: createId('exports'), | ||
property: createId('__linariaPreval'), | ||
computed: false | ||
const programPath = rootScope.path; | ||
if (programPath.node.sourceType === 'script') { | ||
// CJS exports.__linariaPreval = {}; | ||
const prevalExport = { | ||
expression: { | ||
type: 'AssignmentExpression', | ||
operator: '=', | ||
left: { | ||
computed: false, | ||
object: createId('exports'), | ||
property: createId('__linariaPreval'), | ||
type: 'MemberExpression' | ||
}, | ||
right: { | ||
properties: [], | ||
type: 'ObjectExpression' | ||
} | ||
}, | ||
right: { | ||
type: 'ObjectExpression', | ||
properties: [] | ||
} | ||
} | ||
}; | ||
const programPath = rootScope.path; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('expression.right'); | ||
type: 'ExpressionStatement' | ||
}; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('expression.right'); | ||
} else { | ||
// ESM export const __linariaPreval = {}; | ||
const prevalExport = { | ||
declaration: { | ||
declarations: [{ | ||
id: createId('__linariaPreval'), | ||
init: { | ||
properties: [], | ||
type: 'ObjectExpression' | ||
}, | ||
type: 'VariableDeclarator' | ||
}], | ||
kind: 'const', | ||
type: 'VariableDeclaration' | ||
}, | ||
specifiers: [], | ||
type: 'ExportNamedDeclaration' | ||
}; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('declaration.declarations.0.init'); | ||
} | ||
rootScope.setData('__linariaPreval', object); | ||
@@ -31,0 +54,0 @@ return object; |
@@ -825,3 +825,3 @@ /* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */ | ||
} | ||
export default function collectExportsAndImports(path, force = false) { | ||
export function collectExportsAndImports(path, force = false) { | ||
const state = { | ||
@@ -828,0 +828,0 @@ exportRefs: new Map(), |
import { getScope } from './getScope'; | ||
function isInVoid(path) { | ||
return path.parentPath?.isUnaryExpression({ | ||
operator: 'void' | ||
}) ?? false; | ||
function isInUnary(path) { | ||
return path.parentPath?.isUnaryExpression() ?? false; | ||
} | ||
// It's possible for non-strict mode code to have variable deletions. | ||
function isInDelete(path) { | ||
return path.parentPath.node.operator === 'delete'; | ||
} | ||
function isBindingIdentifier(path) { | ||
return path.isBindingIdentifier() && !isInVoid(path); | ||
return path.isBindingIdentifier() && (!isInUnary(path) || isInDelete(path)); | ||
} | ||
function isReferencedIdentifier(path) { | ||
return path.isReferencedIdentifier() || isInVoid(path); | ||
return path.isReferencedIdentifier() || isInUnary(path) && !isInDelete(path); | ||
} | ||
// For some reasons, `isBindingIdentifier` returns true for identifiers inside `void` expressions. | ||
// For some reasons, `isBindingIdentifier` returns true for identifiers inside unary expressions. | ||
const checkers = { | ||
@@ -16,0 +19,0 @@ binding: ex => isBindingIdentifier(ex), |
@@ -1,9 +0,15 @@ | ||
export { addIdentifierToLinariaPreval } from './addIdentifierToLinariaPreval'; | ||
export { addIdentifierToLinariaPreval, getOrAddLinariaPreval } from './addIdentifierToLinariaPreval'; | ||
export { default as asyncResolveFallback, syncResolve } from './asyncResolveFallback'; | ||
export { default as collectExportsAndImports } from './collectExportsAndImports'; | ||
export * from './collectExportsAndImports'; | ||
export { collectExportsAndImports, explicitImport, sideEffectImport } from './collectExportsAndImports'; | ||
export { collectTemplateDependencies, extractExpression } from './collectTemplateDependencies'; | ||
export { createId } from './createId'; | ||
export { createPerfMeter } from './debug/perfMetter'; | ||
export { EventEmitter } from './EventEmitter'; | ||
export { default as findIdentifiers, nonType } from './findIdentifiers'; | ||
export { findPackageJSON } from './findPackageJSON'; | ||
export { hasEvaluatorMetadata } from './hasEvaluatorMetadata'; | ||
export { default as getFileIdx } from './getFileIdx'; | ||
export { hasMeta } from './hasMeta'; | ||
export { getSource } from './getSource'; | ||
export { isBoxedPrimitive } from './isBoxedPrimitive'; | ||
export { default as isExports } from './isExports'; | ||
@@ -13,8 +19,12 @@ export { default as isNotNull } from './isNotNull'; | ||
export { default as isRequire } from './isRequire'; | ||
export { isSerializable } from './isSerializable'; | ||
export { default as isTypedNode } from './isTypedNode'; | ||
export { default as isUnnecessaryReactCall } from './isUnnecessaryReactCall'; | ||
export * from './options'; | ||
export * from './scopeHelpers'; | ||
export { removeDangerousCode } from './removeDangerousCode'; | ||
export { applyAction, mutate, removeWithRelated, findActionForNode, dereference, reference, referenceAll } from './scopeHelpers'; | ||
export { default as slugify } from './slugify'; | ||
export { ValueType } from './types'; | ||
export { valueToLiteral } from './valueToLiteral'; | ||
export { default as JSXElementsRemover } from './visitors/JSXElementsRemover'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import collectExportsAndImports from './collectExportsAndImports'; | ||
import { collectExportsAndImports } from './collectExportsAndImports'; | ||
import { getScope } from './getScope'; | ||
@@ -3,0 +3,0 @@ function getCallee(p) { |
export { default as buildOptions } from './buildOptions'; | ||
export { default as loadBabelOptions } from './loadBabelOptions'; | ||
export { isFeatureEnabled } from './isFeatureEnabled'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -34,4 +34,4 @@ /* eslint-disable no-restricted-syntax */ | ||
binding.referenced = true; | ||
binding.references += 1; | ||
binding.referencePaths.push(referencePath ?? path); | ||
binding.references = binding.referencePaths.length; | ||
} | ||
@@ -87,3 +87,4 @@ function isReferenced({ | ||
} | ||
binding.referenced = binding.referencePaths.length + referencesInConstantViolations.length > 0; | ||
const nonTypeReferences = binding.referencePaths.filter(nonType); | ||
binding.referenced = nonTypeReferences.length + referencesInConstantViolations.length > 0; | ||
return binding; | ||
@@ -90,0 +91,0 @@ } |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.addIdentifierToLinariaPreval = addIdentifierToLinariaPreval; | ||
exports.getOrAddLinariaPreval = getOrAddLinariaPreval; | ||
var _createId = require("./createId"); | ||
@@ -16,22 +17,45 @@ var _scopeHelpers = require("./scopeHelpers"); | ||
} | ||
const prevalExport = { | ||
type: 'ExpressionStatement', | ||
expression: { | ||
type: 'AssignmentExpression', | ||
operator: '=', | ||
left: { | ||
type: 'MemberExpression', | ||
object: (0, _createId.createId)('exports'), | ||
property: (0, _createId.createId)('__linariaPreval'), | ||
computed: false | ||
const programPath = rootScope.path; | ||
if (programPath.node.sourceType === 'script') { | ||
// CJS exports.__linariaPreval = {}; | ||
const prevalExport = { | ||
expression: { | ||
type: 'AssignmentExpression', | ||
operator: '=', | ||
left: { | ||
computed: false, | ||
object: (0, _createId.createId)('exports'), | ||
property: (0, _createId.createId)('__linariaPreval'), | ||
type: 'MemberExpression' | ||
}, | ||
right: { | ||
properties: [], | ||
type: 'ObjectExpression' | ||
} | ||
}, | ||
right: { | ||
type: 'ObjectExpression', | ||
properties: [] | ||
} | ||
} | ||
}; | ||
const programPath = rootScope.path; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('expression.right'); | ||
type: 'ExpressionStatement' | ||
}; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('expression.right'); | ||
} else { | ||
// ESM export const __linariaPreval = {}; | ||
const prevalExport = { | ||
declaration: { | ||
declarations: [{ | ||
id: (0, _createId.createId)('__linariaPreval'), | ||
init: { | ||
properties: [], | ||
type: 'ObjectExpression' | ||
}, | ||
type: 'VariableDeclarator' | ||
}], | ||
kind: 'const', | ||
type: 'VariableDeclaration' | ||
}, | ||
specifiers: [], | ||
type: 'ExportNamedDeclaration' | ||
}; | ||
const [inserted] = programPath.pushContainer('body', [prevalExport]); | ||
object = inserted.get('declaration.declarations.0.init'); | ||
} | ||
rootScope.setData('__linariaPreval', object); | ||
@@ -38,0 +62,0 @@ return object; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = collectExportsAndImports; | ||
exports.collectExportsAndImports = collectExportsAndImports; | ||
exports.sideEffectImport = exports.explicitImport = void 0; | ||
@@ -617,5 +617,5 @@ var _logger = require("@linaria/logger"); | ||
function collectFromExportAllDeclaration(path, state) { | ||
var _path$get, _path$get$node; | ||
var _path$get; | ||
if (isType(path)) return; | ||
const source = (_path$get = path.get('source')) === null || _path$get === void 0 ? void 0 : (_path$get$node = _path$get.node) === null || _path$get$node === void 0 ? void 0 : _path$get$node.value; | ||
const source = (_path$get = path.get('source')) === null || _path$get === void 0 || (_path$get = _path$get.node) === null || _path$get === void 0 ? void 0 : _path$get.value; | ||
if (!source) return; | ||
@@ -676,5 +676,5 @@ | ||
function collectFromExportNamedDeclaration(path, state) { | ||
var _path$get2, _path$get2$node; | ||
var _path$get2; | ||
if (isType(path)) return; | ||
const source = (_path$get2 = path.get('source')) === null || _path$get2 === void 0 ? void 0 : (_path$get2$node = _path$get2.node) === null || _path$get2$node === void 0 ? void 0 : _path$get2$node.value; | ||
const source = (_path$get2 = path.get('source')) === null || _path$get2 === void 0 || (_path$get2 = _path$get2.node) === null || _path$get2 === void 0 ? void 0 : _path$get2.value; | ||
const specifiers = path.get('specifiers'); | ||
@@ -681,0 +681,0 @@ if (specifiers) { |
@@ -9,16 +9,19 @@ "use strict"; | ||
var _getScope = require("./getScope"); | ||
function isInVoid(path) { | ||
function isInUnary(path) { | ||
var _path$parentPath$isUn, _path$parentPath; | ||
return (_path$parentPath$isUn = (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.isUnaryExpression({ | ||
operator: 'void' | ||
})) !== null && _path$parentPath$isUn !== void 0 ? _path$parentPath$isUn : false; | ||
return (_path$parentPath$isUn = (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.isUnaryExpression()) !== null && _path$parentPath$isUn !== void 0 ? _path$parentPath$isUn : false; | ||
} | ||
// It's possible for non-strict mode code to have variable deletions. | ||
function isInDelete(path) { | ||
return path.parentPath.node.operator === 'delete'; | ||
} | ||
function isBindingIdentifier(path) { | ||
return path.isBindingIdentifier() && !isInVoid(path); | ||
return path.isBindingIdentifier() && (!isInUnary(path) || isInDelete(path)); | ||
} | ||
function isReferencedIdentifier(path) { | ||
return path.isReferencedIdentifier() || isInVoid(path); | ||
return path.isReferencedIdentifier() || isInUnary(path) && !isInDelete(path); | ||
} | ||
// For some reasons, `isBindingIdentifier` returns true for identifiers inside `void` expressions. | ||
// For some reasons, `isBindingIdentifier` returns true for identifiers inside unary expressions. | ||
const checkers = { | ||
@@ -25,0 +28,0 @@ binding: ex => isBindingIdentifier(ex), |
191
lib/index.js
@@ -8,10 +8,21 @@ "use strict"; | ||
addIdentifierToLinariaPreval: true, | ||
getOrAddLinariaPreval: true, | ||
asyncResolveFallback: true, | ||
syncResolve: true, | ||
collectExportsAndImports: true, | ||
explicitImport: true, | ||
sideEffectImport: true, | ||
collectTemplateDependencies: true, | ||
extractExpression: true, | ||
createId: true, | ||
createPerfMeter: true, | ||
EventEmitter: true, | ||
findIdentifiers: true, | ||
nonType: true, | ||
findPackageJSON: true, | ||
hasEvaluatorMetadata: true, | ||
getFileIdx: true, | ||
hasMeta: true, | ||
getSource: true, | ||
isBoxedPrimitive: true, | ||
isExports: true, | ||
@@ -21,7 +32,24 @@ isNotNull: true, | ||
isRequire: true, | ||
isSerializable: true, | ||
isTypedNode: true, | ||
isUnnecessaryReactCall: true, | ||
removeDangerousCode: true, | ||
applyAction: true, | ||
mutate: true, | ||
removeWithRelated: true, | ||
findActionForNode: true, | ||
dereference: true, | ||
reference: true, | ||
referenceAll: true, | ||
slugify: true, | ||
ValueType: true, | ||
valueToLiteral: true, | ||
JSXElementsRemover: true | ||
}; | ||
Object.defineProperty(exports, "EventEmitter", { | ||
enumerable: true, | ||
get: function () { | ||
return _EventEmitter.EventEmitter; | ||
} | ||
}); | ||
Object.defineProperty(exports, "JSXElementsRemover", { | ||
@@ -33,2 +61,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "ValueType", { | ||
enumerable: true, | ||
get: function () { | ||
return _types.ValueType; | ||
} | ||
}); | ||
Object.defineProperty(exports, "addIdentifierToLinariaPreval", { | ||
@@ -40,2 +74,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "applyAction", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.applyAction; | ||
} | ||
}); | ||
Object.defineProperty(exports, "asyncResolveFallback", { | ||
@@ -50,5 +90,11 @@ enumerable: true, | ||
get: function () { | ||
return _collectExportsAndImports.default; | ||
return _collectExportsAndImports.collectExportsAndImports; | ||
} | ||
}); | ||
Object.defineProperty(exports, "collectTemplateDependencies", { | ||
enumerable: true, | ||
get: function () { | ||
return _collectTemplateDependencies.collectTemplateDependencies; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createId", { | ||
@@ -60,2 +106,32 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "createPerfMeter", { | ||
enumerable: true, | ||
get: function () { | ||
return _perfMetter.createPerfMeter; | ||
} | ||
}); | ||
Object.defineProperty(exports, "dereference", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.dereference; | ||
} | ||
}); | ||
Object.defineProperty(exports, "explicitImport", { | ||
enumerable: true, | ||
get: function () { | ||
return _collectExportsAndImports.explicitImport; | ||
} | ||
}); | ||
Object.defineProperty(exports, "extractExpression", { | ||
enumerable: true, | ||
get: function () { | ||
return _collectTemplateDependencies.extractExpression; | ||
} | ||
}); | ||
Object.defineProperty(exports, "findActionForNode", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.findActionForNode; | ||
} | ||
}); | ||
Object.defineProperty(exports, "findIdentifiers", { | ||
@@ -79,2 +155,32 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "getOrAddLinariaPreval", { | ||
enumerable: true, | ||
get: function () { | ||
return _addIdentifierToLinariaPreval.getOrAddLinariaPreval; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getSource", { | ||
enumerable: true, | ||
get: function () { | ||
return _getSource.getSource; | ||
} | ||
}); | ||
Object.defineProperty(exports, "hasEvaluatorMetadata", { | ||
enumerable: true, | ||
get: function () { | ||
return _hasEvaluatorMetadata.hasEvaluatorMetadata; | ||
} | ||
}); | ||
Object.defineProperty(exports, "hasMeta", { | ||
enumerable: true, | ||
get: function () { | ||
return _hasMeta.hasMeta; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isBoxedPrimitive", { | ||
enumerable: true, | ||
get: function () { | ||
return _isBoxedPrimitive.isBoxedPrimitive; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isExports", { | ||
@@ -104,2 +210,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "isSerializable", { | ||
enumerable: true, | ||
get: function () { | ||
return _isSerializable.isSerializable; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isTypedNode", { | ||
@@ -117,2 +229,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "mutate", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.mutate; | ||
} | ||
}); | ||
Object.defineProperty(exports, "nonType", { | ||
@@ -124,2 +242,32 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "reference", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.reference; | ||
} | ||
}); | ||
Object.defineProperty(exports, "referenceAll", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.referenceAll; | ||
} | ||
}); | ||
Object.defineProperty(exports, "removeDangerousCode", { | ||
enumerable: true, | ||
get: function () { | ||
return _removeDangerousCode.removeDangerousCode; | ||
} | ||
}); | ||
Object.defineProperty(exports, "removeWithRelated", { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers.removeWithRelated; | ||
} | ||
}); | ||
Object.defineProperty(exports, "sideEffectImport", { | ||
enumerable: true, | ||
get: function () { | ||
return _collectExportsAndImports.sideEffectImport; | ||
} | ||
}); | ||
Object.defineProperty(exports, "slugify", { | ||
@@ -137,20 +285,22 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "valueToLiteral", { | ||
enumerable: true, | ||
get: function () { | ||
return _valueToLiteral.valueToLiteral; | ||
} | ||
}); | ||
var _addIdentifierToLinariaPreval = require("./addIdentifierToLinariaPreval"); | ||
var _asyncResolveFallback = _interopRequireWildcard(require("./asyncResolveFallback")); | ||
var _collectExportsAndImports = _interopRequireWildcard(require("./collectExportsAndImports")); | ||
Object.keys(_collectExportsAndImports).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _collectExportsAndImports[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _collectExportsAndImports[key]; | ||
} | ||
}); | ||
}); | ||
var _collectExportsAndImports = require("./collectExportsAndImports"); | ||
var _collectTemplateDependencies = require("./collectTemplateDependencies"); | ||
var _createId = require("./createId"); | ||
var _perfMetter = require("./debug/perfMetter"); | ||
var _EventEmitter = require("./EventEmitter"); | ||
var _findIdentifiers = _interopRequireWildcard(require("./findIdentifiers")); | ||
var _findPackageJSON = require("./findPackageJSON"); | ||
var _hasEvaluatorMetadata = require("./hasEvaluatorMetadata"); | ||
var _getFileIdx = _interopRequireDefault(require("./getFileIdx")); | ||
var _hasMeta = require("./hasMeta"); | ||
var _getSource = require("./getSource"); | ||
var _isBoxedPrimitive = require("./isBoxedPrimitive"); | ||
var _isExports = _interopRequireDefault(require("./isExports")); | ||
@@ -160,2 +310,3 @@ var _isNotNull = _interopRequireDefault(require("./isNotNull")); | ||
var _isRequire = _interopRequireDefault(require("./isRequire")); | ||
var _isSerializable = require("./isSerializable"); | ||
var _isTypedNode = _interopRequireDefault(require("./isTypedNode")); | ||
@@ -175,15 +326,7 @@ var _isUnnecessaryReactCall = _interopRequireDefault(require("./isUnnecessaryReactCall")); | ||
}); | ||
var _removeDangerousCode = require("./removeDangerousCode"); | ||
var _scopeHelpers = require("./scopeHelpers"); | ||
Object.keys(_scopeHelpers).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _scopeHelpers[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _scopeHelpers[key]; | ||
} | ||
}); | ||
}); | ||
var _slugify = _interopRequireDefault(require("./slugify")); | ||
var _types = require("./types"); | ||
var _valueToLiteral = require("./valueToLiteral"); | ||
var _JSXElementsRemover = _interopRequireDefault(require("./visitors/JSXElementsRemover")); | ||
@@ -190,0 +333,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -7,5 +7,4 @@ "use strict"; | ||
exports.default = isUnnecessaryReactCall; | ||
var _collectExportsAndImports = _interopRequireDefault(require("./collectExportsAndImports")); | ||
var _collectExportsAndImports = require("./collectExportsAndImports"); | ||
var _getScope = require("./getScope"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function getCallee(p) { | ||
@@ -26,5 +25,5 @@ const callee = p.get('callee'); | ||
function isJSXRuntime(p, imports) { | ||
var _jsxRuntime$local, _jsxRuntime$local2, _jsxRuntime$local2$no; | ||
var _jsxRuntime$local, _jsxRuntime$local2; | ||
const jsxRuntime = imports.find(i => i.source === JSXRuntimeSource); | ||
const jsxRuntimeName = (jsxRuntime === null || jsxRuntime === void 0 ? void 0 : (_jsxRuntime$local = jsxRuntime.local) === null || _jsxRuntime$local === void 0 ? void 0 : _jsxRuntime$local.isIdentifier()) && (jsxRuntime === null || jsxRuntime === void 0 ? void 0 : (_jsxRuntime$local2 = jsxRuntime.local) === null || _jsxRuntime$local2 === void 0 ? void 0 : (_jsxRuntime$local2$no = _jsxRuntime$local2.node) === null || _jsxRuntime$local2$no === void 0 ? void 0 : _jsxRuntime$local2$no.name); | ||
const jsxRuntimeName = (jsxRuntime === null || jsxRuntime === void 0 || (_jsxRuntime$local = jsxRuntime.local) === null || _jsxRuntime$local === void 0 ? void 0 : _jsxRuntime$local.isIdentifier()) && (jsxRuntime === null || jsxRuntime === void 0 || (_jsxRuntime$local2 = jsxRuntime.local) === null || _jsxRuntime$local2 === void 0 || (_jsxRuntime$local2 = _jsxRuntime$local2.node) === null || _jsxRuntime$local2 === void 0 ? void 0 : _jsxRuntime$local2.name); | ||
if (jsxRuntime) { | ||
@@ -81,5 +80,5 @@ const callee = getCallee(p); | ||
imports | ||
} = (0, _collectExportsAndImports.default)(programPath); | ||
} = (0, _collectExportsAndImports.collectExportsAndImports)(programPath); | ||
return isJSXRuntime(path, imports) || isClassicReactRuntime(path, imports); | ||
} | ||
//# sourceMappingURL=isUnnecessaryReactCall.js.map |
@@ -8,3 +8,4 @@ "use strict"; | ||
buildOptions: true, | ||
loadBabelOptions: true | ||
loadBabelOptions: true, | ||
isFeatureEnabled: true | ||
}; | ||
@@ -17,2 +18,8 @@ Object.defineProperty(exports, "buildOptions", { | ||
}); | ||
Object.defineProperty(exports, "isFeatureEnabled", { | ||
enumerable: true, | ||
get: function () { | ||
return _isFeatureEnabled.isFeatureEnabled; | ||
} | ||
}); | ||
Object.defineProperty(exports, "loadBabelOptions", { | ||
@@ -26,2 +33,3 @@ enumerable: true, | ||
var _loadBabelOptions = _interopRequireDefault(require("./loadBabelOptions")); | ||
var _isFeatureEnabled = require("./isFeatureEnabled"); | ||
var _types = require("./types"); | ||
@@ -28,0 +36,0 @@ Object.keys(_types).forEach(function (key) { |
@@ -49,4 +49,4 @@ "use strict"; | ||
binding.referenced = true; | ||
binding.references += 1; | ||
binding.referencePaths.push(referencePath !== null && referencePath !== void 0 ? referencePath : path); | ||
binding.references = binding.referencePaths.length; | ||
} | ||
@@ -102,3 +102,4 @@ function isReferenced({ | ||
} | ||
binding.referenced = binding.referencePaths.length + referencesInConstantViolations.length > 0; | ||
const nonTypeReferences = binding.referencePaths.filter(_findIdentifiers.nonType); | ||
binding.referenced = nonTypeReferences.length + referencesInConstantViolations.length > 0; | ||
return binding; | ||
@@ -105,0 +106,0 @@ } |
{ | ||
"name": "@linaria/utils", | ||
"version": "4.5.1", | ||
"version": "4.5.2", | ||
"description": "Blazing fast zero-runtime CSS in JS library", | ||
@@ -26,10 +26,13 @@ "keywords": [ | ||
"dependencies": { | ||
"@babel/core": "^7.20.2", | ||
"@babel/core": "^7.22.9", | ||
"@babel/generator": "^7.22.9", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.18.9", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.19.6", | ||
"@babel/traverse": "^7.20.1", | ||
"@babel/types": "^7.20.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.22.5", | ||
"@babel/template": "^7.22.5", | ||
"@babel/traverse": "^7.22.8", | ||
"@babel/types": "^7.22.5", | ||
"babel-merge": "^3.0.0", | ||
"find-up": "^5.0.0", | ||
"minimatch": "^9.0.3", | ||
"@linaria/logger": "^4.5.0" | ||
@@ -39,2 +42,4 @@ }, | ||
"@types/babel__core": "^7.1.19", | ||
"@types/babel__generator": "^7.6.4", | ||
"@types/babel__template": "^7.4.1", | ||
"@types/babel__traverse": "^7.17.1", | ||
@@ -41,0 +46,0 @@ "@types/node": "^17.0.39" |
@@ -1,2 +0,4 @@ | ||
import type { Scope } from '@babel/traverse'; | ||
import type { NodePath, Scope } from '@babel/traverse'; | ||
import type { ObjectExpression } from '@babel/types'; | ||
export declare function getOrAddLinariaPreval(scope: Scope): NodePath<ObjectExpression>; | ||
export declare function addIdentifierToLinariaPreval(scope: Scope, name: string): void; |
@@ -33,2 +33,2 @@ import type { NodePath } from '@babel/traverse'; | ||
export declare const explicitImport: (item: IImport | ISideEffectImport) => item is IImport; | ||
export default function collectExportsAndImports(path: NodePath, force?: boolean): IState; | ||
export declare function collectExportsAndImports(path: NodePath, force?: boolean): IState; |
@@ -1,10 +0,15 @@ | ||
export type { IVariableContext } from './IVariableContext'; | ||
export { addIdentifierToLinariaPreval } from './addIdentifierToLinariaPreval'; | ||
export { addIdentifierToLinariaPreval, getOrAddLinariaPreval, } from './addIdentifierToLinariaPreval'; | ||
export { default as asyncResolveFallback, syncResolve, } from './asyncResolveFallback'; | ||
export { default as collectExportsAndImports } from './collectExportsAndImports'; | ||
export * from './collectExportsAndImports'; | ||
export { collectExportsAndImports, explicitImport, sideEffectImport, } from './collectExportsAndImports'; | ||
export { collectTemplateDependencies, extractExpression, } from './collectTemplateDependencies'; | ||
export { createId } from './createId'; | ||
export { createPerfMeter } from './debug/perfMetter'; | ||
export { EventEmitter } from './EventEmitter'; | ||
export { default as findIdentifiers, nonType } from './findIdentifiers'; | ||
export { findPackageJSON } from './findPackageJSON'; | ||
export { hasEvaluatorMetadata } from './hasEvaluatorMetadata'; | ||
export { default as getFileIdx } from './getFileIdx'; | ||
export { hasMeta } from './hasMeta'; | ||
export { getSource } from './getSource'; | ||
export { isBoxedPrimitive } from './isBoxedPrimitive'; | ||
export { default as isExports } from './isExports'; | ||
@@ -14,7 +19,15 @@ export { default as isNotNull } from './isNotNull'; | ||
export { default as isRequire } from './isRequire'; | ||
export { isSerializable } from './isSerializable'; | ||
export { default as isTypedNode } from './isTypedNode'; | ||
export { default as isUnnecessaryReactCall } from './isUnnecessaryReactCall'; | ||
export * from './options'; | ||
export * from './scopeHelpers'; | ||
export { removeDangerousCode } from './removeDangerousCode'; | ||
export { applyAction, mutate, removeWithRelated, findActionForNode, dereference, reference, referenceAll, } from './scopeHelpers'; | ||
export { default as slugify } from './slugify'; | ||
export { ValueType } from './types'; | ||
export { valueToLiteral } from './valueToLiteral'; | ||
export { default as JSXElementsRemover } from './visitors/JSXElementsRemover'; | ||
export type { IExport, IImport, IReexport, ISideEffectImport, IState, } from './collectExportsAndImports'; | ||
export type { IPerfMeterOptions } from './debug/perfMetter'; | ||
export type { IVariableContext } from './IVariableContext'; | ||
export type { Artifact, BuildCodeFrameErrorFn, ConstValue, ExpressionValue, FunctionValue, ICSSRule, IEvaluatorMetadata, IMetadata, JSONArray, JSONObject, JSONValue, LazyValue, LinariaMetadata, Location, Replacement, Replacements, Rules, Serializable, StyledMeta, } from './types'; |
export { default as buildOptions } from './buildOptions'; | ||
export { default as loadBabelOptions } from './loadBabelOptions'; | ||
export { isFeatureEnabled } from './isFeatureEnabled'; | ||
export * from './types'; |
@@ -15,3 +15,9 @@ import type { TransformOptions } from '@babel/core'; | ||
export declare type VariableNameFn = (context: IVariableContext) => string; | ||
export declare type Evaluator = (filename: string, options: StrictOptions, code: string | [ast: File, text: string], only: string[] | null, babel: Core) => [ | ||
export declare type EvaluatorConfig = { | ||
features: StrictOptions['features']; | ||
highPriorityPlugins: string[]; | ||
onlyExports: string[]; | ||
}; | ||
export declare type Evaluator = (babelOptions: TransformOptions, ast: File, code: string, config: EvaluatorConfig, babel: Core) => [ | ||
ast: File, | ||
code: string, | ||
@@ -26,4 +32,9 @@ imports: Map<string, string[]> | null, | ||
}; | ||
export declare type FeatureFlag = boolean | string | string[]; | ||
export declare type FeatureFlags = { | ||
dangerousCodeRemover: FeatureFlag; | ||
}; | ||
export declare type StrictOptions = { | ||
babelOptions: TransformOptions; | ||
highPriorityPlugins: string[]; | ||
classNameSlug?: string | ClassNameFn; | ||
@@ -33,2 +44,3 @@ displayName: boolean; | ||
extensions: string[]; | ||
features: FeatureFlags; | ||
ignore?: RegExp; | ||
@@ -35,0 +47,0 @@ rules: EvalRule[]; |
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
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
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
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
598716
197
6089
12
5
7
+ Added@babel/generator@^7.22.9
+ Added@babel/template@^7.22.5
+ Addedminimatch@^9.0.3
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedminimatch@9.0.5(transitive)
Updated@babel/core@^7.22.9
Updated@babel/traverse@^7.22.8
Updated@babel/types@^7.22.5