Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
4
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.21.9 to 7.22.0

lib/package.json

58

lib/generators/modules.js

@@ -17,3 +17,3 @@ "use strict";

exports.ImportSpecifier = ImportSpecifier;
exports._printAssertions = _printAssertions;
exports._printAttributes = _printAttributes;
var _t = require("@babel/types");

@@ -67,8 +67,31 @@ const {

}
function _printAssertions(node) {
this.word("assert");
let warningShown = false;
function _printAttributes(node) {
const {
importAttributesKeyword
} = this.format;
const {
attributes,
assertions
} = node;
if (attributes && !importAttributesKeyword && !warningShown) {
warningShown = true;
console.warn(`\
You are using import attributes, without specifying the desired output syntax.
Please specify the "importAttributesKeyword" generator option, whose value can be one of:
- "with" : \`import { a } from "b" with { type: "json" };\`
- "assert" : \`import { a } from "b" assert { type: "json" };\`
- "with-legacy" : \`import { a } from "b" with type: "json";\`
`);
}
const useAssertKeyword = importAttributesKeyword === "assert" || !importAttributesKeyword && assertions;
this.word(useAssertKeyword ? "assert" : "with");
this.space();
if (!useAssertKeyword && importAttributesKeyword !== "with") {
this.printList(attributes || assertions, node);
return;
}
this.tokenChar(123);
this.space();
this.printList(node.assertions, node);
this.printList(attributes || assertions, node);
this.space();

@@ -78,3 +101,3 @@ this.tokenChar(125);

function ExportAllDeclaration(node) {
var _node$assertions;
var _node$attributes, _node$assertions;
this.word("export");

@@ -90,6 +113,6 @@ this.space();

this.space();
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) {
this.print(node.source, node, true);
this.space();
this._printAssertions(node);
this._printAttributes(node);
} else {

@@ -143,10 +166,10 @@ this.print(node.source, node);

if (node.source) {
var _node$assertions2;
var _node$attributes2, _node$assertions2;
this.space();
this.word("from");
this.space();
if ((_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
this.print(node.source, node, true);
this.space();
this._printAssertions(node);
this._printAttributes(node);
} else {

@@ -171,3 +194,3 @@ this.print(node.source, node);

function ImportDeclaration(node) {
var _node$assertions3;
var _node$attributes3, _node$assertions3;
this.word("import");

@@ -214,18 +237,9 @@ this.space();

}
if ((_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
this.print(node.source, node, true);
this.space();
this._printAssertions(node);
this._printAttributes(node);
} else {
this.print(node.source, node);
}
{
var _node$attributes;
if ((_node$attributes = node.attributes) != null && _node$attributes.length) {
this.space();
this.word("with");
this.space();
this.printList(node.attributes, node);
}
}
this.semicolon();

@@ -232,0 +246,0 @@ }

@@ -239,3 +239,3 @@ "use strict";

} = node;
this.word(kind, kind === "using");
this.word(kind, kind === "using" || kind === "await using");
this.space();

@@ -242,0 +242,0 @@ let hasInits = false;

@@ -43,3 +43,4 @@ "use strict";

recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType,
topicToken: opts.topicToken
topicToken: opts.topicToken,
importAttributesKeyword: opts.importAttributesKeyword
};

@@ -46,0 +47,0 @@ {

{
"name": "@babel/generator",
"version": "7.21.9",
"version": "7.22.0",
"description": "Turns an AST into code.",

@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/types": "^7.21.5",
"@babel/types": "^7.22.0",
"@jridgewell/gen-mapping": "^0.3.2",

@@ -30,3 +30,3 @@ "@jridgewell/trace-mapping": "^0.3.17",

"@babel/helper-fixtures": "^7.21.5",
"@babel/parser": "^7.21.9",
"@babel/parser": "^7.22.0",
"@types/jsesc": "^2.5.0",

@@ -33,0 +33,0 @@ "charcodes": "^0.2.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc