Skip to content

Commit

Permalink
chore: update esbuild tests related to jsx.factory (rolldown#2965)
Browse files Browse the repository at this point in the history
<!-- Thank you for contributing! -->

### Description

<!-- Please insert your description here and provide especially info
about the "what" this PR is solving -->
  • Loading branch information
IWANABETHATGUY authored Nov 28, 2024
1 parent 5e571e4 commit 8ee2182
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"name": "app",
"import": "app.jsx"
}
]
],
"jsx": {
"pragma": "h",
"runtime": "classic"
}
},
"expectExecuted": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,25 @@ snapshot_kind: text
│ ╰───── Module not found, treating it as an external dependency
───╯
```
## UNRESOLVED_IMPORT

```text
[UNRESOLVED_IMPORT] Warning: Could not resolve 'react/jsx-runtime' in app.jsx
```
## UNRESOLVED_IMPORT

```text
[UNRESOLVED_IMPORT] Warning: Could not resolve 'react/jsx-runtime' in in2.jsx
```
# Assets

## app.js

```js
import { render } from "preact";
import { jsx as _jsx, jsx as _jsx$1, jsxs as _jsxs } from "react/jsx-runtime";
import { h, render } from "preact";
//#region import.js
const p = "p";
//#endregion
//#region in2.jsx
const Internal = () => _jsx$1(p, { children: " Test 2 " });
const Internal = () => h(p, null, " Test 2 ");
//#endregion
//#region app.jsx
const App = () => _jsxs(p, { children: [
" ",
_jsx(Internal, {}),
" T "
] });
render(_jsx(App, {}), document.getElementById("app"));
const App = () => h(p, null, " ", h(Internal, null), " T ");
render(h(App, null), document.getElementById("app"));
//#endregion
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
"resolver": {
"/out.js": "app.js"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"name": "fragment",
"import": "fragment.jsx"
}
]
],
"jsx": {
"pragma": "import.meta",
"pragmaFrag": "import.meta",
"runtime": "classic"
}
},
"expectExecuted": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,27 @@
source: crates/rolldown_testing/src/integration_test.rs
snapshot_kind: text
---
# warnings

## UNRESOLVED_IMPORT

```text
[UNRESOLVED_IMPORT] Warning: Could not resolve 'react/jsx-runtime' in factory.jsx
```
## UNRESOLVED_IMPORT

```text
[UNRESOLVED_IMPORT] Warning: Could not resolve 'react/jsx-runtime' in fragment.jsx
```
# Assets

## factory.js

```js
import { jsx as _jsx } from "react/jsx-runtime";
//#region factory.jsx
console.log([_jsx("x", {}), /* @__PURE__ */ import.meta("x", null)]);
console.log([import.meta("x", null), /* @__PURE__ */ import.meta("x", null)]);
f = function() {
console.log([_jsx("y", {}), /* @__PURE__ */ import.meta("y", null)]);
console.log([import.meta("y", null), /* @__PURE__ */ import.meta("y", null)]);
};
//#endregion
```
## fragment.js

