Commit 83467013 authored by Nicolas Chevobbe's avatar Nicolas Chevobbe
Browse files

Bug 1709544 - [devtools] Fix debugger preview tooltip on scripts with private fields. r=bomsy.

This patch adds 2 babel plugin so we can parse such scripts.

Differential Revision: https://phabricator.services.mozilla.com/D114345
parent e76dc3b4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ module.exports = {
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-optional-chaining",
        "@babel/plugin-proposal-nullish-coalescing-operator",
        "@babel/plugin-proposal-private-methods",
        "@babel/plugin-proposal-private-property-in-object",
        [
          "module-resolver",
          {
@@ -71,6 +73,8 @@ module.exports = {
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-optional-chaining",
        "@babel/plugin-proposal-nullish-coalescing-operator",
        "@babel/plugin-proposal-private-methods",
        "@babel/plugin-proposal-private-property-in-object",
        "transform-amd-to-commonjs",
      ],
    },
+38 −5
Original line number Diff line number Diff line
@@ -8314,12 +8314,12 @@ const sourceOptions = {
  generated: {
    sourceType: "unambiguous",
    tokens: true,
    plugins: ["classProperties", "objectRestSpread", "optionalChaining", "nullishCoalescingOperator"]
    plugins: ["classPrivateProperties", "classPrivateMethods", "classProperties", "objectRestSpread", "optionalChaining", "nullishCoalescingOperator"]
  },
  original: {
    sourceType: "unambiguous",
    tokens: true,
    plugins: ["jsx", "flow", "doExpressions", "optionalChaining", "nullishCoalescingOperator", "decorators-legacy", "objectRestSpread", "classProperties", "exportDefaultFrom", "exportNamespaceFrom", "asyncGenerators", "functionBind", "functionSent", "dynamicImport", "react-jsx"]
    plugins: ["jsx", "flow", "doExpressions", "optionalChaining", "nullishCoalescingOperator", "decorators-legacy", "objectRestSpread", "classPrivateProperties", "classPrivateMethods", "classProperties", "exportDefaultFrom", "exportNamespaceFrom", "asyncGenerators", "functionBind", "functionSent", "dynamicImport", "react-jsx"]
  }
};
@@ -8391,7 +8391,7 @@ function parseVueScript(code) {
function parseConsoleScript(text, opts) {
  try {
    return _parse(text, {
      plugins: ["objectRestSpread", "dynamicImport", "nullishCoalescingOperator", "optionalChaining"],
      plugins: ["classPrivateProperties", "classPrivateMethods", "objectRestSpread", "dynamicImport", "nullishCoalescingOperator", "optionalChaining"],
      ...opts,
      allowAwaitOutsideFunction: true
    });
@@ -16197,6 +16197,8 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = createSimplePath;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
@@ -16209,14 +16211,23 @@ function createSimplePath(ancestors) {
  return new SimplePath(ancestors.slice());
}
/**
 * Mimics @babel/traverse's NodePath API in a simpler fashion that isn't as
 * heavy, but still allows the ease of passing paths around to process nested
 * AST structures.
 */
class SimplePath {
  constructor(ancestors, index = ancestors.length - 1) {
    _defineProperty(this, "_index", void 0);
    _defineProperty(this, "_ancestors", void 0);
    _defineProperty(this, "_ancestor", void 0);
    _defineProperty(this, "_parentPath", void 0);
    if (index < 0 || index >= ancestors.length) {
      console.error(ancestors);
      throw new Error("Created invalid path");
@@ -30219,7 +30230,6 @@ function findScopes(scopes, location) {
function compareLocations(a, b) {
  // According to type of Location.column can be undefined, if will not be the
  // case here, ignoring flow error.
  // $FlowIgnore
  return a.line == b.line ? a.column - b.column : a.line - b.line;
}
@@ -44876,6 +44886,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
 * "implicit"
 * Variables added automaticly like "this" and "arguments"
 *
 * "var"
 * Variables declared with "var" or non-block function declarations
 *
 * "let"
 * Variables declared with "let".
 *
 * "const"
 * Variables declared with "const", or added as const
 * bindings like inner function expressions and inner class names.
 *
 * "import"
 * Imported binding names exposed from other modules.
 *
 * "global"
 * Variables that reference undeclared global values.
 */
// Location information about the expression immediartely surrounding a
// given binding reference.
function isGeneratedId(id) {
  return !/\/originalSource/.test(id);
}
+5 −1
Original line number Diff line number Diff line
@@ -1223,7 +1223,11 @@ exports.isNodeTest = isNodeTest;
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function isNode() {
  return process && process.release && process.release.name == "node";
  try {
    return process.release.name == "node";
  } catch (e) {
    return false;
  }
}

function isNodeTest() {
+0 −1
Original line number Diff line number Diff line
@@ -1304,7 +1304,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
 *
 * Both are fine, but cannot be mixed for the same module.
 */
// $FlowIgnore
// Modules imported without destructuring
// We cannot directly export literals containing special characters
// (eg. "my-module/Test") which is why they are nested in "vendored".
+2 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
    "@babel/plugin-proposal-class-properties": "^7.5.5",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
    "@babel/plugin-proposal-optional-chaining": "^7.8.3",
    "@babel/plugin-proposal-private-property-in-object": "^7.14.0",
    "@babel/plugin-transform-modules-commonjs": "^7.5.0",
    "@babel/preset-env": "^7.5.5",
    "@babel/preset-react": "^7.0.0",
Loading