Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@babel/generator/lib/index.js

    rd565449 r0c6b92a  
    77var _sourceMap = require("./source-map.js");
    88var _printer = require("./printer.js");
    9 function normalizeOptions(code, opts) {
     9function normalizeOptions(code, opts, ast) {
     10  if (opts.experimental_preserveFormat) {
     11    if (typeof code !== "string") {
     12      throw new Error("`experimental_preserveFormat` requires the original `code` to be passed to @babel/generator as a string");
     13    }
     14    if (!opts.retainLines) {
     15      throw new Error("`experimental_preserveFormat` requires `retainLines` to be set to `true`");
     16    }
     17    if (opts.compact && opts.compact !== "auto") {
     18      throw new Error("`experimental_preserveFormat` is not compatible with the `compact` option");
     19    }
     20    if (opts.minified) {
     21      throw new Error("`experimental_preserveFormat` is not compatible with the `minified` option");
     22    }
     23    if (opts.jsescOption) {
     24      throw new Error("`experimental_preserveFormat` is not compatible with the `jsescOption` option");
     25    }
     26    if (!Array.isArray(ast.tokens)) {
     27      throw new Error("`experimental_preserveFormat` requires the AST to have attatched the token of the input code. Make sure to enable the `tokens: true` parser option.");
     28    }
     29  }
    1030  const format = {
    1131    auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
    1232    auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
    1333    shouldPrintComment: opts.shouldPrintComment,
     34    preserveFormat: opts.experimental_preserveFormat,
    1435    retainLines: opts.retainLines,
    1536    retainFunctionParens: opts.retainFunctionParens,
     
    4869    }
    4970  }
    50   if (format.compact) {
     71  if (format.compact || format.preserveFormat) {
    5172    format.indent.adjustMultilineComment = false;
    5273  }
     
    7192      this._map = void 0;
    7293      this._ast = ast;
    73       this._format = normalizeOptions(code, opts);
     94      this._format = normalizeOptions(code, opts, ast);
    7495      this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
    7596    }
     
    81102}
    82103function generate(ast, opts = {}, code) {
    83   const format = normalizeOptions(code, opts);
     104  const format = normalizeOptions(code, opts, ast);
    84105  const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
    85   const printer = new _printer.default(format, map);
     106  const printer = new _printer.default(format, map, ast.tokens, typeof code === "string" ? code : null);
    86107  return printer.generate(ast);
    87108}
Note: See TracChangeset for help on using the changeset viewer.