Skip to content
Closed
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
5 changes: 5 additions & 0 deletions packages/qwik/src/optimizer/core/src/inlined_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use swc_ecmascript::ast;
use swc_ecmascript::codegen::text_writer::JsWriter;
use swc_ecmascript::transforms::fixer;
use swc_ecmascript::transforms::hygiene::hygiene_with_config;
use swc_ecmascript::transforms::optimization;
use swc_ecmascript::visit::{Visit, VisitWith};
use swc_ecmascript::{
utils::private_ident,
Expand Down Expand Up @@ -199,6 +200,10 @@ pub fn render_expr(expr: &ast::Expr) -> String {
};
expr.visit_mut_with(&mut hygiene_with_config(Default::default()));
expr.visit_mut_with(&mut fixer(None));
expr.visit_mut_with(&mut optimization::simplify::dce::dce(
Default::default(),
Default::default(),
));
emitter
.emit_module(&ast::Module {
span: DUMMY_SP,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: packages/qwik/src/optimizer/core/src/test.rs
assertion_line: 821
assertion_line: 822
expression: output
snapshot_kind: text
---
==INPUT==

Expand Down Expand Up @@ -39,9 +38,9 @@ export default component$(() => {
============================= test.js ==

import { serverQrl } from "@qwik.dev/router";
import { qrlDEV } from "@qwik.dev/core";
import { _noopQrlDEV } from "@qwik.dev/core";
import { componentQrl } from "@qwik.dev/core";
import { qrlDEV } from "@qwik.dev/core";
const i_LUXeXe0DQrg = ()=>import("./test.tsx_test_component_LUXeXe0DQrg");
import { sideEffect } from './secret';
(function() {
Expand Down Expand Up @@ -93,6 +92,34 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
]
}
*/
============================= test.tsx_api_server_JonPp043gH0.js (ENTRY POINT)==

export const api_server_JonPp043gH0 = ()=>{
supabase.from('ffg').do(dfd);
};


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"sCAoB2B;IAC1B,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;AACzB\"}")
/*
{
"origin": "test.tsx",
"name": "api_server_JonPp043gH0",
"entry": null,
"displayName": "test.tsx_api_server",
"hash": "JonPp043gH0",
"canonicalFilename": "test.tsx_api_server_JonPp043gH0",
"path": "",
"extension": "js",
"parent": null,
"ctxKind": "function",
"ctxName": "server$",
"captures": false,
"loc": [
433,
473
]
}
*/
============================= test.tsx_test_component_LUXeXe0DQrg.js (ENTRY POINT)==

import { _jsxSorted } from "@qwik.dev/core";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: packages/qwik/src/optimizer/core/src/test.rs
assertion_line: 3814
assertion_line: 3816
expression: output
snapshot_kind: text
---
==INPUT==

Expand Down Expand Up @@ -45,6 +44,39 @@ export const App = /*#__PURE__*/ componentQrl(/*#__PURE__*/ qrlDEV(i_ckEPmXZlub0


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;AAGA,OAAO,MAAM,oBAAM;;;;;IAoBhB\"}")
============================= test.tsx_App_component_Cmp_p_shouldRemove_uU0MG0jvQD4.js (ENTRY POINT)==

import { useLexicalScope } from "@qwik.dev/core";
export const App_component_Cmp_p_shouldRemove_uU0MG0jvQD4 = ()=>{
const [stuff] = useLexicalScope();
return stuff.count;
};


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";4DAgBmB;;WAAM,MAAM,KAAK\"}")
/*
{
"origin": "test.tsx",
"name": "App_component_Cmp_p_shouldRemove_uU0MG0jvQD4",
"entry": null,
"displayName": "test.tsx_App_component_Cmp_p_shouldRemove",
"hash": "uU0MG0jvQD4",
"canonicalFilename": "test.tsx_App_component_Cmp_p_shouldRemove_uU0MG0jvQD4",
"path": "",
"extension": "js",
"parent": "App_component_ckEPmXZlub0",
"ctxKind": "eventHandler",
"ctxName": "shouldRemove$",
"captures": true,
"loc": [
350,
367
],
"captureNames": [
"stuff"
]
}
*/
============================= test.tsx_App_component_ckEPmXZlub0.js (ENTRY POINT)==

import { _jsxSorted } from "@qwik.dev/core";
Expand Down Expand Up @@ -116,6 +148,66 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
]
}
*/
============================= test.tsx_App_component_serverStuff_ebyHaP15ytQ.js (ENTRY POINT)==

import { useLexicalScope } from "@qwik.dev/core";
export const App_component_serverStuff_ebyHaP15ytQ = async ()=>{
const [stuff] = useLexicalScope();
// should be removed but keep scope
console.log(stuff.count);
};


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";qDAKc;;IACZ,mCAAmC;IACnC,QAAQ,GAAG,CAAC,MAAM,KAAK\"}")
/*
{
"origin": "test.tsx",
"name": "App_component_serverStuff_ebyHaP15ytQ",
"entry": null,
"displayName": "test.tsx_App_component_serverStuff",
"hash": "ebyHaP15ytQ",
"canonicalFilename": "test.tsx_App_component_serverStuff_ebyHaP15ytQ",
"path": "",
"extension": "js",
"parent": "App_component_ckEPmXZlub0",
"ctxKind": "function",
"ctxName": "serverStuff$",
"captures": true,
"loc": [
154,
235
],
"captureNames": [
"stuff"
]
}
*/
============================= test.tsx_App_component_Cmp_p_onClick_vuXzfUTkpto.js (ENTRY POINT)==

export const App_component_Cmp_p_onClick_vuXzfUTkpto = ()=>console.log('warn');


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"uDAiBc,IAAM,QAAQ,GAAG,CAAC\"}")
/*
{
"origin": "test.tsx",
"name": "App_component_Cmp_p_onClick_vuXzfUTkpto",
"entry": null,
"displayName": "test.tsx_App_component_Cmp_p_onClick",
"hash": "vuXzfUTkpto",
"canonicalFilename": "test.tsx_App_component_Cmp_p_onClick_vuXzfUTkpto",
"path": "",
"extension": "js",
"parent": "App_component_ckEPmXZlub0",
"ctxKind": "eventHandler",
"ctxName": "onClick$",
"captures": false,
"loc": [
383,
408
]
}
*/
== DIAGNOSTICS ==

