fix(es): Fix codegen & minifier (#2006)

swc_ecma_codegen:
 - Emit a semicolon before `!`.
 - Emit a semicolon before `[`. (#2007)

swc_ecma_minifier:
 - Disable buggy passes.
 - `iife`: Don't inline async functions. (#2007)
This commit is contained in:
강동윤 2021-08-04 19:27:17 +09:00 committed by GitHub
parent 68608db0b3
commit 48bc26d3c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 3288 additions and 3093 deletions

6
Cargo.lock generated
View File

@ -2427,7 +2427,7 @@ dependencies = [
[[package]]
name = "swc_ecma_codegen"
version = "0.66.0"
version = "0.66.1"
dependencies = [
"bitflags",
"num-bigint",
@ -2497,7 +2497,7 @@ dependencies = [
[[package]]
name = "swc_ecma_minifier"
version = "0.18.0"
version = "0.18.1"
dependencies = [
"ansi_term 0.12.1",
"anyhow",
@ -3192,7 +3192,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm"
version = "1.2.73"
version = "1.2.74"
dependencies = [
"console_error_panic_hook",
"once_cell",

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.66.0"
version = "0.66.1"
[dependencies]
bitflags = "1"

View File

@ -60,7 +60,7 @@ impl<W: WriteJs> WriteJs for OmitTrailingSemi<W> {
self.commit_pending_semi()?;
}
"/" | "{" | "(" => {
"[" | "!" | "/" | "{" | "(" => {
self.commit_pending_semi()?;
}

View File

@ -0,0 +1,2 @@
var foo;
!foo

View File

@ -0,0 +1,2 @@
var foo;
!foo;

View File

@ -0,0 +1 @@
var foo;!foo

View File

@ -0,0 +1,2 @@
foo()
!unary

View File

@ -0,0 +1,2 @@
foo();
!unary;

View File

@ -0,0 +1 @@
foo();!unary

View File

@ -0,0 +1,7 @@
"use strict";
const a = {};
for (let b in a)
a[b] = a[b].trim();
["foo",].forEach(() => { })

View File

@ -0,0 +1,8 @@
"use strict";
const a = {
};
for(let b in a)a[b] = a[b].trim();
[
"foo",
].forEach(()=>{
});

View File

@ -0,0 +1 @@
"use strict";const a={};for(let b in a)a[b]=a[b].trim();["foo",].forEach(()=>{})

View File

@ -1,10 +1,10 @@
use super::Optimizer;
use crate::compress::optimize::bools::negate_cost;
use crate::compress::optimize::Ctx;
use crate::compress::optimize::DISABLE_BUGGY_PASSES;
use crate::debug::dump;
use crate::util::make_bool;
use crate::util::SpanExt;
use crate::DISABLE_BUGGY_PASSES;
use std::mem::swap;
use swc_common::EqIgnoreSpan;
use swc_common::Spanned;

View File

@ -1,6 +1,6 @@
use super::Optimizer;
use super::DISABLE_BUGGY_PASSES;
use crate::compress::optimize::is_pure_undefined_or_null;
use crate::DISABLE_BUGGY_PASSES;
use std::f64;
use std::num::FpCategory;
use swc_atoms::js_word;

View File

@ -2,6 +2,7 @@ use super::Optimizer;
use crate::{
compress::optimize::util::is_directive,
util::{sort::is_sorted_by, MoudleItemExt},
DISABLE_BUGGY_PASSES,
};
use std::cmp::Ordering;
use swc_ecma_ast::*;
@ -28,6 +29,9 @@ impl Optimizer<'_> {
if !self.options.join_vars {
return;
}
if DISABLE_BUGGY_PASSES {
return;
}
// Sort by position

View File

@ -313,6 +313,16 @@ impl Optimizer<'_> {
match callee {
Expr::Arrow(f) => {
if f.is_async {
log::trace!("iife: [x] Cannot inline async fn");
return;
}
if f.is_generator {
log::trace!("iife: [x] Cannot inline generator");
return;
}
if self.ctx.in_top_level() && !self.ctx.in_call_arg && self.options.negate_iife {
match &f.body {
BlockStmtOrExpr::BlockStmt(body) => {
@ -431,6 +441,11 @@ impl Optimizer<'_> {
}
}
if f.function.is_async {
log::trace!("iife: [x] Cannot inline async fn");
return;
}
if f.function.is_generator {
log::trace!("iife: [x] Cannot inline generator");
return;

View File

@ -64,8 +64,6 @@ mod unsafes;
mod unused;
mod util;
const DISABLE_BUGGY_PASSES: bool = true;
#[derive(Debug, Default)]
pub(super) struct OptimizerState {
vars_for_inlining: FxHashMap<Id, Box<Expr>>,

View File

@ -47,6 +47,8 @@ mod pass;
pub mod timing;
mod util;
const DISABLE_BUGGY_PASSES: bool = true;
#[inline]
pub fn optimize(
mut m: Module,

View File

@ -1,4 +1,4 @@
use crate::option::CompressOptions;
use crate::{option::CompressOptions, DISABLE_BUGGY_PASSES};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
@ -16,6 +16,10 @@ impl PostcompressOptimizer<'_> {
if !self.options.bools {
return;
}
// This is buggy
if DISABLE_BUGGY_PASSES {
return;
}
// Note: `||` is not handled because of precedence.
match e {

View File

@ -1,6 +1,6 @@
import { m } from "../index.f66dda46.js";
const value$1 = "it works", value = "it works";
function AliasOutside() {
return m`<div><p>Inside: ${value}</p><p>Outside: ${value$1}</p></div>`;
}
const value$1 = "it works", value = "it works";
export default AliasOutside;

View File

@ -1,6 +1,6 @@
import { m } from "../index.f66dda46.js";
const jpg = "/assets/img.2dae108d.jpg";
function Files() {
return m`<div style="padding: 2rem;"><h1>Files</h1><p> jpg: ${jpg}<br/><img src=${jpg} alt="" height="320"/></p></div>`;
}
const jpg = "/assets/img.2dae108d.jpg";
export default Files;

View File

@ -1,9 +1,4 @@
import { s as style, m } from "../index.f66dda46.js";
function Environment() {
return m`<table><thead><tr><th>Name ${foo}</th><th>Value</th></tr></thead><tbody>${Object.keys(process.env).sort().map((key)=>{
return m`<tr key=${key}><td>${key}</td><td>${String(process.env[key])}</td></tr>`;
})}</tbody></table>`;
}
const process = {
browser: !0,
env: {
@ -14,4 +9,9 @@ const process = {
NODE_ENV: "production"
}
}, foo = 42;
function Environment() {
return m`<table><thead><tr><th>Name ${foo}</th><th>Value</th></tr></thead><tbody>${Object.keys(process.env).sort().map((key)=>{
return m`<tr key=${key}><td>${key}</td><td>${String(process.env[key])}</td></tr>`;
})}</tbody></table>`;
}
export { Environment };

View File

@ -1,11 +1,11 @@
import { s as style, y, m } from "../index.f66dda46.js";
const styles = {
about: "about_migxty"
};
function About({ query , title , }) {
return y(()=>(console.log("Mounted About: ", title), ()=>{
console.log("Unmounting About: ", title);
})
, []), m`<section class=${styles.about}><h1>${title || "About"}</h1><p>My name is Jason.</p><pre>${JSON.stringify(query)}</pre></section>`;
}
const styles = {
about: "about_migxty"
};
export default About;

View File

@ -1,4 +1,8 @@
import { a as l, y, m } from "../index.f66dda46.js";
const json = {
foo: 42,
bar: "bar"
};
function JSONView() {
const [fetched, setFetched, ] = l(null);
return y(()=>{
@ -7,8 +11,4 @@ function JSONView() {
);
}, []), m`<div><p>import: ${JSON.stringify(json)}</p><p>fetch: ${JSON.stringify(fetched)}</p></div>`;
}
const json = {
foo: 42,
bar: "bar"
};
export { JSONView };

View File

@ -0,0 +1,7 @@
const obj = {}
for (let key in obj) {
obj[key] = obj[key].trim();
}
let arr = ["foo",]
arr.forEach(() => { })

View File

@ -0,0 +1,8 @@
const obj = {
};
for(let key in obj)obj[key] = obj[key].trim();
let arr = [
"foo",
];
arr.forEach(()=>{
});

View File

@ -0,0 +1,8 @@
function func() {
(async () => {
await this.foo();
this.bar();
})()
}
func()

View File

@ -0,0 +1,6 @@
function func() {
(async ()=>{
await this.foo(), this.bar();
})();
}
func();

File diff suppressed because it is too large Load Diff

View File

@ -641,7 +641,7 @@
this.root = ("/" + this.root + "/").replace(rootStripper, "/"), oldIE && this._wantsHashChange && (this.iframe = Backbone.$("<iframe src=\"javascript:0\" tabindex=\"-1\" />").hide().appendTo("body")[0].contentWindow, this.navigate(fragment)), this._hasPushState ? Backbone.$(window).on("popstate", this.checkUrl) : this._wantsHashChange && "onhashchange" in window && !oldIE ? Backbone.$(window).on("hashchange", this.checkUrl) : this._wantsHashChange && (this._checkUrlInterval = setInterval(this.checkUrl, this.interval)), this.fragment = fragment;
var loc = this.location, atRoot = loc.pathname.replace(/[^\/]$/, "$&/") === this.root;
if (this._wantsHashChange && this._wantsPushState) {
if (!this._hasPushState || atRoot) return this.fragment = this.getFragment(null, !0), this.location.replace(this.root + this.location.search + "#" + this.fragment), !0;
if (!this._hasPushState && !atRoot) return this.fragment = this.getFragment(null, !0), this.location.replace(this.root + this.location.search + "#" + this.fragment), !0;
this._hasPushState && atRoot && loc.hash && (this.fragment = this.getHash().replace(routeStripper, ""), this.history.replaceState({
}, document.title, this.root + this.fragment + loc.search));
}

File diff suppressed because it is too large Load Diff

View File

@ -1648,7 +1648,7 @@
document.activeElement && "body" !== document.activeElement.nodeName.toLowerCase() ? $17(document.activeElement).blur() : $17("input:focus, textarea:focus, select:focus").blur();
} catch (e) {
}
alreadyThere = !1, isDialog && active && (active.url && active.url.indexOf($17.mobile.dialogHashKey) > -1 && this.activePage && !this.activePage.hasClass("ui-dialog") && $17.mobile.navigate.history.activeIndex > 0 && (settings.changeHash = !1, alreadyThere = !0), url = active.url || "", !alreadyThere && url.indexOf("#") > -1 ? url += $17.mobile.dialogHashKey : url += "#" + $17.mobile.dialogHashKey, 0 === $17.mobile.navigate.history.activeIndex && url === $17.mobile.navigate.history.initialDst && (url += $17.mobile.dialogHashKey)), (newPageTitle = active ? toPage.jqmData("title") || toPage.children(":jqmData(role='header')").find(".ui-title").text() : pageTitle) && pageTitle === document.title && (pageTitle = newPageTitle), toPage.jqmData("title") || toPage.jqmData("title", pageTitle), settings.transition = settings.transition || (historyDir || activeIsInitialPage ? active.transition : undefined) || (isDialog ? $17.mobile.defaultDialogTransition : $17.mobile.defaultPageTransition), !historyDir && alreadyThere && ($17.mobile.navigate.history.getActive().pageUrl = pageUrl), url && !settings.fromHashChange && (!$17.mobile.path.isPath(url) && 0 > url.indexOf("#") && (url = "#" + url), params = {
alreadyThere = !1, isDialog && active && (active.url && active.url.indexOf($17.mobile.dialogHashKey) > -1 && this.activePage && !this.activePage.hasClass("ui-dialog") && $17.mobile.navigate.history.activeIndex > 0 && (settings.changeHash = !1, alreadyThere = !0), url = active.url || "", !alreadyThere && url.indexOf("#") > -1 ? url += $17.mobile.dialogHashKey : url += "#" + $17.mobile.dialogHashKey, 0 === $17.mobile.navigate.history.activeIndex && url === $17.mobile.navigate.history.initialDst && (url += $17.mobile.dialogHashKey)), (newPageTitle = active ? toPage.jqmData("title") || toPage.children(":jqmData(role='header')").find(".ui-title").text() : pageTitle) && pageTitle === document.title && (pageTitle = newPageTitle), toPage.jqmData("title") || toPage.jqmData("title", pageTitle), settings.transition = settings.transition || (historyDir && !activeIsInitialPage ? active.transition : undefined) || (isDialog ? $17.mobile.defaultDialogTransition : $17.mobile.defaultPageTransition), !historyDir && alreadyThere && ($17.mobile.navigate.history.getActive().pageUrl = pageUrl), url && !settings.fromHashChange && (!$17.mobile.path.isPath(url) && 0 > url.indexOf("#") && (url = "#" + url), params = {
transition: settings.transition,
title: pageTitle,
pageUrl: pageUrl,
@ -1829,7 +1829,7 @@
},
transition: function() {
var none, reverseClass = this.reverse ? " reverse" : "", screenHeight = $17.mobile.getScreenHeight(), maxTransitionOverride = !1 !== $17.mobile.maxTransitionWidth && $17.mobile.window.width() > $17.mobile.maxTransitionWidth;
return this.toScroll = $17.mobile.navigate.history.getActive().lastScroll || $17.mobile.defaultHomeScroll, none = !$17.support.cssTransitions || !$17.support.cssAnimations || maxTransitionOverride || !this.name || "none" === this.name || Math.max($17.mobile.window.scrollTop(), this.toScroll) > $17.mobile.getMaxScrollForTransition(), this.toggleViewportClass(), this.$from || none ? this.startOut(screenHeight, reverseClass, none) : this.doneOut(screenHeight, reverseClass, none, !0), this.deferred.promise();
return this.toScroll = $17.mobile.navigate.history.getActive().lastScroll || $17.mobile.defaultHomeScroll, none = !$17.support.cssTransitions || !$17.support.cssAnimations || maxTransitionOverride || !this.name || "none" === this.name || Math.max($17.mobile.window.scrollTop(), this.toScroll) > $17.mobile.getMaxScrollForTransition(), this.toggleViewportClass(), this.$from && !none ? this.startOut(screenHeight, reverseClass, none) : this.doneOut(screenHeight, reverseClass, none, !0), this.deferred.promise();
}
});
})(jQuery, this), (function($17) {
@ -4756,11 +4756,12 @@
}
});
})(jQuery), (function($17, window) {
$17.mobile.iosorientationfixEnabled = !0;
var zoom, evt, x, y, z, aig, ua = navigator.userAgent;
if (!(/iPhone|iPad|iPod/.test(navigator.platform) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf("AppleWebKit") > -1)) return void ($17.mobile.iosorientationfixEnabled = !1);
function checkTilt(e) {
x = Math.abs((aig = (evt = e.originalEvent).accelerationIncludingGravity).x), y = Math.abs(aig.y), z = Math.abs(aig.z), !window.orientation && (x > 7 || (z > 6 && y < 8 || z < 8 && y > 6) && x > 5) ? zoom.enabled && zoom.disable() : zoom.enabled || zoom.enable();
}
if ($17.mobile.iosorientationfixEnabled = !0, !(/iPhone|iPad|iPod/.test(navigator.platform) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf("AppleWebKit") > -1)) return void ($17.mobile.iosorientationfixEnabled = !1);
zoom = $17.mobile.zoom, $17.mobile.document.on("mobileinit", function() {
$17.mobile.iosorientationfixEnabled && $17.mobile.window.bind("orientationchange.iosorientationfix", zoom.enable).bind("devicemotion.iosorientationfix", checkTilt);
});

View File

@ -1308,7 +1308,7 @@ Event1.Keys = {
var nativeRootContains = root && this.isNativeCode(root.contains), nativeDocumentContains = document && this.isNativeCode(document.contains);
for(feature in features.contains = nativeRootContains && nativeDocumentContains ? function(context, node) {
return context.contains(node);
} : nativeRootContains || nativeDocumentContains ? function(context, node) {
} : nativeRootContains && !nativeDocumentContains ? function(context, node) {
return context === node || (context === document ? document.documentElement : context).contains(node);
} : root && root.compareDocumentPosition ? function(context, node) {
return context === node || !!(16 & context.compareDocumentPosition(node));

View File

@ -5,7 +5,16 @@
});
}(this, function(exports) {
"use strict";
var REACT_ELEMENT_TYPE = 60103, REACT_PORTAL_TYPE = 60106, REACT_PROVIDER_TYPE = 60109, REACT_CONTEXT_TYPE = 60110, REACT_FORWARD_REF_TYPE = 60112, REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, REACT_BLOCK_TYPE = 60121, REACT_SERVER_BLOCK_TYPE = 60122, REACT_FUNDAMENTAL_TYPE = 60117, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_LEGACY_HIDDEN_TYPE = 60131, MAYBE_ITERATOR_SYMBOL = "function" == typeof Symbol && Symbol.iterator;
var REACT_ELEMENT_TYPE = 60103, REACT_PORTAL_TYPE = 60106;
exports.Fragment = 60107, exports.StrictMode = 60108, exports.Profiler = 60114;
var REACT_PROVIDER_TYPE = 60109, REACT_CONTEXT_TYPE = 60110, REACT_FORWARD_REF_TYPE = 60112;
exports.Suspense = 60113;
var REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, REACT_BLOCK_TYPE = 60121, REACT_SERVER_BLOCK_TYPE = 60122, REACT_FUNDAMENTAL_TYPE = 60117, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_LEGACY_HIDDEN_TYPE = 60131;
if ("function" == typeof Symbol && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor("react.element"), REACT_PORTAL_TYPE = symbolFor("react.portal"), exports.Fragment = symbolFor("react.fragment"), exports.StrictMode = symbolFor("react.strict_mode"), exports.Profiler = symbolFor("react.profiler"), REACT_PROVIDER_TYPE = symbolFor("react.provider"), REACT_CONTEXT_TYPE = symbolFor("react.context"), REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"), exports.Suspense = symbolFor("react.suspense"), REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"), REACT_MEMO_TYPE = symbolFor("react.memo"), REACT_LAZY_TYPE = symbolFor("react.lazy"), REACT_BLOCK_TYPE = symbolFor("react.block"), REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"), REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"), symbolFor("react.scope"), symbolFor("react.opaque.id"), REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"), symbolFor("react.offscreen"), REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
}
var MAYBE_ITERATOR_SYMBOL = "function" == typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" != typeof maybeIterable) return null;
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
@ -31,6 +40,14 @@
function setExtraStackFrame(stack) {
currentExtraStackFrame = stack;
}
ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
currentExtraStackFrame = stack;
}, ReactDebugCurrentFrame.getCurrentStack = null, ReactDebugCurrentFrame.getStackAddendum = function() {
var stack = "";
currentExtraStackFrame && (stack += currentExtraStackFrame);
var impl = ReactDebugCurrentFrame.getCurrentStack;
return impl && (stack += impl() || ""), stack;
};
var IsSomeRendererActing = {
current: !1
}, ReactSharedInternals = {
@ -58,6 +75,7 @@
});
argsWithFormat.unshift("Warning: " + format), Function.prototype.apply.call(console[level], console, argsWithFormat);
}
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
var didWarnStateUpdateForUnmountedComponent = {
};
function warnNoop(publicInstance, callerName) {
@ -82,6 +100,13 @@
function Component(props, context, updater) {
this.props = props, this.context = context, this.refs = emptyObject, this.updater = updater || ReactNoopUpdateQueue;
}
Object.freeze(emptyObject), Component.prototype.isReactComponent = {
}, Component.prototype.setState = function(partialState, callback) {
if (!("object" == typeof partialState || "function" == typeof partialState || null == partialState)) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
this.updater.enqueueSetState(this, partialState, callback, "setState");
}, Component.prototype.forceUpdate = function(callback) {
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
};
var deprecatedAPIs = {
isMounted: [
"isMounted",
@ -92,11 +117,19 @@
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
]
};
for(var fnName in deprecatedAPIs)deprecatedAPIs.hasOwnProperty(fnName) && (function(methodName, info) {
Object.defineProperty(Component.prototype, fnName, {
get: function() {
warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
}
});
})(fnName, deprecatedAPIs[fnName]);
function ComponentDummy() {
}
function PureComponent(props, context, updater) {
this.props = props, this.context = context, this.refs = emptyObject, this.updater = updater || ReactNoopUpdateQueue;
}
ComponentDummy.prototype = Component.prototype;
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
function getWrappedName(outerType, innerType, wrapperName) {
var functionName = innerType.displayName || innerType.name || "";
@ -144,6 +177,7 @@
}
return null;
}
pureComponentPrototype.constructor = PureComponent, assign(pureComponentPrototype, Component.prototype), pureComponentPrototype.isPureReactComponent = !0;
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs, hasOwnProperty$1 = Object.prototype.hasOwnProperty, RESERVED_PROPS = {
key: !0,
ref: !0,
@ -188,6 +222,8 @@
didWarnAboutStringRefs[componentName] || (error("Component \"%s\" contains the string ref \"%s\". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref", componentName, config.ref), didWarnAboutStringRefs[componentName] = !0);
}
}
didWarnAboutStringRefs = {
};
var ReactElement = function(type, key, ref, self, source, owner, props) {
var element = {
$$typeof: REACT_ELEMENT_TYPE,
@ -412,6 +448,7 @@
}
disabledDepth < 0 && error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
disabledLog.__reactDisabledLog = !0;
var prefix, ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
function describeBuiltInComponentFrame(name, source, ownerFn) {
if (void 0 === prefix) try {
@ -513,6 +550,7 @@
}
return "";
}
componentFrameCache = new ("function" == typeof WeakMap ? WeakMap : Map)();
var loggedTypeFailures = {
}, ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
function setCurrentlyValidatingElement(element) {
@ -556,6 +594,7 @@
function getSourceInfoErrorAddendumForProps(elementProps) {
return null != elementProps ? getSourceInfoErrorAddendum(elementProps.__source) : "";
}
propTypesMisspellWarningShown = !1;
var ownerHasKeyUseWarning = {
};
function getCurrentComponentErrorInfo(parentType) {
@ -629,6 +668,72 @@
return type === exports.Fragment ? validateFragmentProps(element) : validatePropTypes(element), element;
}
var propTypesMisspellWarningShown, requestHostCallback, requestHostTimeout, cancelHostTimeout, shouldYieldToHost, requestPaint, getCurrentTime, forceFrameRate, didWarnAboutDeprecatedCreateFactory = !1, enableSchedulerDebugging = !1, enableProfiling = !1;
if ("object" == typeof performance && "function" == typeof performance.now) {
var localPerformance = performance;
getCurrentTime = function() {
return localPerformance.now();
};
} else {
var localDate = Date, initialTime = localDate.now();
getCurrentTime = function() {
return localDate.now() - initialTime;
};
}
if ("undefined" == typeof window || "function" != typeof MessageChannel) {
var _callback = null, _timeoutID = null, _flushCallback = function() {
if (null !== _callback) try {
var currentTime = getCurrentTime(), hasRemainingTime = !0;
_callback(hasRemainingTime, currentTime), _callback = null;
} catch (e) {
throw setTimeout(_flushCallback, 0), e;
}
};
requestHostCallback = function(cb) {
null !== _callback ? setTimeout(requestHostCallback, 0, cb) : (_callback = cb, setTimeout(_flushCallback, 0));
}, requestHostTimeout = function(cb, ms) {
_timeoutID = setTimeout(cb, ms);
}, cancelHostTimeout = function() {
clearTimeout(_timeoutID);
}, shouldYieldToHost = function() {
return !1;
}, requestPaint = forceFrameRate = function() {
};
} else {
var _setTimeout = window.setTimeout, _clearTimeout = window.clearTimeout;
if ("undefined" != typeof console) {
var requestAnimationFrame = window.requestAnimationFrame, cancelAnimationFrame = window.cancelAnimationFrame;
"function" != typeof requestAnimationFrame && console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"), "function" != typeof cancelAnimationFrame && console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
}
var isMessageLoopRunning = !1, scheduledHostCallback = null, taskTimeoutID = -1, yieldInterval = 5, deadline = 0;
shouldYieldToHost = function() {
return getCurrentTime() >= deadline;
}, requestPaint = function() {
}, forceFrameRate = function(fps) {
if (fps < 0 || fps > 125) return void console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported");
yieldInterval = fps > 0 ? Math.floor(1000 / fps) : 5;
};
var performWorkUntilDeadline = function() {
if (null !== scheduledHostCallback) {
var currentTime = getCurrentTime();
deadline = currentTime + yieldInterval;
var hasTimeRemaining = !0;
try {
scheduledHostCallback(hasTimeRemaining, currentTime) ? port.postMessage(null) : (isMessageLoopRunning = !1, scheduledHostCallback = null);
} catch (error) {
throw port.postMessage(null), error;
}
} else isMessageLoopRunning = !1;
}, channel = new MessageChannel(), port = channel.port2;
channel.port1.onmessage = performWorkUntilDeadline, requestHostCallback = function(callback) {
scheduledHostCallback = callback, isMessageLoopRunning || (isMessageLoopRunning = !0, port.postMessage(null));
}, requestHostTimeout = function(callback, ms) {
taskTimeoutID = _setTimeout(function() {
callback(getCurrentTime());
}, ms);
}, cancelHostTimeout = function() {
_clearTimeout(taskTimeoutID), taskTimeoutID = -1;
};
}
function push(heap, node) {
var index = heap.length;
heap.push(node), siftUp(heap, node, index);
@ -724,7 +829,7 @@
unstable_NormalPriority: 3,
unstable_IdlePriority: 5,
unstable_LowPriority: 4,
unstable_runWithPriority: function unstable_runWithPriority(priorityLevel, eventHandler) {
unstable_runWithPriority: function(priorityLevel, eventHandler) {
switch(priorityLevel){
case 1:
case 2:
@ -743,7 +848,7 @@
currentPriorityLevel = previousPriorityLevel;
}
},
unstable_next: function unstable_next(eventHandler) {
unstable_next: function(eventHandler) {
var priorityLevel;
switch(currentPriorityLevel){
case 1:
@ -763,7 +868,7 @@
currentPriorityLevel = previousPriorityLevel;
}
},
unstable_scheduleCallback: function unstable_scheduleCallback(priorityLevel, callback, options) {
unstable_scheduleCallback: function(priorityLevel, callback, options) {
var timeout, startTime, currentTime = getCurrentTime();
if ("object" == typeof options && null !== options) {
var delay = options.delay;
@ -797,10 +902,10 @@
};
return startTime > currentTime ? (newTask.sortIndex = startTime, push(timerQueue, newTask), null === peek(taskQueue) && newTask === peek(timerQueue) && (isHostTimeoutScheduled ? cancelHostTimeout() : isHostTimeoutScheduled = !0, requestHostTimeout(handleTimeout, startTime - currentTime))) : (newTask.sortIndex = expirationTime, push(taskQueue, newTask), isHostCallbackScheduled || isPerformingWork || (isHostCallbackScheduled = !0, requestHostCallback(flushWork))), newTask;
},
unstable_cancelCallback: function unstable_cancelCallback(task) {
unstable_cancelCallback: function(task) {
task.callback = null;
},
unstable_wrapCallback: function unstable_wrapCallback(callback) {
unstable_wrapCallback: function(callback) {
var parentPriorityLevel = currentPriorityLevel;
return function() {
var previousPriorityLevel = currentPriorityLevel;
@ -812,19 +917,19 @@
}
};
},
unstable_getCurrentPriorityLevel: function unstable_getCurrentPriorityLevel() {
unstable_getCurrentPriorityLevel: function() {
return currentPriorityLevel;
},
get unstable_shouldYield () {
return shouldYieldToHost;
},
unstable_requestPaint: requestPaint,
unstable_continueExecution: function unstable_continueExecution() {
unstable_continueExecution: function() {
isHostCallbackScheduled || isPerformingWork || (isHostCallbackScheduled = !0, requestHostCallback(flushWork));
},
unstable_pauseExecution: function unstable_pauseExecution() {
unstable_pauseExecution: function() {
},
unstable_getFirstCallbackNode: function unstable_getFirstCallbackNode() {
unstable_getFirstCallbackNode: function() {
return peek(taskQueue);
},
get unstable_now () {
@ -834,7 +939,13 @@
return forceFrameRate;
},
unstable_Profiling: null
}), interactionIDCounter = 0, threadIDCounter = 0, interactionsRef = null, subscriberRef = null, subscribers = null;
}), interactionIDCounter = 0, threadIDCounter = 0, interactionsRef = null, subscriberRef = null;
interactionsRef = {
current: new Set()
}, subscriberRef = {
current: null
};
var subscribers = null;
function onInteractionTraced(interaction) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
@ -895,6 +1006,7 @@
}
}), didCatchError) throw caughtError;
}
subscribers = new Set();
var ReactSharedInternals$1 = {
ReactCurrentDispatcher: ReactCurrentDispatcher,
ReactCurrentOwner: ReactCurrentOwner,
@ -910,7 +1022,7 @@
get __subscriberRef () {
return subscriberRef;
},
unstable_clear: function unstable_clear(callback) {
unstable_clear: function(callback) {
var prevInteractions = interactionsRef.current;
interactionsRef.current = new Set();
try {
@ -919,13 +1031,13 @@
interactionsRef.current = prevInteractions;
}
},
unstable_getCurrent: function unstable_getCurrent() {
unstable_getCurrent: function() {
return interactionsRef.current;
},
unstable_getThreadID: function unstable_getThreadID() {
unstable_getThreadID: function() {
return ++threadIDCounter;
},
unstable_trace: function unstable_trace(name, timestamp, callback) {
unstable_trace: function(name, timestamp, callback) {
var threadID = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 0, interaction = {
__count: 1,
id: interactionIDCounter++,
@ -954,7 +1066,7 @@
}
return returnValue;
},
unstable_wrap: function unstable_wrap(callback) {
unstable_wrap: function(callback) {
var threadID = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, wrappedInteractions = interactionsRef.current, subscriber = subscriberRef.current;
null !== subscriber && subscriber.onWorkScheduled(wrappedInteractions, threadID), wrappedInteractions.forEach(function(interaction) {
interaction.__count++;
@ -991,7 +1103,7 @@
}
}, wrapped;
},
unstable_subscribe: function unstable_subscribe(subscriber) {
unstable_subscribe: function(subscriber) {
subscribers.add(subscriber), 1 === subscribers.size && (subscriberRef.current = {
onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
onInteractionTraced: onInteractionTraced,
@ -1001,107 +1113,12 @@
onWorkStopped: onWorkStopped
});
},
unstable_unsubscribe: function unstable_unsubscribe(subscriber) {
unstable_unsubscribe: function(subscriber) {
subscribers.delete(subscriber), 0 === subscribers.size && (subscriberRef.current = null);
}
})
};
if (exports.Fragment = 60107, exports.StrictMode = 60108, exports.Profiler = 60114, exports.Suspense = 60113, "function" == typeof Symbol && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor("react.element"), REACT_PORTAL_TYPE = symbolFor("react.portal"), exports.Fragment = symbolFor("react.fragment"), exports.StrictMode = symbolFor("react.strict_mode"), exports.Profiler = symbolFor("react.profiler"), REACT_PROVIDER_TYPE = symbolFor("react.provider"), REACT_CONTEXT_TYPE = symbolFor("react.context"), REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"), exports.Suspense = symbolFor("react.suspense"), REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"), REACT_MEMO_TYPE = symbolFor("react.memo"), REACT_LAZY_TYPE = symbolFor("react.lazy"), REACT_BLOCK_TYPE = symbolFor("react.block"), REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"), REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"), symbolFor("react.scope"), symbolFor("react.opaque.id"), REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"), symbolFor("react.offscreen"), REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
}
for(var fnName in ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
currentExtraStackFrame = stack;
}, ReactDebugCurrentFrame.getCurrentStack = null, ReactDebugCurrentFrame.getStackAddendum = function() {
var stack = "";
currentExtraStackFrame && (stack += currentExtraStackFrame);
var impl = ReactDebugCurrentFrame.getCurrentStack;
return impl && (stack += impl() || ""), stack;
}, ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame, Object.freeze(emptyObject), Component.prototype.isReactComponent = {
}, Component.prototype.setState = function(partialState, callback) {
if (!("object" == typeof partialState || "function" == typeof partialState || null == partialState)) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
this.updater.enqueueSetState(this, partialState, callback, "setState");
}, Component.prototype.forceUpdate = function(callback) {
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
}, deprecatedAPIs)deprecatedAPIs.hasOwnProperty(fnName) && (function(methodName, info) {
Object.defineProperty(Component.prototype, fnName, {
get: function() {
warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
}
});
})(fnName, deprecatedAPIs[fnName]);
if (ComponentDummy.prototype = Component.prototype, pureComponentPrototype.constructor = PureComponent, assign(pureComponentPrototype, Component.prototype), pureComponentPrototype.isPureReactComponent = !0, didWarnAboutStringRefs = {
}, disabledLog.__reactDisabledLog = !0, componentFrameCache = new ("function" == typeof WeakMap ? WeakMap : Map)(), propTypesMisspellWarningShown = !1, "object" == typeof performance && "function" == typeof performance.now) {
var localPerformance = performance;
getCurrentTime = function() {
return localPerformance.now();
};
} else {
var localDate = Date, initialTime = localDate.now();
getCurrentTime = function() {
return localDate.now() - initialTime;
};
}
if ("undefined" == typeof window || "function" != typeof MessageChannel) {
var _callback = null, _timeoutID = null, _flushCallback = function() {
if (null !== _callback) try {
var currentTime = getCurrentTime(), hasRemainingTime = !0;
_callback(hasRemainingTime, currentTime), _callback = null;
} catch (e) {
throw setTimeout(_flushCallback, 0), e;
}
};
requestHostCallback = function(cb) {
null !== _callback ? setTimeout(requestHostCallback, 0, cb) : (_callback = cb, setTimeout(_flushCallback, 0));
}, requestHostTimeout = function(cb, ms) {
_timeoutID = setTimeout(cb, ms);
}, cancelHostTimeout = function() {
clearTimeout(_timeoutID);
}, shouldYieldToHost = function() {
return !1;
}, requestPaint = forceFrameRate = function() {
};
} else {
var _setTimeout = window.setTimeout, _clearTimeout = window.clearTimeout;
if ("undefined" != typeof console) {
var requestAnimationFrame = window.requestAnimationFrame, cancelAnimationFrame = window.cancelAnimationFrame;
"function" != typeof requestAnimationFrame && console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"), "function" != typeof cancelAnimationFrame && console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
}
var isMessageLoopRunning = !1, scheduledHostCallback = null, taskTimeoutID = -1, yieldInterval = 5, deadline = 0;
shouldYieldToHost = function() {
return getCurrentTime() >= deadline;
}, requestPaint = function() {
}, forceFrameRate = function(fps) {
if (fps < 0 || fps > 125) return void console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported");
yieldInterval = fps > 0 ? Math.floor(1000 / fps) : 5;
};
var performWorkUntilDeadline = function() {
if (null !== scheduledHostCallback) {
var hasMoreWork, currentTime = getCurrentTime();
deadline = currentTime + yieldInterval;
var hasTimeRemaining = !0;
try {
scheduledHostCallback(hasTimeRemaining, currentTime) ? port.postMessage(null) : (isMessageLoopRunning = !1, scheduledHostCallback = null);
} catch (error) {
throw port.postMessage(null), error;
}
} else isMessageLoopRunning = !1;
}, channel = new MessageChannel(), port = channel.port2;
channel.port1.onmessage = performWorkUntilDeadline, requestHostCallback = function(callback) {
scheduledHostCallback = callback, isMessageLoopRunning || (isMessageLoopRunning = !0, port.postMessage(null));
}, requestHostTimeout = function(callback, ms) {
taskTimeoutID = _setTimeout(function() {
callback(getCurrentTime());
}, ms);
}, cancelHostTimeout = function() {
_clearTimeout(taskTimeoutID), taskTimeoutID = -1;
};
}
interactionsRef = {
current: new Set()
}, subscriberRef = {
current: null
}, subscribers = new Set(), ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
try {
var frozenObject = Object.freeze({
});

File diff suppressed because it is too large Load Diff

View File

@ -320,43 +320,7 @@ var YUI = function() {
"[object Array]": "array",
"[object Date]": "date",
"[object Error]": "error"
}, SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g, TRIM_LEFT_REGEX = new RegExp("^[\t-\r \xa0 -\u2028\u2029 ]+"), TRIM_RIGHT_REGEX = new RegExp("[\t-\r \xa0 -\u2028\u2029 ]+$"), TRIMREGEX = new RegExp(TRIM_LEFT_REGEX.source + "|" + TRIM_RIGHT_REGEX.source, "g"), NATIVE_FN_REGEX = /\{\s*\[(?:native code|function)\]\s*\}/i, Lang = Y.Lang, Native = Array.prototype, hasOwn = Object.prototype.hasOwnProperty;
function YArray(thing, startIndex, force) {
var len, result;
if (startIndex || (startIndex = 0), force || YArray.test(thing)) try {
return Native.slice.call(thing, startIndex);
} catch (ex) {
for(result = [], len = thing.length; startIndex < len; ++startIndex)result.push(thing[startIndex]);
return result;
}
return [
thing
];
}
function Queue() {
this._init(), this.add.apply(this, arguments);
}
var UNDEFINED, hasOwn = Object.prototype.hasOwnProperty, isObject = Y.Lang.isObject, Lang = Y.Lang, hasOwn = Object.prototype.hasOwnProperty, O = Y.Object = Lang._isNative(Object.create) ? function(obj) {
return Object.create(obj);
} : function() {
function F() {
}
return function(obj) {
return F.prototype = obj, new F();
};
}(), forceEnum = O._forceEnum = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toString",
"toLocaleString",
"valueOf"
], hasEnumBug = O._hasEnumBug = !({
valueOf: 0
}).propertyIsEnumerable("valueOf"), hasProtoEnumBug = O._hasProtoEnumBug = (function() {
}).propertyIsEnumerable("prototype"), owns = O.owns = function(obj, key) {
return !!obj && hasOwn.call(obj, key);
};
}, SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g, TRIM_LEFT_REGEX = new RegExp("^[\t-\r \xa0 -\u2028\u2029 ]+"), TRIM_RIGHT_REGEX = new RegExp("[\t-\r \xa0 -\u2028\u2029 ]+$"), TRIMREGEX = new RegExp(TRIM_LEFT_REGEX.source + "|" + TRIM_RIGHT_REGEX.source, "g"), NATIVE_FN_REGEX = /\{\s*\[(?:native code|function)\]\s*\}/i;
L._isNative = function(fn) {
return !!(Y.config.useNativeES5 && fn && NATIVE_FN_REGEX.test(fn));
}, L.isArray = L._isNative(Array.isArray) ? Array.isArray : function(o) {
@ -413,7 +377,24 @@ var YUI = function() {
return s.replace(TRIM_RIGHT_REGEX, "");
}, L.type = function(o) {
return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? "object" : "null");
}, Y.Array = YArray, YArray.dedupe = Lang._isNative(Object.create) ? function(array) {
};
var Lang = Y.Lang, Native = Array.prototype, hasOwn = Object.prototype.hasOwnProperty;
function YArray(thing, startIndex, force) {
var len, result;
if (startIndex || (startIndex = 0), force || YArray.test(thing)) try {
return Native.slice.call(thing, startIndex);
} catch (ex) {
for(result = [], len = thing.length; startIndex < len; ++startIndex)result.push(thing[startIndex]);
return result;
}
return [
thing
];
}
function Queue() {
this._init(), this.add.apply(this, arguments);
}
Y.Array = YArray, YArray.dedupe = Lang._isNative(Object.create) ? function(array) {
var i, item, len, hash = Object.create(null), results = [];
for(i = 0, len = array.length; i < len; ++i)hash[item = array[i]] || (hash[item] = 1, results.push(item));
return results;
@ -469,7 +450,9 @@ var YUI = function() {
size: function() {
return this._q.length;
}
}, Y.Queue = Queue, YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue(), Y.cached = function(source, cache, refetch) {
}, Y.Queue = Queue, YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue();
var hasOwn = Object.prototype.hasOwnProperty, isObject = Y.Lang.isObject;
Y.cached = function(source, cache, refetch) {
return cache || (cache = {
}), function(arg) {
var key = arguments.length > 1 ? Array.prototype.join.call(arguments, "__") : String(arg);
@ -494,7 +477,29 @@ var YUI = function() {
Y.Object._hasEnumBug && Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge);
}
return receiver;
}, O.hasKey = owns, O.keys = Lang._isNative(Object.keys) || hasProtoEnumBug ? Object.keys : function(obj) {
};
var UNDEFINED, Lang = Y.Lang, hasOwn = Object.prototype.hasOwnProperty, O = Y.Object = Lang._isNative(Object.create) ? function(obj) {
return Object.create(obj);
} : function() {
function F() {
}
return function(obj) {
return F.prototype = obj, new F();
};
}(), forceEnum = O._forceEnum = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toString",
"toLocaleString",
"valueOf"
], hasEnumBug = O._hasEnumBug = !({
valueOf: 0
}).propertyIsEnumerable("valueOf"), hasProtoEnumBug = O._hasProtoEnumBug = (function() {
}).propertyIsEnumerable("prototype"), owns = O.owns = function(obj, key) {
return !!obj && hasOwn.call(obj, key);
};
O.hasKey = owns, O.keys = Lang._isNative(Object.keys) && !hasProtoEnumBug ? Object.keys : function(obj) {
if (!Lang.isObject(obj)) throw new TypeError("Object.keys called on a non-object");
var i, key, len, keys = [];
if (hasProtoEnumBug && "function" == typeof obj) for(key in obj)owns(obj, key) && "prototype" !== key && keys.push(key);

View File

@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.73",
"version": "1.2.74",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",

View File

@ -622,6 +622,7 @@ impl Compiler {
decorators_before_export: true,
top_level_await: true,
import_assertions: true,
dynamic_import: true,
..Default::default()
}),

View File

@ -6,7 +6,7 @@ license = "Apache-2.0 AND MIT"
name = "wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.2.73"
version = "1.2.74"
[lib]
crate-type = ["cdylib"]