Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/codegen): Emit leading comments for ExprStmt #7916

Merged
merged 5 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Shard extends _utils.Emitter {
} else if (emit) {
this.emit(_utils.ShardEvent.DESTROYED);
}
// (Step 3) Make the websocket connection prop undefined.
_class_private_field_set._(this, _ws1, undefined);
// (Step 4) Set the shard status to disconnected.
this.status = _utils.Status.DISCONNECTED;
Expand All @@ -138,6 +139,7 @@ class Shard extends _utils.Emitter {
_class_private_field_set._(this, _seq, -1);
this.session.reset();
}
// (Step 7) Reset ze bucket!
_class_private_field_set._(this, _bucket, new _utils.Bucket(120, 6e4));
}
connect() {
Expand Down Expand Up @@ -406,6 +408,7 @@ class Shard extends _utils.Emitter {
* Guilds that are expected to be received.
* @type {Set<string>}
*/ this.expectedGuilds = new Set();
// Private shit
_class_private_field_set._(this, _seq, -1);
_class_private_field_set._(this, _closingSeq, 0);
_class_private_field_set._(this, _queue, []);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export var webpackJsonpCallback = function(parentChunkLoadingFunction, data) {
/******/ var runtime = data[2];
//......
runtime && runtime(__webpack_require__);
// return result
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/************************************************************************/ /******/ /******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = {
/***/ 746: /***/ function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__1) {
// originally from react
Object.prototype.hasOwnProperty;
// END MY ACTUAL CODE
/***/ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ function _simulateTransaction() {
// @ts-ignore
transaction.recentBlockhash = _state.sent();
signData = transaction.serializeMessage();
// @ts-ignore
wireTransaction = transaction._serialize(signData);
encodedTransaction = wireTransaction.toString("base64");
config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ var Router = /*#__PURE__*/ function() {
if (!_this.urlIsNew(cleanedAs) && !localeChange) {
method = "replaceState";
}
// we need to resolve the as value using rewrites for dynamic SSG
// pages to allow building the data URL correctly
resolvedAs = as;
// url and as should always be prefixed with basePath by this
// point by either next/link or router.push/replace so strip the
Expand Down Expand Up @@ -315,6 +317,7 @@ var Router = /*#__PURE__*/ function() {
// when updating query information
props.pageProps.statusCode = 500;
}
// shallow routing is only allowed for same page URL changes.
isValidShallowRoute = options.shallow && _this.route === route;
shouldScroll = (_options_scroll = options.scroll) !== null && _options_scroll !== void 0 ? _options_scroll : !isValidShallowRoute;
resetScroll = shouldScroll ? {
Expand Down
7 changes: 6 additions & 1 deletion crates/swc/tests/fixture/sourcemap/006/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ it("should compress avif smaller than webp and smaller than jpg", /*#__PURE__*/
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
query = {
/**
*
* 'Foo bar baz'
*
* Return @
*/ query = {
url: "/test.jpg",
w: w,
q: 75
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/006/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": ";;AAAAA,GAAG,6EAA+D,oBAAA;QAOxDC,OACAC,MAQAC,MAQAC,MAQAC,MACAC,MACAC;;;;gBA3BAN,QAAQ;oBAAEO,KAAK;oBAAaC,GAAAA;oBAAGC,GAAG;gBAAG;gBAC9B;;oBAAMC,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBA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QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBAKba,OAAOb,KAAKc,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOb,KAAKW,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMX,OAAO;gBAKbY,OAAOZ,KAAKa,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOZ,KAAKU,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMV,OAAO;gBAKbW,OAAOX,KAAKY,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOX,KAAKS,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEhC;;oBAAMf,KAAKiB,MAAM;;;gBAAzBd,OAAO,AAAC,cAAqBe,UAAU;gBAC/B;;oBAAMjB,KAAKgB,MAAM;;;gBAAzBb,OAAO,AAAC,cAAqBc,UAAU;gBAC/B;;oBAAMhB,KAAKe,MAAM;;;gBAAzBZ,OAAO,AAAC,cAAqBa,UAAU;gBAE7CC,QAAQC,GAAG,CAAC;oBAAEC,SAAAA;oBAASd,GAAAA;oBAAGJ,MAAAA;oBAAMC,MAAAA;oBAAMC,MAAAA;gBAAK;gBAE3CQ,OAAOT,MAAMkB,YAAY,CAACjB;gBAC1BQ,OAAOV,MAAMmB,YAAY,CAAClB;;;;;;AAC9B",
"names": [
"it",
"query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ var B = /*#__PURE__*/ function(A) {
_superprop_get_y().call(_this1);
// call with element access
_superprop_get("x").call(_this1);
// property access (read)
a = _superprop_get_x();
// element access (read)
b = _superprop_get("x");
return [
2
Expand Down Expand Up @@ -89,7 +91,9 @@ var B = /*#__PURE__*/ function(A) {
_superprop_get_x().call(_this1);
// call with element access
_superprop_get("x").call(_this1);
// property access (read)
a = _superprop_get_x();
// element access (read)
b = _superprop_get("x");
// property access (assign)
_superprop_set_x(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ var Conestoga = /*#__PURE__*/ function(Wagon1) {
function Conestoga(drunkOO) {
_class_call_check(this, Conestoga);
var _this;
// error: wrong type
_this = _super.call(this, "nope");
_this.drunkOO = drunkOO;
return _this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
cache.mobile = cache.phone = phone, cache.tablet = null;
return; // unambiguously identified as phone
}
// our rules haven't found a match -> try more general fallback rules
impl.isMobileFallback(userAgent) ? undefined === (phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth)) ? (cache.mobile = impl.FALLBACK_MOBILE, cache.tablet = cache.phone = null) : phoneSized ? (cache.mobile = cache.phone = impl.FALLBACK_PHONE, cache.tablet = null) : (cache.mobile = cache.tablet = impl.FALLBACK_TABLET, cache.phone = null) : impl.isTabletFallback(userAgent) ? (cache.mobile = cache.tablet = impl.FALLBACK_TABLET, cache.phone = null) : // not mobile at all!
cache.mobile = cache.tablet = cache.phone = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @param {Second} s
* @param {Fs} f
*/ export function consume(t, s, f) {
Target.START;
/** @type {Target} */ Target.START;
}
/** @param {string} s */ export function ff(s) {
return(// element access with arbitrary string is an error only with noImplicitAny
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TypeScript1 = TypeScript || (TypeScript = {}), preFindEnclosingScope = function(
}, context.scopeStartAST = ast, context.enclosingClassDecl = ast;
break;
case NodeType.ObjectLit:
// Only consider target-typed object literals
ast.targetType && (context.scopeGetter = function() {
return ast.targetType.containedScope;
}, context.objectLiteralScopeGetter = function() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ Formatting1 = Formatting || (Formatting = {}), Indenter = function() {
}
// The parent node to take its indentation is the first parent that has indentation.
for(; null != parent && !parent.CanIndent();)parent = parent.Parent;
// Skip Program since it has no indentation
null != parent && parent.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkProg && (offset = parent.AuthorNode.Details.StartOffset, indentNode = parent);
} else {
indentNode = tree.StartNodeSelf, offset = tree.StartNodePreviousSibling.Details.StartOffset;
Expand All @@ -289,6 +290,7 @@ Formatting1 = Formatting || (Formatting = {}), Indenter = function() {
}
if (null != indentNode) {
var indentOverride = this.GetLineIndentationForOffset(offset);
// Set the indentation on all the siblings to be the same as indentNode
this.smartIndent || null === tree.StartNodePreviousSibling || null == indentNode.Parent || ParseNodeExtensions.GetChildren(indentNode.Parent).foreach(function(sibling) {
sibling !== indentNode && sibling.CanIndent() && sibling.SetIndentationOverride(indentOverride);
});
Expand Down
2 changes: 2 additions & 0 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,8 @@ where
#[emitter]
#[tracing::instrument(skip_all)]
fn emit_expr_stmt(&mut self, e: &ExprStmt) -> Result {
self.emit_leading_comments_of_span(e.span, false)?;

emit!(e.expr);

semi!();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4569,6 +4569,7 @@ var load228 = __swcpack_require__.bind(void 0, function(module, exports) {
var $DataView = global[DATA_VIEW];
var Math1 = global.Math;
var RangeError1 = global.RangeError;
// eslint-disable-next-line no-shadow-restricted-names
global.Infinity;
var BaseBuffer = $ArrayBuffer;
var abs = Math1.abs;
Expand Down
Loading