-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement jsx option * Add tests * Pass jsx options to SWC Signed-off-by: Martin Idel <[email protected]> * Add JsxElement to ast-types * Add JsxOpeningElement * Add JSXElementChild -> JSXElement * Add JSXElementChild -> JSXText * WIP Add JsxAttribute * Add JSXElementChild -> JSXExprContainer and JSXEmptyExpr * Add JsxFragment * Align AST types with official types and verify This adds acorn-jsx to test the AST against. Tests will fail if the check fails. * Sort converters into alphabetical order * Associate identifier with variable * Use correct JSX types * Ensure React is included when JSX is used * Rework JSX option and global variable handling for preserving * Start work on transpilation support * Improve option and transpilation support * Handle missing jsx factory * Add additional tests and support expressions * Handle JSXText * Support attributes transpilation * Support fragments * Extract shared code from fragments * Support JSXText in all possible positions * Support all possible JSX attribute types * Support JSXMemberExpression * Support JSXSpreadChild * Support JSXSpreadAttribute * Use correct span for empty expressions * Improve formatting for macro names * Move converters into separate files * Make everything except the parse function only crate public * use macros for JSX where possible * Initial jsx rendering logic for simple cases * Split classic and automatic mode * Handle jsx without children * Handle jsx with children * Fix fragment rendering * Prepare for fallback rendering We still need to switch the arguments to old mode as well for the fallback case. * Reenable tests for now * Update linting * Improve JSX rendering and move to parent element * Align classic attribute rendering with automatic * Refine classic mode rendering to make extraction easier * Refine automatic mode rendering * Fix automatic rendering * Extract attribute rendering * Extract shared functionality * Move initialize and include functionality to shared base element * Extract fragment opening rendering to JSXOpeningFragment * Share rendering functionality with fragments * Deconflict closing elements * Handle native elements * Add additional checks * Ensure CLI supports presets * Add JSX options to REPL * Add documentation * Improve coverage * Fix local browser build * Add jsx example * Refine docs --------- Signed-off-by: Martin Idel <[email protected]> Co-authored-by: Martin Idel <[email protected]> Co-authored-by: Felix Huttmann <[email protected]> Co-authored-by: Alexander Droll <[email protected]> Co-authored-by: Timo Peter <[email protected]>
- Loading branch information
1 parent
ed98e08
commit ca186ee
Showing
350 changed files
with
4,171 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import path from 'path'; | ||
import type { Plugin } from 'vite'; | ||
|
||
export function replacePathPicomatch(): Plugin { | ||
return { | ||
enforce: 'pre', | ||
load(id) { | ||
if (id === 'picomatch') { | ||
return 'export default {}'; | ||
} | ||
}, | ||
name: 'replace-picomatch', | ||
resolveId(source) { | ||
if (source === 'picomatch') { | ||
return { id: 'picomatch' }; | ||
} | ||
if (source === 'path') { | ||
return path.resolve(__dirname, '../../browser/src/path.ts'); | ||
} | ||
} | ||
}; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"title": "Tree-shaking", | ||
"title": "Named exports", | ||
"options": { | ||
"treeshake": true | ||
"output": { | ||
"exports": "auto", | ||
"esModule": "if-default-prop" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
// TREE-SHAKING | ||
import { cube } from './maths.js'; | ||
// NAMED EXPORTS | ||
// There are many ways to export bindings | ||
// from an ES2015 module | ||
export var foo = 1; | ||
|
||
console.log(cube(5)); // 125 | ||
export function bar() { | ||
// try changing this to `foo++` | ||
// when generating CommonJS | ||
return foo; | ||
} | ||
|
||
function baz() { | ||
return bar(); | ||
} | ||
|
||
export * from './qux'; | ||
export { baz }; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
{ | ||
"title": "Named exports", | ||
"title": "Tree-shaking", | ||
"options": { | ||
"output": { | ||
"exports": "auto", | ||
"esModule": "if-default-prop" | ||
} | ||
"treeshake": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
// NAMED EXPORTS | ||
// There are many ways to export bindings | ||
// from an ES2015 module | ||
export var foo = 1; | ||
// TREE-SHAKING | ||
import { cube } from './maths.js'; | ||
|
||
export function bar() { | ||
// try changing this to `foo++` | ||
// when generating CommonJS | ||
return foo; | ||
} | ||
|
||
function baz() { | ||
return bar(); | ||
} | ||
|
||
export * from './qux'; | ||
export { baz }; | ||
console.log(cube(5)); // 125 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"title": "Multiple Entry Modules", | ||
"entryModules": ["main.js", "otherEntry.js"], | ||
"options": { | ||
"output": { | ||
"minifyInternalExports": false, | ||
"preserveModules": false | ||
} | ||
} | ||
"entryModules": ["main.js", "otherEntry.js"], | ||
"options": { | ||
"output": { | ||
"minifyInternalExports": false, | ||
"preserveModules": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"title": "JSX", | ||
"options": { | ||
"jsx": { | ||
"mode": "preserve" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// JSX SUPPORT | ||
// Try different jsx.mode and see how it is transformed | ||
import './other.js'; | ||
const Foo = ({ world }) => <div>Hello {world}!</div>; | ||
|
||
console.log(<Foo world="World" />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const Foo = () => <div>This is deconflicted!</div>; | ||
console.log(<Foo />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.