[]
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: packages/qwik/src/optimizer/core/src/test.rs
assertion_line: 865
assertion_line: 866
expression: output
snapshot_kind: text
---
==INPUT==

Expand All @@ -13,7 +12,7 @@ export const Works = component$((props) => {
const text = 'hola';
return (
<>
<div onClick$={server$(() => console.log('in server', text))}></div>
<div onClick$={() => server$(() => console.log('in server', text))}></div>
<div onClick$={() => foo()}></div>
</>
);
Expand All @@ -23,25 +22,23 @@ export const Works = component$((props) => {

import "./foo";
import { componentQrl } from "@qwik.dev/core";
import { serverQrl } from "@qwik.dev/core";
import { _regSymbol } from "@qwik.dev/core";
import { inlinedQrl } from "@qwik.dev/core";
import { _jsxSorted } from "@qwik.dev/core";
import { _noopQrl } from "@qwik.dev/core";
import { _jsxSorted } from "@qwik.dev/core";
import { Fragment as _Fragment } from "@qwik.dev/core/jsx-runtime";
export const Works = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props)=>{
return /*#__PURE__*/ _jsxSorted(_Fragment, null, null, [
/*#__PURE__*/ _jsxSorted("div", {
onClick$: serverQrl(/*#__PURE__*/ inlinedQrl(/*#__PURE__*/ _regSymbol(()=>console.log('in server', 'hola'), "gcSPFNpGYgg"), "Works_component_Fragment_div_onClick_server_gcSPFNpGYgg"))
}, null, null, 2, null),
/*#__PURE__*/ _jsxSorted("div", null, {
onClick$: /*#__PURE__*/ _noopQrl("Works_component_Fragment_div_onClick_nO4DPVZWP7g")
}, null, 3, null),
/*#__PURE__*/ _jsxSorted("div", null, {
onClick$: /*#__PURE__*/ _noopQrl("Works_component_Fragment_div_onClick_1_GlJs0t0HdXk")
}, null, 3, null)
], 1, "u6_0");
], 3, "u6_0");
}, "Works_component_t45qL4vNGv0"));


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;AAGA,OAAO,MAAM,sBAAQ,sCAAW,CAAC;IAEhC,qBACC;sBACA,WAAC;YAAI,UAAU,4DAAQ,IAAM,QAAQ,GAAG,CAAC,aAH7B;;sBAIZ,WAAC;YAAI,QAAQ;;;AAGf,mCAAG\"}")
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;;AAGA,OAAO,MAAM,sBAAQ,sCAAW,CAAC;IAEhC,qBACC;sBACA,WAAC;YAAI,QAAQ;;sBACb,WAAC;YAAI,QAAQ;;;AAGf,mCAAG\"}")
== DIAGNOSTICS ==

