feat(es/testing): Print comments in test_fixture (#3920)

This commit is contained in:
Donny/강동윤 2022-03-09 11:54:27 +09:00 committed by GitHub
parent 1196cc8155
commit 3d43a9b69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 1642 additions and 570 deletions

4
Cargo.lock generated
View File

@ -2182,9 +2182,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.4"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",

View File

@ -1,4 +1,4 @@
let Foo = function(UnknownNativeClass) {
let Foo = /*#__PURE__*/ function(UnknownNativeClass) {
"use strict";
_inherits(Foo, UnknownNativeClass);
var _super = _createSuper(Foo);

View File

@ -9,18 +9,23 @@ class Foo {
var _class;
this.Bar = (_class = class {
constructor(){
this.q = void 0;
this.q = void 0 // should not replace
;
}
}, _class.p = void 0, _class.p1 = class {
constructor(){
new.target;
}
}, _class.p2 = new function _target() {
} // should not replace
, _class.p2 = new function _target() {
this.constructor;
}, _class.p3 = function() {
} // should not replace
, _class.p3 = function() {
void 0;
}, _class.p4 = function _target() {
} // should replace
, _class.p4 = function _target() {
this.constructor;
}, _class);
} // should not replace
, _class);
}
}

View File

@ -9,18 +9,23 @@ class Foo {
var _class;
this.Bar = (_class = class {
constructor(){
_defineProperty(this, "q", void 0);
_defineProperty(this, "q", void 0 // should not replace
);
}
}, _defineProperty(_class, "p", void 0), _defineProperty(_class, "p1", class {
constructor(){
new.target;
}
}), _defineProperty(_class, "p2", new function _target() {
} // should not replace
), _defineProperty(_class, "p2", new function _target() {
this.constructor;
}), _defineProperty(_class, "p3", function() {
} // should not replace
), _defineProperty(_class, "p3", function() {
void 0;
}), _defineProperty(_class, "p4", function _target() {
} // should replace
), _defineProperty(_class, "p4", function _target() {
this.constructor;
}), _class);
} // should not replace
), _class);
}
}

View File

@ -1,5 +1,5 @@
var _foo = new WeakMap();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);

View File

@ -1,5 +1,5 @@
var _foo = new WeakMap();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);

View File

@ -1,5 +1,5 @@
var _foo = new WeakSet();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);

View File