```js
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
//#region fragment.jsx
console.log([_jsx(_Fragment, { children: "x" }), /* @__PURE__ */ import.meta(import.meta, null, "x")]), f = function() {
console.log([_jsx(_Fragment, { children: "y" }), /* @__PURE__ */ import.meta(import.meta, null, "y")]);
console.log([import.meta(import.meta, null, "x"), /* @__PURE__ */ import.meta(import.meta, null, "x")]), f = function() {
console.log([import.meta(import.meta, null, "y"), /* @__PURE__ */ import.meta(import.meta, null, "y")]);
};
//#endregion
Expand Down
30 changes: 11 additions & 19 deletions crates/rolldown/tests/esbuild/default/jsx_import_meta_value/diff.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reason
1. `jsx.factory`
1. esbuild will auto polyfill `import.meta`
# Diff
## /out/factory.js
### esbuild
Expand All @@ -19,12 +19,11 @@ f = function() {
```
### rolldown
```js
import { jsx as _jsx } from "react/jsx-runtime";

//#region factory.jsx
console.log([_jsx("x", {}), /* @__PURE__ */ import.meta("x", null)]);
console.log([import.meta("x", null), /* @__PURE__ */ import.meta("x", null)]);
f = function() {
console.log([_jsx("y", {}), /* @__PURE__ */ import.meta("y", null)]);
console.log([import.meta("y", null), /* @__PURE__ */ import.meta("y", null)]);
};

//#endregion
Expand All @@ -34,14 +33,13 @@ f = function() {
===================================================================
--- esbuild /out/factory.js
+++ rolldown factory.js
@@ -1,5 +1,5 @@
@@ -1,5 +1,4 @@
-var import_meta = {};
-console.log([import_meta("x", null), import_meta("x", null)]);
+import {jsx as _jsx} from "react/jsx-runtime";
+console.log([_jsx("x", {}), import.meta("x", null)]);
+console.log([import.meta("x", null), import.meta("x", null)]);
f = function () {
- console.log([import_meta("y", null), import_meta("y", null)]);
+ console.log([_jsx("y", {}), import.meta("y", null)]);
+ console.log([import.meta("y", null), import.meta("y", null)]);
};

```
Expand All @@ -62,11 +60,10 @@ console.log([
```
### rolldown
```js
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";

//#region fragment.jsx
console.log([_jsx(_Fragment, { children: "x" }), /* @__PURE__ */ import.meta(import.meta, null, "x")]), f = function() {
console.log([_jsx(_Fragment, { children: "y" }), /* @__PURE__ */ import.meta(import.meta, null, "y")]);
console.log([import.meta(import.meta, null, "x"), /* @__PURE__ */ import.meta(import.meta, null, "x")]), f = function() {
console.log([import.meta(import.meta, null, "y"), /* @__PURE__ */ import.meta(import.meta, null, "y")]);
};

//#endregion
Expand All @@ -76,17 +73,12 @@ console.log([_jsx(_Fragment, { children: "x" }), /* @__PURE__ */ import.meta(imp
===================================================================
--- esbuild /out/fragment.js
+++ rolldown fragment.js
@@ -1,4 +1,8 @@
@@ -1,4 +1,3 @@
-var import_meta = {};
-(console.log([import_meta(import_meta, null, "x"), import_meta(import_meta, null, "x")]), f = function () {
- console.log([import_meta(import_meta, null, "y"), import_meta(import_meta, null, "y")]);
+import {Fragment as _Fragment, jsx as _jsx} from "react/jsx-runtime";
+(console.log([_jsx(_Fragment, {
+ children: "x"
+}), import.meta(import.meta, null, "x")]), f = function () {
+ console.log([_jsx(_Fragment, {
+ children: "y"
+ }), import.meta(import.meta, null, "y")]);
+(console.log([import.meta(import.meta, null, "x"), import.meta(import.meta, null, "x")]), f = function () {
+ console.log([import.meta(import.meta, null, "y"), import.meta(import.meta, null, "y")]);
});

```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reason
1. `jsx.factory`
1. replace this with `void 0` in none function scope
# Diff
## /out/factory.js
### esbuild
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reason
1. `jsx.factory`
1. should mark module as cjs if `this` in none function scope
# Diff
## /out/factory.js
### esbuild
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reason
1. `jsx.factory`
1. should replace `this` with `void 0` when it's in none function scope
# Diff
## /out/factory.js
### esbuild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ snapshot_kind: text
# tests/esbuild/default/import_re_export_es6_issue149
- app-!~{000}~.js => app-Dxo2PfWo.js
- app-!~{000}~.js => app-DaxVQXwp.js
# tests/esbuild/default/import_relative_as_package
Expand Down Expand Up @@ -1066,8 +1066,8 @@ snapshot_kind: text
# tests/esbuild/default/jsx_import_meta_value
- factory-!~{000}~.js => factory-CItnMqcA.js
- fragment-!~{001}~.js => fragment-C91b-ako.js
- factory-!~{000}~.js => factory-BjTERCBI.js
- fragment-!~{001}~.js => fragment-8HyPJWP9.js
# tests/esbuild/default/jsx_imports_common_js
Expand Down
19 changes: 11 additions & 8 deletions scripts/snap-diff/stats/aggregated-reason-without-not-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
- crates/rolldown/tests/esbuild/ts/ts_computed_class_field_use_define_true_lower
- crates/rolldown/tests/esbuild/ts/ts_declare_class_fields
- crates/rolldown/tests/esbuild/ts/ts_minify_derived_class
## `jsx.factory`
- crates/rolldown/tests/esbuild/default/import_re_export_es6_issue149
- crates/rolldown/tests/esbuild/default/jsx_import_meta_property
- crates/rolldown/tests/esbuild/default/jsx_import_meta_value
- crates/rolldown/tests/esbuild/default/jsx_this_property_common_js
- crates/rolldown/tests/esbuild/default/jsx_this_property_esm
- crates/rolldown/tests/esbuild/default/jsx_this_value_common_js
- crates/rolldown/tests/esbuild/default/jsx_this_value_esm
## lowering ts experimental decorator
- crates/rolldown/tests/esbuild/ts/ts_experimental_decorators_keep_names
- crates/rolldown/tests/esbuild/ts/ts_experimental_decorators_mangle_props_assign_semantics
Expand All @@ -36,6 +28,9 @@
## double module initialization
- crates/rolldown/tests/esbuild/dce/package_json_side_effects_array_keep_main_implicit_main
- crates/rolldown/tests/esbuild/dce/package_json_side_effects_array_keep_module_implicit_main
## `jsx.factory`
- crates/rolldown/tests/esbuild/default/jsx_import_meta_property
- crates/rolldown/tests/esbuild/default/jsx_this_property_common_js
## different iife impl
- crates/rolldown/tests/esbuild/importstar/re_export_star_as_external_iife
- crates/rolldown/tests/esbuild/importstar/re_export_star_as_iife_no_bundle
Expand Down Expand Up @@ -115,6 +110,14 @@
- crates/rolldown/tests/esbuild/default/inject_import_meta
## generate wrong syntax when Exported is `StringLiteral`, and rest part of esbuild gen is weird since there is no need to rename
- crates/rolldown/tests/esbuild/default/inject_no_bundle
## esbuild will auto polyfill `import.meta`
- crates/rolldown/tests/esbuild/default/jsx_import_meta_value
## replace this with `void 0` in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_property_esm
## should mark module as cjs if `this` in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_value_common_js
## should replace `this` with `void 0` when it's in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_value_esm
## should read `tsconfig.json`
- crates/rolldown/tests/esbuild/default/non_determinism_issue2537
## resolve alias
Expand Down
19 changes: 11 additions & 8 deletions scripts/snap-diff/stats/aggregated-reason.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@
- crates/rolldown/tests/esbuild/loader/loader_copy_with_format
- crates/rolldown/tests/esbuild/loader/loader_copy_with_injected_file_bundle
- crates/rolldown/tests/esbuild/loader/loader_copy_with_transform
## `jsx.factory`
- crates/rolldown/tests/esbuild/default/import_re_export_es6_issue149
- crates/rolldown/tests/esbuild/default/jsx_import_meta_property
- crates/rolldown/tests/esbuild/default/jsx_import_meta_value
- crates/rolldown/tests/esbuild/default/jsx_this_property_common_js
- crates/rolldown/tests/esbuild/default/jsx_this_property_esm
- crates/rolldown/tests/esbuild/default/jsx_this_value_common_js
- crates/rolldown/tests/esbuild/default/jsx_this_value_esm
## not support glob
- crates/rolldown/tests/esbuild/glob/glob_basic_no_splitting
- crates/rolldown/tests/esbuild/glob/glob_basic_splitting
Expand Down Expand Up @@ -97,6 +89,9 @@
## double module initialization
- crates/rolldown/tests/esbuild/dce/package_json_side_effects_array_keep_main_implicit_main
- crates/rolldown/tests/esbuild/dce/package_json_side_effects_array_keep_module_implicit_main
## `jsx.factory`
- crates/rolldown/tests/esbuild/default/jsx_import_meta_property
- crates/rolldown/tests/esbuild/default/jsx_this_property_common_js
## different iife impl
- crates/rolldown/tests/esbuild/importstar/re_export_star_as_external_iife
- crates/rolldown/tests/esbuild/importstar/re_export_star_as_iife_no_bundle
Expand Down Expand Up @@ -185,6 +180,14 @@
- crates/rolldown/tests/esbuild/default/inject_import_meta
## generate wrong syntax when Exported is `StringLiteral`, and rest part of esbuild gen is weird since there is no need to rename
- crates/rolldown/tests/esbuild/default/inject_no_bundle
## esbuild will auto polyfill `import.meta`
- crates/rolldown/tests/esbuild/default/jsx_import_meta_value
## replace this with `void 0` in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_property_esm
## should mark module as cjs if `this` in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_value_common_js
## should replace `this` with `void 0` when it's in none function scope
- crates/rolldown/tests/esbuild/default/jsx_this_value_esm
## not support preserve `jsx`
- crates/rolldown/tests/esbuild/default/minified_jsx_preserve_with_object_spread
## should read `tsconfig.json`
Expand Down
12 changes: 6 additions & 6 deletions scripts/snap-diff/stats/stats.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Compatibility metric
- total: 784
- passed: 550
- passed ratio: 70.15%
- passed: 551
- passed ratio: 70.28%
# Compatibility metric without not supported case
- total: 720
- passed: 550
- passed ratio: 76.39%
- passed: 551
- passed ratio: 76.53%
# Compatibility metric details
## dce
- total: 113
- passed: 93
- passed ratio: 82.30%
## default
- total: 254
- passed: 173
- passed ratio: 68.11%
- passed: 174
- passed ratio: 68.50%
## glob
- total: 9
- passed: 1
Expand Down
Loading

0 comments on commit 8ee2182

Please sign in to comment.