[]
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: packages/qwik/src/optimizer/core/src/test.rs
assertion_line: 1929
assertion_line: 1930
expression: output
snapshot_kind: text
---
==INPUT==

Expand All @@ -28,6 +27,7 @@ export const Parent = component$(() => {

useTask$(() => {
// Code
runSomething();
});

return (
Expand All @@ -50,11 +50,11 @@ import "./keep";
import "../keep2";
import { componentQrl } from "@qwik.dev/core";
import { useClientMountQrl } from "@qwik.dev/core";
import { useLexicalScope } from "@qwik.dev/core";
import { inlinedQrl } from "@qwik.dev/core";
import { _noopQrl } from "@qwik.dev/core";
import { useTaskQrl } from "@qwik.dev/core";
import { inlinedQrl } from "@qwik.dev/core";
import { _wrapProp } from "@qwik.dev/core";
import { useLexicalScope } from "@qwik.dev/core";
import { _jsxSorted } from "@qwik.dev/core";
import { useStore } from '@qwik.dev/core';
export const Parent = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(()=>{
Expand All @@ -66,7 +66,8 @@ export const Parent = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(()=>{
state
]));
useTaskQrl(/*#__PURE__*/ inlinedQrl(()=>{
// Code
// Code
runSomething();
}, "Parent_component_useTask_ngmvcygWux8"));
return /*#__PURE__*/ _jsxSorted("div", null, {
shouldRemove$: /*#__PURE__*/ _noopQrl("Parent_component_div_shouldRemove_EBj69wTX1do", [
Expand All @@ -90,7 +91,7 @@ export const Parent = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(()=>{
}, "Parent_component_t6Wy3C0Q0XM"));


Some("{\"version\":3,\"sources\":[\"/user/qwik/src/components/component.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;;;AACA,SAAsC,QAAQ,QAAkB,iBAAiB;AAQjF,OAAO,MAAM,uBAAS,sCAAW;IAChC,MAAM,QAAQ,SAAS;QACtB,MAAM;IACP;IAEA,qBAAqB;IACrB;;;IAKA,oCAAS;IACR,OAAO;IACR;IAEA,qBACC,WAAC;QACA,aAAa;;;QACb,QAAQ;;;;sBAER,WAAC;YACA,QAAQ,2BAAE,IAAM,QAAQ,GAAG,CAAC;YAC5B,OAAO,2BAAE;;uBAAM,MAAM,IAAI;;;;;kBAEzB;;AAGJ,oCAAG\"}")
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/components/component.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;;;AACA,SAAsC,QAAQ,QAAkB,iBAAiB;AAQjF,OAAO,MAAM,uBAAS,sCAAW;IAChC,MAAM,QAAQ,SAAS;QACtB,MAAM;IACP;IAEA,qBAAqB;IACrB;;;IAKA,oCAAS;QACR,OAAO;QACP;IACD;IAEA,qBACC,WAAC;QACA,aAAa;;;QACb,QAAQ;;;;sBAER,WAAC;YACA,QAAQ,2BAAE,IAAM,QAAQ,GAAG,CAAC;YAC5B,OAAO,2BAAE;;uBAAM,MAAM,IAAI;;;;;kBAEzB;;AAGJ,oCAAG\"}")
== DIAGNOSTICS ==

[]
Loading
Loading