@ -1,5 +1,5 @@
var _foo = new WeakMap(), _bar = new WeakMap();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);
@ -17,7 +17,7 @@ let Foo = function() {
key: "test",
value: function test() {
var _bar1 = new WeakMap();
let Nested = function() {
let Nested = /*#__PURE__*/ function() {
function Nested() {
_classCallCheck(this, Nested);
_classPrivateFieldInit(this, _bar1, {

View File

@ -1,5 +1,5 @@
var _foo = new WeakMap();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);
@ -13,7 +13,7 @@ let Foo = function() {
key: "test",
value: function test() {
var _foo1 = new WeakMap();
let Nested = function() {
let Nested = /*#__PURE__*/ function() {
function Nested() {
_classCallCheck(this, Nested);
_classPrivateFieldInit(this, _foo1, {

View File

@ -1,5 +1,5 @@
var _foo = new WeakMap();
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);
@ -12,7 +12,7 @@ let Foo = function() {
{
key: "test",
value: function test() {
let Nested = function() {
let Nested = /*#__PURE__*/ function() {
function Nested() {
_classCallCheck(this, Nested);
}

View File

@ -1,4 +1,4 @@
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);

View File

@ -1,4 +1,4 @@
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);

View File

@ -1,4 +1,4 @@
let Foo = function() {
let Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_classCallCheck(this, Foo);
@ -13,5 +13,4 @@ let Foo = function() {
]);
return Foo;
}();
function foo() {
}
function foo() {}

View File

@ -1,4 +1,11 @@
"use strict";
/** @license React v17.0.2
* react-jsx-runtime.profiling.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ "use strict";
require("object-assign");
var f = require("react"), g = 60103;
exports.Fragment = 60107;

View File

@ -13,7 +13,7 @@ use swc_ecma_transforms_module::common_js::common_js;
use swc_ecma_transforms_testing::{parse_options, test, test_fixture_allowing_error, Tester};
use super::*;
use crate::{display_name, react};
use crate::{display_name, pure_annotations, react};
fn tr(t: &mut Tester, options: Options, top_level_mark: Mark) -> impl Fold {
chain!(
@ -72,6 +72,7 @@ fn fixture_tr(t: &mut Tester, mut options: FixtureOptions) -> impl Fold {
top_level_mark
),
display_name(),
pure_annotations(Some(t.comments.clone()))
)
}

View File

@ -1,14 +1,13 @@
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
const App = _jsxDEV("div", {
const App = /*#__PURE__*/ _jsxDEV("div", {
children: [
_jsxDEV("div", {
}, void 0, false, {
/*#__PURE__*/ _jsxDEV("div", {}, void 0, false, {
fileName: "input.js",
lineNumber: 3,
columnNumber: 9
}, this),
_jsxDEV(_Fragment, {
children: _jsxDEV("div", {
/*#__PURE__*/ _jsxDEV(_Fragment, {
children: /*#__PURE__*/ _jsxDEV("div", {
children: "hoge"
}, 1, false, {
fileName: "input.js",

View File

@ -1,10 +1,9 @@
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
const App = _jsxs("div", {
const App = /*#__PURE__*/ _jsxs("div", {
children: [
_jsx("div", {
}),
_jsx(_Fragment, {
children: _jsx("div", {
/*#__PURE__*/ _jsx("div", {}),
/*#__PURE__*/ _jsx(_Fragment, {
children: /*#__PURE__*/ _jsx("div", {
children: "hoge"
}, 1)
})

View File

@ -1,14 +1,13 @@
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
const App = _jsxDEV("div", {
/**@jsxRuntime automatic */ const App = /*#__PURE__*/ _jsxDEV("div", {
children: [
_jsxDEV("div", {
}, void 0, false, {
/*#__PURE__*/ _jsxDEV("div", {}, void 0, false, {
fileName: "input.js",
lineNumber: 4,
columnNumber: 9
}, this),
_jsxDEV(_Fragment, {
children: _jsxDEV("div", {
/*#__PURE__*/ _jsxDEV(_Fragment, {
children: /*#__PURE__*/ _jsxDEV("div", {
children: "hoge"
}, void 0, false, {
fileName: "input.js",

View File

@ -8,12 +8,10 @@ const Bar = ()=>{
var c = _react5();
var jsx = 1;
var _jsx1 = 2;
return _jsx("div", {
});
return(/*#__PURE__*/ _jsx("div", {}));
}
;
return _jsx("span", {
});
return(/*#__PURE__*/ _jsx("span", {}));
};
};
};

View File

@ -1,6 +1,4 @@
import { jsx as _jsx } from "baz/jsx-runtime";
/** @jsxImportSource baz */
var x = _jsx("div", {
children: _jsx("span", {})
/** @jsxImportSource baz */ var x = /*#__PURE__*/ _jsx("div", {
children: /*#__PURE__*/ _jsx("span", {})
});

View File

@ -1,5 +1,4 @@
import { jsx as _jsx } from "foo/jsx-runtime";
var x = _jsx("div", {
children: _jsx("span", {})
var x = /*#__PURE__*/ _jsx("div", {
children: /*#__PURE__*/ _jsx("span", {})
});

View File

@ -1,19 +1,17 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { createElement as _createElement } from "react";
import * as react from "react";
var y = react.createElement("div", {
var y = /*#__PURE__*/ react.createElement("div", {
foo: 1
});
var x = _jsxs("div", {
var x = /*#__PURE__*/ _jsxs("div", {
children: [
_jsx("div", {
}, "1"),
_jsx("div", {
/*#__PURE__*/ _jsx("div", {}, "1"),
/*#__PURE__*/ _jsx("div", {
meow: "wolf"
}, "2"),
_jsx("div", {
}, "3"),
_createElement("div", {
/*#__PURE__*/ _jsx("div", {}, "3"),
/*#__PURE__*/ _createElement("div", {
...props,
key: "4"
})

View File

@ -0,0 +1,2 @@
import React from 'react';
React.createElement('div');

View File

@ -0,0 +1,2 @@
import React from "react";
/*#__PURE__*/ React.createElement("div");

View File

@ -1 +1 @@
React.createElement(React.Fragment, null, React.createElement("span", null, "Hello something long to not trigger line break"), "\xa0");
/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("span", null, "Hello something long to not trigger line break"), "\xa0");

View File

@ -1,9 +1,10 @@
// Foo.jsx
import React from "react";
export default function Foo() {
return React.createElement("div", {
return(/*#__PURE__*/ React.createElement("div", {
onClick: async (e)=>{
await doSomething();
}
});
}));
};
Foo.displayName = "Foo";

View File

@ -1,8 +1,8 @@
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
export var App = function() {
return _jsx(_Fragment, {
children: _jsx("div", {
return(/*#__PURE__*/ _jsx(_Fragment, {
children: /*#__PURE__*/ _jsx("div", {
children: "1"
})
});
}));
};

View File

@ -1,3 +1,3 @@
React.createElement(Page, {
/*#__PURE__*/ React.createElement(Page, {
num: "\\\\ "
}, "ABC");

View File

@ -1,3 +1,3 @@
React.createElement(Page, {
/*#__PURE__*/ React.createElement(Page, {
num: "\\\\\\\\"
}, "ABC");

View File

@ -1 +1 @@
React.createElement("div", null);
/*#__PURE__*/ React.createElement("div", null);

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
});
/* @jsx h */ /*#__PURE__*/ _jsx("div", {});

View File

@ -1,2 +1 @@
/* @jsx h */
h("div", null);
/* @jsx h */ /*#__PURE__*/ h("div", null);

View File

@ -1 +1 @@
h("div", null);
/*#__PURE__*/ h("div", null);

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
});
/*#__PURE__*/ _jsx("div", {});

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
});
/* @jsx h */ /*#__PURE__*/ _jsx("div", {});

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
});
/*#__PURE__*/ _jsx("div", {});

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
});
/* @jsx h */ /*#__PURE__*/ _jsx("div", {});

View File

@ -1,2 +1 @@
/* @jsx h */
h("div", null);
/* @jsx h */ /*#__PURE__*/ h("div", null);

View File

@ -1 +1 @@
h("div", null);
/*#__PURE__*/ h("div", null);

View File

@ -1,5 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx(Component, {
/*#__PURE__*/ _jsx(Component, {
...props,
sound: "moo"
});

View File

@ -1,5 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime";
var div = _jsx(Component, {
var div = /*#__PURE__*/ _jsx(Component, {
...props,
foo: "bar"
});

View File

@ -1,10 +1,10 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var x = _jsxs("div", {
var x = /*#__PURE__*/ _jsxs("div", {
children: [
"foo",
"bar",
"baz",
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "buz bang"
}),
"qux",

View File

@ -1,5 +1,5 @@
import { jsxs as _jsxs } from "react/jsx-runtime";
_jsxs(Text, {
/*#__PURE__*/ _jsxs(Text, {
children: [
"To get started, edit index.ios.js!!!",
"\n",

View File

@ -1,4 +1,3 @@
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
var x = _jsx(React.Fragment, {
}, "foo");
var x = /*#__PURE__*/ _jsx(React.Fragment, {}, "foo");

View File

@ -1,3 +1,2 @@
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var x = _jsx(_Fragment, {
});
var x = /*#__PURE__*/ _jsx(_Fragment, {});

View File

@ -1,5 +1,4 @@
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var x = _jsx(_Fragment, {
children: _jsx("div", {
})
var x = /*#__PURE__*/ _jsx(_Fragment, {
children: /*#__PURE__*/ _jsx("div", {})
});

View File

@ -1,13 +1,10 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var x = _jsxs("div", {
var x = /*#__PURE__*/ _jsxs("div", {
children: [
_jsx("span", {
}),
/*#__PURE__*/ _jsx("span", {}),
[
_jsx("span", {
}, "0"),
_jsx("span", {
}, "1")
/*#__PURE__*/ _jsx("span", {}, "0"),
/*#__PURE__*/ _jsx("span", {}, "1")
]
]
});

View File

@ -1,6 +1,4 @@
import { jsx as _jsx } from "foo/jsx-runtime";
/* @jsxImportSource foo*/
_jsx("div", {
children: "Hi"
/* @jsxImportSource foo*/ /*#__PURE__*/ _jsx("div", {
children: "Hi"
});

View File

@ -1 +1 @@
React.createElement("div", null);
/*#__PURE__*/ React.createElement("div", null);

View File

@ -1 +1 @@
React.createElement("Namespace:Component", null);
/*#__PURE__*/ React.createElement("Namespace:Component", null);

View File

@ -1,10 +1,10 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
id: "w\xf4w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
id: "\\w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
id: "w < w"
});

View File

@ -1,31 +1,31 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "wow"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "w\xf4w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "w & w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "w & w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "w \xa0 w"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "this should not parse as unicode: \\u00a0"
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "this should parse as nbsp: \xa0 "
});
_jsxs("div", {
/*#__PURE__*/ _jsxs("div", {
children: [
"this should parse as unicode: ",
"\xa0\xa0"
]
});
_jsx("div", {
/*#__PURE__*/ _jsx("div", {
children: "w < w"
});

View File

@ -1,11 +1,9 @@
import { jsx as _jsx } from "react/jsx-runtime";
var x = /*#__PURE__*/_jsx("div", {
/* a multi-line
comment */
attr1: "foo",
children: /*#__PURE__*/_jsx("span", {
// a double-slash comment
attr2: "bar"
})
var x = /*#__PURE__*/ _jsx("div", {
/* a multi-line
comment */ attr1: "foo",
children: /*#__PURE__*/ _jsx("span" // a double-slash comment
, {
attr2: "bar"
})
});

View File

@ -1,3 +1,2 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx("f:image", {
});
/*#__PURE__*/ _jsx("f:image", {});

View File

@ -1,5 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime";
_jsx(Component, {
/*#__PURE__*/ _jsx(Component, {
y: 2,
...x,
z: true

View File

@ -1,6 +1,8 @@
/** @jsx dom */
dom(Foo, null);
var profile = dom("div", null, dom("img", {
src: "avatar.png",
className: "profile"
}), dom("h3", null, [user.firstName, user.lastName].join(" ")));
/** @jsx dom */ /*#__PURE__*/ dom(Foo, null);
var profile = /*#__PURE__*/ dom("div", null, /*#__PURE__*/ dom("img", {
src: "avatar.png",
className: "profile"
}), /*#__PURE__*/ dom("h3", null, [
user.firstName,
user.lastName
].join(" ")));

View File

@ -1,6 +1,8 @@
/** @jsx dom */
dom(Foo, null);
var profile = dom("div", null, dom("img", {
src: "avatar.png",
className: "profile"
}), dom("h3", null, [user.firstName, user.lastName].join(" ")));
/** @jsx dom */ /*#__PURE__*/ dom(Foo, null);
var profile = /*#__PURE__*/ dom("div", null, /*#__PURE__*/ dom("img", {
src: "avatar.png",
className: "profile"
}), /*#__PURE__*/ dom("h3", null, [
user.firstName,
user.lastName
].join(" ")));

View File

@ -1,5 +1,8 @@
dom(Foo, null);
var profile = dom("div", null, dom("img", {
src: "avatar.png",
className: "profile"
}), dom("h3", null, [user.firstName, user.lastName].join(" ")));
/*#__PURE__*/ dom(Foo, null);
var profile = /*#__PURE__*/ dom("div", null, /*#__PURE__*/ dom("img", {
src: "avatar.png",
className: "profile"
}), /*#__PURE__*/ dom("h3", null, [
user.firstName,
user.lastName
].join(" ")));

View File

@ -1,2 +1 @@
/* @jsx foo*/
foo("div", null, "Hi");
/* @jsx foo*/ /*#__PURE__*/ foo("div", null, "Hi");

View File

@ -1,5 +1,4 @@
/* @jsxRuntime automatic @jsxImportSource react */
import { jsx as _jsx } from "preact/jsx-runtime";
var div = _jsx("div", {
/* @jsxRuntime automatic @jsxImportSource preact */ var div = /*#__PURE__*/ _jsx("div", {
children: "test"
});

View File

@ -1,2 +1 @@
/** @jsx dom */
dom("div", null, "no fragment is used");
/** @jsx dom */ /*#__PURE__*/ dom("div", null, "no fragment is used");

View File

@ -1,4 +1 @@
/** @jsx dom */
/** @jsxFrag DomFrag */
dom(DomFrag, null);
/** @jsx dom */ /** @jsxFrag DomFrag */ /*#__PURE__*/ dom(DomFrag, null);

View File

@ -1 +1 @@
React.createElement("div", null);
/*#__PURE__*/ React.createElement("div", null);

View File

@ -1 +1 @@
React.createElement("Namespace:Component", null);
/*#__PURE__*/ React.createElement("Namespace:Component", null);

View File

@ -1,9 +1,9 @@
React.createElement("div", {
/*#__PURE__*/ React.createElement("div", {
id: "w\xf4w"
});
React.createElement("div", {
/*#__PURE__*/ React.createElement("div", {
id: "\\w"
});
React.createElement("div", {
/*#__PURE__*/ React.createElement("div", {
id: "w < w"
});

View File

@ -1,9 +1,9 @@
var HelloMessage = React.createClass({
render: function() {
return React.createElement("div", null, "Hello ", this.props.name);
return(/*#__PURE__*/ React.createElement("div", null, "Hello ", this.props.name));
},
displayName: "HelloMessage"
});
React.render(React.createElement(HelloMessage, {
name: React.createElement("span", null, "Sebastian")
React.render(/*#__PURE__*/ React.createElement(HelloMessage, {
name: /*#__PURE__*/ React.createElement("span", null, "Sebastian")
}), mountNode);

View File

@ -1,8 +1,7 @@
var x = /*#__PURE__*/React.createElement("div", {
/* a multi-line
comment */
attr1: "foo"
}, /*#__PURE__*/React.createElement("span", {
// a double-slash comment
attr2: "bar"
var x = /*#__PURE__*/ React.createElement("div", {
/* a multi-line
comment */ attr1: "foo"
}, /*#__PURE__*/ React.createElement("span" // a double-slash comment
, {
attr2: "bar"
}));

View File

@ -1,3 +1,3 @@
h("f:image", {
"n:attr": true
/*#__PURE__*/ h("f:image", {
"n:attr": true
});

View File

@ -1 +1 @@
h("f:image", null);
/*#__PURE__*/ h("f:image", null);

View File

@ -1,4 +1 @@
/* @jsxFrag React.Fragment */
/* @jsx h */
h(React.Fragment, null, "Test");
/* @jsxFrag React.Fragment */ /* @jsx h */ /*#__PURE__*/ h(React.Fragment, null, "Test");

View File

@ -1,4 +1,4 @@
export default React.createElement(A, {
export default /*#__PURE__*/ React.createElement(A, {
className: b,
header: "C",
subheader: "D E"

View File

@ -1,5 +1,5 @@
export default (()=>{
return React.createElement(Input, {
return(/*#__PURE__*/ React.createElement(Input, {
pattern: ".*\\S+.*"
});
}));
});

View File

@ -1,4 +1,6 @@
#![deny(clippy::all)]
#![deny(clippy::all)]
#![deny(unused)]
#![allow(clippy::result_unit_err)]
use std::{
@ -31,8 +33,9 @@ use swc_ecma_transforms_base::{
fixer,
helpers::{inject_helpers, HELPERS},
hygiene,
pass::noop,
};
use swc_ecma_utils::{quote_ident, quote_str, DropSpan, ExprFactory};
use swc_ecma_utils::{quote_ident, quote_str, ExprFactory};
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, FoldWith, VisitMut, VisitMutWith};
use tempfile::tempdir_in;
use testing::{assert_eq, find_executable, NormalizedOutput};
@ -164,9 +167,6 @@ impl<'a> Tester<'a> {
let module = module
.fold_with(&mut tr)
.fold_with(&mut as_folder(DropSpan {
preserve_ctxt: true,
}))
.fold_with(&mut as_folder(Normalizer));
Ok(module)
@ -289,6 +289,9 @@ pub fn test_transform<F, P>(
}
let actual = actual
.fold_with(&mut as_folder(::swc_ecma_utils::DropSpan {
preserve_ctxt: true,
}))
.fold_with(&mut hygiene::hygiene())
.fold_with(&mut fixer::fixer(Some(&tester.comments)));
@ -682,14 +685,7 @@ fn test_fixture_inner<P>(
let expected = expected.unwrap_or_default();
let expected_src = Tester::run(|tester| {
let expected_module = tester.apply_transform(
as_folder(::swc_ecma_utils::DropSpan {
preserve_ctxt: true,
}),
"expected.js",
syntax,
&expected,
)?;
let expected_module = tester.apply_transform(noop(), "expected.js", syntax, &expected)?;
let expected_src = tester.print(&expected_module, &tester.comments.clone());
@ -730,10 +726,7 @@ fn test_fixture_inner<P>(
let actual = actual
.fold_with(&mut crate::hygiene::hygiene())
.fold_with(&mut crate::fixer::fixer(Some(&tester.comments)))
.fold_with(&mut as_folder(DropSpan {
preserve_ctxt: false,
}));
.fold_with(&mut crate::fixer::fixer(Some(&tester.comments)));
let actual_src = tester.print(&actual, &tester.comments.clone());

View File

@ -5,20 +5,18 @@ var Foo;
Foo[Foo["b"] = 10] = "b";
Foo[Foo["c"] = Foo.b + x] = "c";
Foo[Foo["d"] = Foo.c] = "d";
})(Foo || (Foo = {
}));
})(Foo || (Foo = {}));
var Bar;
(function(Bar) {
Bar[Bar["a"] = 1] = "a";
Bar[Bar["b"] = Foo.a] = "b";
Bar[Bar["E"] = Bar.b] = "E";
Bar[Bar["F"] = Math.E] = "F";
})(Bar || (Bar = {
}));
})(Bar || (Bar = {}));
var Baz;
(function(Baz) {
Baz[Baz["a"] = 0] = "a";
Baz[Baz["b"] = 1] = "b";
Baz[Baz["x"] = Baz.a.toString()] = "x";
})(Baz || (Baz = {
}));
Baz[Baz[// @ts-ignore
"x"] = Baz.a.toString()] = "x";
})(Baz || (Baz = {}));

View File

@ -63,6 +63,7 @@ class ServerRouter {
}
}
function enhanceComponents(options, App, Component) {
// For backwards compatibility
if (typeof options === "function") {
return {
App,
@ -88,7 +89,7 @@ function checkRedirectValues(redirect, req, method) {
errors.push(`\`permanent\` must be \`true\` or \`false\``);
} else if (hasStatusCode && !allowedStatusCodes.has(statusCode)) {
errors.push(`\`statusCode\` must undefined or one of ${[
...allowedStatusCodes
...allowedStatusCodes,
].join(", ")}`);
}
const destinationType = typeof destination;
@ -104,9 +105,13 @@ function checkRedirectValues(redirect, req, method) {
}
}
export async function renderToHTML(req, res, pathname, query, renderOpts) {
// In dev we invalidate the cache by appending a timestamp to the resource URL.
// This is a workaround to fix https://github.com/vercel/next.js/issues/5860
// TODO: remove this workaround when https://bugs.webkit.org/show_bug.cgi?id=187726 is fixed.
renderOpts.devOnlyCacheBusterQueryString = renderOpts.dev ? renderOpts.devOnlyCacheBusterQueryString || `?ts=${Date.now()}` : "";
// don't modify original query object
query = Object.assign({}, query);
const { err , dev =false , ampPath ="" , App , Document , pageConfig ={} , Component , buildManifest , fontManifest , reactLoadableManifest , ErrorDebug , getStaticProps , getStaticPaths , getServerSideProps , isDataReq , params , previewProps , basePath , devOnlyCacheBusterQueryString , supportsDynamicHTML , concurrentFeatures } = renderOpts;
const { err , dev =false , ampPath ="" , App , Document , pageConfig ={} , Component , buildManifest , fontManifest , reactLoadableManifest , ErrorDebug , getStaticProps , getStaticPaths , getServerSideProps , isDataReq , params , previewProps , basePath , devOnlyCacheBusterQueryString , supportsDynamicHTML , concurrentFeatures , } = renderOpts;
const getFontDefinition = (url)=>{
if (fontManifest) {
return getFontDefinitionFromManifest(url, fontManifest);
@ -147,7 +152,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
for (const methodName of [
"getStaticProps",
"getServerSideProps",
"getStaticPaths"
"getStaticPaths",
]){
if (Component[methodName]) {
throw new Error(`page ${pathname} ${methodName} ${GSSP_COMPONENT_MEMBER_ERROR}`);
@ -184,12 +189,14 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
throw new Error(`The default export is not a React Component in page: "/_document"`);
}
if (isAutoExport || isFallback) {
// remove query values except ones that will be set during export
query = {
...query.amp ? {
amp: query.amp
} : {}
};
asPath = `${pathname}${req.url.endsWith("/") && pathname !== "/" && !pageIsDynamic ? "/" : ""}`;
asPath = `${pathname}${// ensure trailing slash is present for non-dynamic auto-export pages
req.url.endsWith("/") && pathname !== "/" && !pageIsDynamic ? "/" : ""}`;
req.url = pathname;
}
if (pathname === "/404" && (hasPageGetInitialProps || getServerSideProps)) {
@ -199,13 +206,17 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
throw new Error(`\`pages${pathname}\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}`);
}
}
await Loadable.preloadAll();
await Loadable.preloadAll(); // Make sure all dynamic imports are loaded
let isPreview;
let previewData;
if ((isSSG || getServerSideProps) && !isFallback) {
// Reads of this are cached on the `req` object, so this should resolve
// instantly. There's no need to pass this data down from a previous
// invoke, where we'd have to consider server & serverless.
previewData = tryGetPreviewData(req, res, previewProps);
isPreview = previewData !== false;
}
// url will always be set
const routerIsReady = !!(getServerSideProps || hasPageGetInitialProps || !defaultAppGetInitialProps && !isSSG);
const router = new ServerRouter(pathname, query, asPath, {
isFallback: isFallback
@ -315,6 +326,8 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
defaultLocale: renderOpts.defaultLocale
});
} catch (staticPropsError) {
// remove not found error code to prevent triggering legacy
// 404 rendering
if (staticPropsError && staticPropsError.code === "ENOENT") {
delete staticPropsError.code;
}
@ -357,6 +370,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
renderOpts.isRedirect = true;
}
if ((dev || isBuildTimeSSG) && !renderOpts.isNotFound && !isSerializableProps(pathname, "getStaticProps", data.props)) {
// this fn should throw an error instead of ever returning `false`
throw new Error("invariant: getStaticProps did not return valid props. Please report this.");
}
if ("revalidate" in data) {
@ -366,21 +380,30 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
} else if (data.revalidate <= 0) {
throw new Error(`A page's revalidate option can not be less than or equal to zero for ${req.url}. A revalidate option of zero means to revalidate after _every_ request, and implies stale data cannot be tolerated.` + `\n\nTo never revalidate, you can set revalidate to \`false\` (only ran once at build-time).` + `\nTo revalidate as soon as possible, you can set the value to \`1\`.`);
} else if (data.revalidate > 31536000) {
// if it's greater than a year for some reason error
console.warn(`Warning: A page's revalidate option was set to more than a year for ${req.url}. This may have been done in error.` + `\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!`);
}
} else if (data.revalidate === true) {
// When enabled, revalidate after 1 second. This value is optimal for
// the most up-to-date page possible, but without a 1-to-1
// request-refresh ratio.
data.revalidate = 1;
} else if (data.revalidate === false || typeof data.revalidate === "undefined") {
// By default, we never revalidate.
data.revalidate = false;
} else {
throw new Error(`A page's revalidate option must be seconds expressed as a natural number. Mixed numbers and strings cannot be used. Received '${JSON.stringify(data.revalidate)}' for ${req.url}`);
}
} else {
data.revalidate = false;
// By default, we never revalidate.
(data).revalidate = false;
}
props1.pageProps = Object.assign({}, props1.pageProps, "props" in data ? data.props : undefined);
renderOpts.revalidate = "revalidate" in data ? data.revalidate : undefined;
// pass up revalidate and props for export
// TODO: change this to a different passing mechanism
(renderOpts).revalidate = "revalidate" in data ? data.revalidate : undefined;
renderOpts.pageData = props1;
// this must come after revalidate is added to renderOpts
if (renderOpts.isNotFound) {
return null;
}
@ -421,6 +444,8 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
});
canAccessRes = false;
} catch (serverSidePropsError) {
// remove not found error code to prevent triggering legacy
// 404 rendering
if (isError(serverSidePropsError) && serverSidePropsError.code === "ENOENT") {
delete serverSidePropsError.code;
}
@ -462,6 +487,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
data.props = await data.props;
}
if ((dev || isBuildTimeSSG) && !isSerializableProps(pathname, "getServerSideProps", data.props)) {
// this fn should throw an error instead of ever returning `false`
throw new Error("invariant: getServerSideProps did not return valid props. Please report this.");
}
props1.pageProps = Object.assign({}, props1.pageProps, data.props);
@ -470,16 +496,26 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
if (!isSSG && !getServerSideProps && process.env.NODE_ENV !== "production" && Object.keys(props1?.pageProps || {}).includes("url")) {
console.warn(`The prop \`url\` is a reserved prop in Next.js for legacy reasons and will be overridden on page ${pathname}\n` + `See more info here: https://nextjs.org/docs/messages/reserved-page-prop`);
}
// Avoid rendering page un-necessarily for getServerSideProps data request
// and getServerSideProps/getStaticProps redirects
if (isDataReq && !isSSG || renderOpts.isRedirect) {
return RenderResult.fromStatic(JSON.stringify(props1));
}
// We don't call getStaticProps or getServerSideProps while generating
// the fallback so make sure to set pageProps to an empty object
if (isFallback) {
props1.pageProps = {};
}
// the response might be finished on the getInitialProps call
if (isResSent(res) && !isSSG) return null;
// we preload the buildManifest for auto-export dynamic pages
// to speed up hydrating query values
let filteredBuildManifest = buildManifest;
if (isAutoExport && pageIsDynamic) {
const page = denormalizePagePath(normalizePagePath(pathname));
// This code would be much cleaner using `immer` and directly pushing into
// the result from `getPageFiles`, we could maybe consider that in the
// future.
if (page in filteredBuildManifest.pages) {
filteredBuildManifest = {
...filteredBuildManifest,
@ -488,7 +524,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
[page]: [
...filteredBuildManifest.pages[page],
...filteredBuildManifest.lowPriorityFiles.filter((f)=>f.includes("_buildManifest")
)
),
]
},
lowPriorityFiles: filteredBuildManifest.lowPriorityFiles.filter((f)=>!f.includes("_buildManifest")
@ -496,7 +532,19 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
};
}
}
const generateStaticHTML = supportsDynamicHTML !== true;
/**
* Rules of Static & Dynamic HTML:
*
* 1.) We must generate static HTML unless the caller explicitly opts
* in to dynamic HTML support.
*
* 2.) If dynamic HTML support is requested, we must honor that request
* or throw an error. It is the sole responsibility of the caller to
* ensure they aren't e.g. requesting dynamic HTML for an AMP page.
*
* These rules help ensure that other existing features like request caching,
* coalescing, and ISR continue working as intended.
*/ const generateStaticHTML = supportsDynamicHTML !== true;
const renderDocument = async ()=>{
if (Document.getInitialProps) {
const renderPage = (options = {})=>{
@ -526,6 +574,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
renderPage
};
const docProps = await loadGetInitialProps(Document, documentCtx);
// the response might be finished on the getInitialProps call
if (isResSent(res) && !isSSG) return null;
if (!docProps || typeof docProps.html !== "string") {
const message = `"${getDisplayName(Document)}.getInitialProps()" should resolve to an object with a "html" prop set with a valid html string`;
@ -577,7 +626,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
}
const hybridAmp = ampState.hybrid;
const docComponentsRendered = {};
const { assetPrefix , buildId , customServer , defaultLocale , disableOptimizedLoading , domainLocales , locale , locales , runtimeConfig } = renderOpts;
const { assetPrefix , buildId , customServer , defaultLocale , disableOptimizedLoading , domainLocales , locale , locales , runtimeConfig , } = renderOpts;
const htmlProps1 = {
__NEXT_DATA__: {
props: props1,
@ -612,6 +661,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
hybridAmp,
dynamicImports: Array.from(dynamicImports),
assetPrefix,
// Only enabled in production as development mode has features relying on HMR (style injection for example)
unstable_runtimeJS: process.env.NODE_ENV === "production" ? pageConfig.unstable_runtimeJS : undefined,
unstable_JsPreload: pageConfig.unstable_JsPreload,
devOnlyCacheBusterQueryString,
@ -663,8 +713,8 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
piperFromArray(prefix),
documentResult.bodyResult,
piperFromArray([
documentHTML.substring(renderTargetIdx + BODY_RENDER_TARGET.length)
])
documentHTML.substring(renderTargetIdx + BODY_RENDER_TARGET.length),
]),
];
const postProcessors = (generateStaticHTML ? [
inAmpMode ? async (html)=>{
@ -683,6 +733,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
});
} : null,
renderOpts.optimizeCss ? async (html)=>{
// eslint-disable-next-line import/no-extraneous-dependencies
const Critters = require("critters");
const cssOptimizer = new Critters({
ssrMode: true,
@ -697,7 +748,7 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
} : null,
inAmpMode || hybridAmp ? async (html)=>{
return html.replace(/&amp;amp=1/g, "&amp=1");
} : null
} : null,
] : []).filter(Boolean);
if (generateStaticHTML || postProcessors.length > 0) {
let html = await piperToString(chainPipers(pipers));
@ -732,6 +783,7 @@ function renderToStream(element, generateStaticHTML) {
return new Promise((resolve, reject)=>{
let underlyingStream = null;
const stream = new Writable({
// Use the buffer from the underlying stream
highWaterMark: 0,
write (chunk, encoding, callback) {
if (!underlyingStream) {
@ -757,6 +809,9 @@ function renderToStream(element, generateStaticHTML) {
}
underlyingStream.resolve(err);
});
// React uses `flush` to prevent stream middleware like gzip from buffering to the
// point of harming streaming performance, so we make sure to expose it and forward it.
// See: https://github.com/reactwg/react-18/discussions/91
Object.defineProperty(stream, "flush", {
value: ()=>{
if (!underlyingStream) {

View File

@ -1,5 +1,8 @@
if (exports) module.exports = null;
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (exports) // For Node.js.
module.exports = null;
else {
define, define.amd;
// For AMD. Register as an anonymous module.
define([], factory.bind(root, root));
}

View File

@ -22,7 +22,7 @@ var source;
var key;
const data = null;
export const version = process.env.__NEXT_VERSION;
const looseToArray = null, { props: hydrateProps , err: hydrateErr , page , query , buildId , assetPrefix , runtimeConfig , dynamicIds , isFallback , locale , locales , domainLocales , isPreview , rsc } = null;
const looseToArray = null, { props: hydrateProps , err: hydrateErr , page , query , buildId , assetPrefix , runtimeConfig , dynamicIds , isFallback , locale , locales , domainLocales , isPreview , rsc , } = null;
let { defaultLocale } = null;
const prefix = null;
setConfig(null);
@ -104,7 +104,7 @@ const wrapApp = ()=>{
let RSCComponent;
if (process.env.__NEXT_RSC) {
const rscCache = null, RSCWrapper = ()=>{
const { createFromFetch } = require("next/dist/compiled/react-server-dom-webpack");
const { createFromFetch , } = require("next/dist/compiled/react-server-dom-webpack");
let response;
(()=>{
const t = null;
@ -136,12 +136,10 @@ const elem = React.createElement(React.Fragment, null, React.createElement(null,
let referenceNode;
()=>{
const targetTag = null;
}, ()=>{
};
}, ()=>{};
}), React.createElement(null, null, React.createElement(null, null), React.createElement(Portal, "next-route-announcer", React.createElement(RouteAnnouncer, null))));
React.createElement(React.createElement(React.StrictMode, null, null));
React.useLayoutEffect(null, null), React.useEffect(()=>{
}, null), React.useEffect(()=>{
React.useLayoutEffect(null, null), React.useEffect(()=>{}, null), React.useEffect(()=>{
measureWebVitals(null);
}, null);
React.useLayoutEffect(null, null);

View File

@ -40,7 +40,7 @@ const data = null;
const version = null;
exports.version = null;
const looseToArray = null;
const { props: hydrateProps , err: hydrateErr , page , query , buildId , assetPrefix , runtimeConfig , dynamicIds , isFallback , locale , locales , domainLocales , isPreview , rsc } = null;
const { props: hydrateProps , err: hydrateErr , page , query , buildId , assetPrefix , runtimeConfig , dynamicIds , isFallback , locale , locales , domainLocales , isPreview , rsc , } = null;
let { defaultLocale } = null;
const prefix = null;
let asPath;
@ -51,6 +51,7 @@ if (process.env.__NEXT_I18N_SUPPORT) {
const { formatUrl } = require("../shared/lib/router/utils/format-url");
const parsedAs = null;
const localePathResult = null;
// attempt detecting default locale based on hostname
const detectedDomain = null;
}
const { initScriptLoader } = require("./script");
@ -84,11 +85,13 @@ let CachedComponent;
const { component: app , exports: mod } = null;
const exportedReportWebVitals = null;
()=>{
// Combines timestamp with random number for unique ID
const uniqueID = null;
let perfStartEntry;
const webVitals = null;
};
const pageEntrypoint = null;
const pageEntrypoint = // error, so we need to skip waiting for the entrypoint.
null;
if (process.env.NODE_ENV !== "production") {
const { isValidElementType } = require("react-is");
}
@ -109,10 +112,14 @@ const { App , err } = null;
(()=>{
import("../pages/_error")(null);
})(()=>{
// In production we do a normal render with the `ErrorComponent` as component.
// If we've gotten here upon initial render, we can use the props from the server.
// Otherwise, we need to call `getInitialProps` on `App` before mounting.
const AppTree = null;
const appCtx = null;
});
let reactRoot;
// On initial render a hydrate should always happen
let shouldHydrate;
const reactEl = null;
const navStartEntries = null;
@ -123,7 +130,7 @@ let RSCComponent;
if (process.env.__NEXT_RSC) {
const rscCache = null;
const RSCWrapper = ()=>{
const { createFromFetch } = require("next/dist/compiled/react-server-dom-webpack");
const { createFromFetch , } = require("next/dist/compiled/react-server-dom-webpack");
let response;
(()=>{
const t = null;
@ -160,8 +167,9 @@ const nonce = null;
const desiredHrefs = null;
const currentStyleTags1 = null;
const currentHrefs1 = null;
// Reorder styles into intended order:
let referenceNode;
()=>{
const targetTag = null;
};
const elem = null;
const elem = /*#__PURE__*/ null;

View File

@ -1,4 +1,9 @@
// shim for using process in browser
var process = module.exports = null;
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
var queue;
@ -14,7 +19,7 @@ process.title = null;
process.browser = null;
process.env = null;
process.argv = null;
process.version = null;
process.version = null; // empty string to avoid regexp issues
process.versions = null;
process.on = null;
process.addListener = null;

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,8 @@ if (process.env.NODE_ENV !== "production") {
var localDate;
var initialTime;
exports.unstable_now = null;
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
// fallback to a naive implementation.
var _callback;
var _timeoutID;
var _flushCallback = function() {
@ -19,21 +21,30 @@ if (process.env.NODE_ENV !== "production") {
};
exports.unstable_shouldYield = null;
exports.unstable_forceFrameRate = null;
// Capture local references to native APIs, in case a polyfill overrides them.
var _setTimeout;
var _clearTimeout;
// TODO: Scheduler no longer requires these methods to be polyfilled. But
// maybe we want to continue warning if they don't exist, to preserve the
// option to rely on it in the future?
var requestAnimationFrame;
var cancelAnimationFrame;
var isMessageLoopRunning;
var scheduledHostCallback;
var taskTimeoutID;
var taskTimeoutID; // Scheduler periodically yields in case there is other work on the main
// thread, like user events. By default, it yields multiple times per frame.
// It does not attempt to align with frame boundaries, since most tasks don't
// need to be frame aligned; for those that do, use requestAnimationFrame.
var yieldInterval;
var deadline;
var deadline; // TODO: Make this configurable
// `isInputPending` is not available. Since we have no way of knowing if
// there's pending input, always yield at the end of the frame.
exports.unstable_shouldYield = function() {
exports.unstable_now();
};
}; // Since we yield every frame regardless, `requestPaint` has no effect.
exports.unstable_forceFrameRate = null;
var performWorkUntilDeadline = function() {
var currentTime = exports.unstable_now();
var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
var hasTimeRemaining;
var hasMoreWork;
};
@ -56,27 +67,32 @@ if (process.env.NODE_ENV !== "production") {
var leftIndex;
var left;
var rightIndex;
var right;
var right; // If the left or right node is smaller, swap with the smaller of those.
// Compare sort index first, then task id.
var diff;
// TODO: Use symbols?
var ImmediatePriority;
var UserBlockingPriority;
var NormalPriority;
var LowPriority;
var IdlePriority;
var maxSigned31BitInt;
var IMMEDIATE_PRIORITY_TIMEOUT;
/* eslint-disable no-var */ // Math.pow(2, 30) - 1
// 0b111111111111111111111111111111
var maxSigned31BitInt; // Times out immediately
var IMMEDIATE_PRIORITY_TIMEOUT; // Eventually times out
var USER_BLOCKING_PRIORITY_TIMEOUT;
var NORMAL_PRIORITY_TIMEOUT;
var LOW_PRIORITY_TIMEOUT;
var IDLE_PRIORITY_TIMEOUT;
var LOW_PRIORITY_TIMEOUT; // Never times out
var IDLE_PRIORITY_TIMEOUT; // Tasks are stored on a min heap
var taskQueue;
var timerQueue;
var taskIdCounter;
var timerQueue; // Incrementing id counter. Used to maintain insertion order.
var taskIdCounter; // Pausing the scheduler is useful for debugging.
var currentTask;
var currentPriorityLevel;
var currentPriorityLevel; // This is set while performing work, to prevent re-entrancy.
var isPerformingWork;
var isHostCallbackScheduled;
var isHostTimeoutScheduled;
// Check for tasks that are no longer delayed and add them to the queue.
var timer;
var firstTimer;
var previousPriorityLevel;
@ -93,6 +109,7 @@ if (process.env.NODE_ENV !== "production") {
var previousPriorityLevel2;
var parentPriorityLevel;
(function() {
// This is a fork of runWithPriority, inlined for performance.
var previousPriorityLevel;
});
var currentTime2 = exports.unstable_now();

View File

@ -1,6 +1,12 @@
if (process.env.NODE_ENV !== "production") {
var _assign = require("object-assign");
// TODO: this is special because it gets imported during build.
var ReactVersion;
// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE;
var REACT_PORTAL_TYPE;
exports.Fragment = null;
@ -29,25 +35,39 @@ if (process.env.NODE_ENV !== "production") {
var MAYBE_ITERATOR_SYMBOL;
var FAUX_ITERATOR_SYMBOL;
var maybeIterator;
var ReactCurrentDispatcher;
var ReactCurrentBatchConfig;
var ReactCurrentOwner;
/**
* Keeps track of the current dispatcher.
*/ var ReactCurrentDispatcher;
/**
* Keeps track of the current batch's configuration such as how long an update
* should suspend for if it needs to.
*/ var ReactCurrentBatchConfig;
/**
* Keeps track of the current owner.
*
* The current owner is the component who should own any components that are
* currently being constructed.
*/ var ReactCurrentOwner;
var ReactDebugCurrentFrame;
var currentExtraStackFrame;
(function() {
var stack;
var stack; // Add an extra top frame while an element is being validated
var impl;
});
var IsSomeRendererActing;
/**
* Used by act() to track whether you're inside an act() scope.
*/ var IsSomeRendererActing;
var ReactSharedInternals;
var ReactDebugCurrentFrame1;
var stack;
var argsWithFormat;
var argsWithFormat; // Careful: RN currently depends on this prefix
var didWarnStateUpdateForUnmountedComponent;
var _constructor;
var componentName;
var warningKey;
var ReactNoopUpdateQueue;
/**
* This is the abstract API for an update queue.
*/ var ReactNoopUpdateQueue;
var emptyObject;
var deprecatedAPIs;
var defineDeprecationWarning;
@ -79,28 +99,51 @@ if (process.env.NODE_ENV !== "production") {
var warnAboutAccessingKey;
var warnAboutAccessingRef;
var componentName1;
var ReactElement = function() {
/**
* Factory method to create a new React element. This no longer adheres to
* the class pattern, so do not use new to call it. Also, instanceof check
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
* if something is a React Element.
*
* @param {*} type
* @param {*} props
* @param {*} key
* @param {string|object} ref
* @param {*} owner
* @param {*} self A *temporary* helper to detect places where `this` is
* different from the `owner` when React.createElement is called, so that we
* can warn. We want to get rid of owner and replace string `ref`s with arrow
* functions, and as long as `this` and owner are the same, there will be no
* change in behavior.
* @param {*} source An annotation object (added by a transpiler or otherwise)
* indicating filename, line number, and/or other information.
* @internal
*/ var ReactElement = function() {
var element;
};
var propName;
var propName; // Reserved names are extracted
var props;
var key;
var ref;
var self;
var source;
// the newly allocated props object.
var childrenLength;
var childArray;
var defaultProps;
var displayName;
var newElement;
var propName1;
var props1;
var propName1; // Original props are copied
var props1; // Reserved names are extracted
var key1;
var ref1;
var self1;
var source1;
var ref1; // Self is preserved since the owner is preserved.
var self1; // Source is preserved since cloneElement is unlikely to be targeted by a
// transpiler, and the original source is probably a better indicator of the
// true owner.
var source1; // Owner will be preserved, unless ref is overridden
var owner;
var defaultProps1;
// the newly allocated props object.
var childrenLength1;
var childArray1;
var SEPARATOR;
@ -108,17 +151,21 @@ if (process.env.NODE_ENV !== "production") {
var escapeRegex;
var escaperLookup;
var escapedString;
var didWarnAboutMaps;
/**
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/ var didWarnAboutMaps;
var userProvidedKeyEscapeRegex;
var type;
var invokeCallback;
var _child;
var mappedChild;
var mappedChild; // If it's the only child, treat the name as if it was wrapped in an array
// so that it's consistent if the number of children grows:
var childKey;
var escapedChildKey;
var child;
var nextName;
var subtreeCount;
var subtreeCount; // Count of children found in the current subtree.
var nextNamePrefix;
var iteratorFn;
var iterableChildren;
@ -133,33 +180,39 @@ if (process.env.NODE_ENV !== "production") {
var hasWarnedAboutUsingNestedContextConsumers;
var hasWarnedAboutUsingConsumerProvider;
var hasWarnedAboutDisplayNameOnConsumer;
var Consumer;
// A separate object, but proxies back to the original context object for
// backwards compatibility. It has a different $$typeof, so we can properly
// warn for the incorrect usage of Context as a Consumer.
var Consumer; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
var Uninitialized;
var Pending;
var Resolved;
var Rejected;
var ctor;
var thenable;
var thenable; // Transition to the next state.
var pending;
(function() {
var defaultExport;
var resolved;
}), function() {
// Transition to the next state.
var rejected;
};
var payload1;
var lazyType;
// In production, this would just set it on the object.
var defaultProps2;
var propTypes;
var propTypes; // $FlowFixMe
var elementType;
var ownName;
var enableScopeAPI;
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
var enableScopeAPI; // Experimental Create Event Handle API.
exports.Fragment, exports.Profiler, exports.StrictMode, exports.Suspense;
var elementType1;
var ownName1;
var dispatcher;
var dispatcher1;
var realContext;
var realContext; // Don't deduplicate because this legitimately causes bugs
var dispatcher2;
var dispatcher3;
var dispatcher4;
@ -169,6 +222,10 @@ if (process.env.NODE_ENV !== "production") {
var dispatcher8;
var dispatcher9;
var dispatcher10;
// Helpers to patch console.logs to avoid logging during side-effect free
// replaying on render function. This currently only patches the object
// lazily which won't cover if the log function was extracted eagerly.
// We could also eagerly patch the method.
var disabledDepth;
var prevLog;
var prevInfo;
@ -177,8 +234,8 @@ if (process.env.NODE_ENV !== "production") {
var prevGroup;
var prevGroupCollapsed;
var prevGroupEnd;
var props2;
var props3;
var props2; // $FlowFixMe Flow thinks console is immutable.
/* eslint-disable react-internal/no-production-logging */ var props3; // $FlowFixMe Flow thinks console is immutable.
var ReactCurrentDispatcher$1;
var prefix;
var match;
@ -187,13 +244,17 @@ if (process.env.NODE_ENV !== "production") {
var PossiblyWeakMap;
var frame;
var control;
var previousPrepareStackTrace;
var previousPrepareStackTrace; // $FlowFixMe It does accept undefined.
var previousDispatcher;
var Fake;
// Something should be setting the props in the constructor.
var Fake; // $FlowFixMe
// This extracts the first frame from the sample that isn't also in the control.
// Skipping one frame that we assume is the frame that calls the two.
var sampleLines;
var controlLines;
var s;
var c;
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
var _frame;
var name;
var syntheticFrame;
@ -211,9 +272,10 @@ if (process.env.NODE_ENV !== "production") {
var ReactDebugCurrentFrame$1;
var owner1;
var stack1;
// $FlowFixMe This is okay but Flow doesn't know it.
var has;
var typeSpecName;
var error$1;
var error$1; // Prop type validation may throw. In case they do, we don't want to
var err;
var owner2;
var stack2;
@ -221,10 +283,16 @@ if (process.env.NODE_ENV !== "production") {
var name1;
var fileName;
var lineNumber;
var ownerHasKeyUseWarning;
/**
* Warn if there's no key explicitly set on dynamic arrays of children or
* object keys are not valid. This allows us to keep track of children between
* updates.
*/ var ownerHasKeyUseWarning;
var info;
var parentName;
var currentComponentErrorInfo;
// property, it may be the creator of the child that's responsible for
// assigning it a key.
var childOwner;
var child1;
var iteratorFn1;
@ -232,15 +300,16 @@ if (process.env.NODE_ENV !== "production") {
var step1;
var type1;
var propTypes1;
// Intentionally inside to avoid triggering lazy initializers:
var name2;
var _name;
var keys;
var key2;
var validType;
var validType; // We warn in this case but don't throw. We expect the element creation to
var info1;
var sourceInfo;
var typeString;
var element;
var element; // The result can be nullish if a mock or a custom function is used.
exports.Fragment;
var didWarnAboutDeprecatedCreateFactory;
var validatedFactory;

View File

@ -1,8 +1,11 @@
if (process.env.NODE_ENV !== "production") {
var DEFAULT_THREAD_ID;
var DEFAULT_THREAD_ID; // Counters used to generate unique IDs.
var interactionIDCounter;
var threadIDCounter;
exports.__interactionsRef = null;
var threadIDCounter; // Set of currently traced interactions.
// Interactions "stack"
// Meaning that newly traced interactions are appended to the previously active set.
// When an interaction goes out of scope, the previous set (if any) is restored.
exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end.
exports.__subscriberRef = null;
exports.__interactionsRef = null;
exports.__subscriberRef = null;
@ -12,7 +15,9 @@ if (process.env.NODE_ENV !== "production") {
exports.__interactionsRef.current;
var threadID;
var interaction;
var prevInteractions1 = exports.__interactionsRef.current;
var prevInteractions1 = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.
// To do that, clone the current interactions.
// The previous set will be restored upon completion.
var interactions;
exports.__interactionsRef.current = null;
var subscriber = exports.__subscriberRef.current;

View File

@ -1,11 +1,17 @@
var runtime = function(exports) {
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ var runtime = function(exports) {
var Op;
var hasOwn;
var undefined;
var undefined; // More compressible than void 0.
var $Symbol;
var iteratorSymbol;
var asyncIteratorSymbol;
var toStringTagSymbol;
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator;
var generator;
var context;
@ -14,7 +20,11 @@ var runtime = function(exports) {
var GenStateSuspendedYield;
var GenStateExecuting;
var GenStateCompleted;
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel;
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype;
var getProto;
var NativeIteratorPrototype;
@ -23,12 +33,19 @@ var runtime = function(exports) {
var ctor;
};
exports.mark = null;
// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
exports.awrap = null;
var record;
var result;
var value;
var previousPromise;
exports.AsyncIterator = null;
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
exports.async = function() {
var iter;
exports.isGeneratorFunction(null);
@ -62,4 +79,8 @@ var runtime = function(exports) {
var thrown;
};
exports;
}((module, module.exports));
}(// If this script is executing as a CommonJS module, use module.exports
// as the regeneratorRuntime namespace. Otherwise create a new empty
// object. Either way, the resulting object will be used to initialize
// the regeneratorRuntime variable at the top of this file.
(module, module.exports));

View File

@ -1,4 +1,5 @@
export function foo() {
const meta = null;
// const { event, team, user } = this.props;
const b = null;
}