🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@marko/compiler

Package Overview
Dependencies
Maintainers
7
Versions
377
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marko/compiler - npm Package Compare versions

Comparing version
5.40.1
to
5.40.2
+5
-2
babel-utils.d.ts

@@ -181,7 +181,10 @@ import type { Config, types as t } from "@marko/compiler";

): void;
export function assertNoArgs(path: t.NodePath<t.MarkoTag>): void;
export function assertNoArgs(path: t.NodePath<t.MarkoTag>, hint?: string): void;
export function assertNoVar(path: t.NodePath<t.MarkoTag>): void;
export function assertNoAttributes(path: t.NodePath<t.MarkoTag>): void;
export function assertNoParams(path: t.NodePath<t.MarkoTag>): void;
export function assertNoAttributeTags(path: t.NodePath<t.MarkoTag>): void;
export function assertNoAttributeTags(
path: t.NodePath<t.MarkoTag>,
hint?: string,
): void;
export function assertAttributesOrArgs(path: t.NodePath<t.MarkoTag>): void;

@@ -188,0 +191,0 @@ export function assertAttributesOrSingleArg(path: t.NodePath<t.MarkoTag>): void;

@@ -326,2 +326,25 @@ "use strict";exports.__esModule = true;exports.default = void 0;var _babel = require("@marko/compiler/internal/babel");

traverseAll(file, translator.analyze);
if (!markoOpts.errorRecovery) {
// Analyze failures are recorded as error diagnostics so the whole
// template reports at once (and editors compiling with
// `errorRecovery` keep them as recoverable diagnostics); mirror
// the parse layer by throwing them together at the stage's end.
const seen = new Set();
const errors = [];
for (const diag of meta.diagnostics) {
if (diag.type !== _diagnostics.DiagnosticType.Error) continue;
const key = `${
diag.loc ? `${diag.loc.start.line}:${diag.loc.start.column}` : ""}:${
diag.label}`;
if (seen.has(key)) continue;
seen.add(key);
errors.push(
(0, _buildCodeFrame.buildCodeFrameError)(filename, file.code, diag.loc, diag.label)
);
if (errors.length === 8) break;
}
(0, _mergeErrors.default)(errors);
}
} catch (e) {

@@ -328,0 +351,0 @@ compileCache.delete(id);

@@ -19,2 +19,18 @@ "use strict";exports.__esModule = true;exports.parseMarko = parseMarko;var _babelUtils = require("@marko/compiler/babel-utils");

const noop = () => {};
const jsxStyleAttrValueReg = /^\{[\s\S]*\}$/;
// A brace wrapped attribute value that only parses once unwrapped is almost
// certainly a JSX/Svelte style value (eg `onClick={handler}`); say so instead
// of surfacing the bare expression parse error.
const withWrappedAttrValueHint = (file, part, rawValue, node) => {
const trimmed = rawValue.trim();
if (
node.type === "MarkoParseError" &&
jsxStyleAttrValueReg.test(trimmed) &&
(0, _babelUtils.parseExpression)(file, trimmed.slice(1, -1), part.value.start).type !==
"MarkoParseError")
{
node.label += `${node.label.endsWith(".") ? "" : "."} Attribute values in Marko are plain JavaScript expressions, not JSX; remove the wrapping \`{ }\`.`;
}
return node;
};
const emptyRange = (part) => part.start === part.end;

@@ -416,6 +432,8 @@ const isAttrTag = (tag) => tag.name.value?.[0] === "@";

currentAttr.bound = part.bound;
currentAttr.value = (0, _babelUtils.parseExpression)(
const rawAttrValue = parser.read(part.value);
currentAttr.value = withWrappedAttrValueHint(
file,
parser.read(part.value),
part.value.start
part,
rawAttrValue,
(0, _babelUtils.parseExpression)(file, rawAttrValue, part.value.start)
);

@@ -422,0 +440,0 @@ },

@@ -44,7 +44,7 @@ "use strict";exports.__esModule = true;exports.assertAllowedAttributes = assertAllowedAttributes;exports.assertAttributesOrArgs = assertAttributesOrArgs;exports.assertAttributesOrSingleArg = assertAttributesOrSingleArg;exports.assertNoArgs = assertNoArgs;exports.assertNoAttributeTags = assertNoAttributeTags;exports.assertNoAttributes = assertNoAttributes;exports.assertNoParams = assertNoParams;exports.assertNoVar = assertNoVar;function assertAllowedAttributes(path, allowed) {

function assertNoAttributeTags(path) {
function assertNoAttributeTags(path, hint) {
if (path.node.attributeTags.length) {
throw path.hub.buildError(
path.node.attributeTags[0],
"Tag not support nested attribute tags."
`Tag does not support nested attribute tags.${hint ? ` ${hint}` : ""}`
);

@@ -54,3 +54,3 @@ }

function assertNoArgs(path) {
function assertNoArgs(path, hint) {
const args = path.node.arguments;

@@ -62,3 +62,3 @@ if (args && args.length) {

{ loc: { start, end } },
"Tag does not support arguments."
`Tag does not support arguments.${hint ? ` ${hint}` : ""}`
);

@@ -65,0 +65,0 @@ }

{
"name": "@marko/compiler",
"version": "5.40.1",
"version": "5.40.2",
"description": "Marko template to JS compiler.",

@@ -5,0 +5,0 @@ "keywords": [