Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fcaldarelli/react-jsx-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: develop
Choose a base ref
...
head repository: TroyAlford/react-jsx-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
Loading
Showing with 3,496 additions and 9,509 deletions.
  1. +0 −47 .circleci/config.yml
  2. +1 −1 .eslintrc
  3. +87 −0 .github/workflows/publish.yml
  4. +16 −0 .github/workflows/pull-request.yml
  5. +1 −0 .gitignore
  6. +2 −10 .npmignore
  7. +1 −0 .tool-versions
  8. +10 −0 .vscode/settings.json
  9. +25 −0 .vscode/tasks.json
  10. +0 −11 babel.config.js
  11. +0 −16 babel.es5.js
  12. BIN bun.lockb
  13. +5 −0 bunfig.toml
  14. +18 −0 demo/demo.tsx
  15. +3 −3 {source → demo}/index.html
  16. +43 −0 demo/server.ts
  17. +0 −2 dist/cjs/react-jsx-parser.min.js
  18. +0 −1 dist/cjs/react-jsx-parser.min.js.map
  19. +0 −30 dist/components/JsxParser.d.ts
  20. +0 −2 dist/constants/attributeNames.d.ts
  21. +0 −4 dist/constants/specialTags.d.ts
  22. +0 −2 dist/es5/react-jsx-parser.min.js
  23. +0 −1 dist/es5/react-jsx-parser.min.js.map
  24. +0 −7 dist/helpers/camelCase.d.ts
  25. +0 −10 dist/helpers/hash.d.ts
  26. +0 −8 dist/helpers/parseStyle.d.ts
  27. +0 −9 dist/helpers/resolvePath.d.ts
  28. +0 −4 dist/index.d.ts
  29. +0 −2 dist/umd/react-jsx-parser.min.js
  30. +0 −1 dist/umd/react-jsx-parser.min.js.map
  31. +0 −37 jest.config.js
  32. +0 −6 jest/jest.setup.ts
  33. +0 −1 jest/mock.files.ts
  34. +0 −1 jest/mock.styles.ts
  35. +66 −185 package.json
  36. +12 −12 patches/{acorn-jsx+5.3.1.patch → acorn-jsx@5.3.2.patch}
  37. +626 −726 source/components/JsxParser.test.tsx
  38. +264 −139 source/components/JsxParser.tsx
  39. +0 −7 source/components/__snapshots__/JsxParser.test.tsx.snap
  40. +40 −1 source/constants/attributeNames.ts
  41. +0 −18 source/demo.tsx
  42. +0 −30 source/dist.test.js
  43. +6 −0 source/errors/NullishShortCircuit.ts
  44. +0 −2 source/helpers/camelCase.test.js
  45. +0 −2 source/helpers/parseStyle.test.js
  46. +6 −7 source/helpers/parseStyle.ts
  47. +0 −2 source/helpers/resolvePath.test.js
  48. +11 −5 source/types/acorn-jsx.d.ts
  49. +4 −0 test/happydom.ts
  50. +44 −24 tsconfig.json
  51. +0 −74 webpack.config.js
  52. +0 −51 webpack.demo.js
  53. +2,205 −8,008 yarn.lock
47 changes: 0 additions & 47 deletions .circleci/config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
"import/extensions": ["error", { "js": "never", "scss": "always", "ts": "never" }],
"import/no-unresolved": "off",
"import/prefer-default-export": "off",
"indent": ["error", "tab"],
"indent": ["error", "tab", { "SwitchCase": 1 }],
"lines-between-class-members": "off",
"no-case-declarations": "off",
"no-tabs": "off",
87 changes: 87 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Check and Publish NPM Version

on:
push:
branches:
- develop

jobs:
check-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up bun
uses: oven-sh/setup-bun@v2

- name: Install and Build
run: |
bun install
bun run build
- name: Get the latest release
id: get_latest_release
run: |
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "::set-output name=latest_release::${latest_release}"
- name: Get version from package.json
id: get_package_version
run: |
package_version=$(jq -r .version < ./package.json)
echo "::set-output name=package_version::${package_version}"
- name: Compare GitHub release version
id: compare_github_versions
run: |
if [ "${{ steps.get_latest_release.outputs.latest_release }}" == "${{ steps.get_package_version.outputs.package_version }}" ]; then
echo "GitHub release version matches package.json version."
echo "::set-output name=should_create_release::false"
else
echo "GitHub release version does not match package.json version."
echo "::set-output name=should_create_release::true"
fi
- name: Create GitHub release
if: steps.compare_github_versions.outputs.should_create_release == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_package_version.outputs.package_version }}
release_name: Release ${{ steps.get_package_version.outputs.package_version }}
draft: false
prerelease: false

- name: Get latest NPM version
id: get_latest_npm_version
run: |
npm_version=$(npm show $(jq -r .name < ./package.json) version)
echo "::set-output name=npm_version::${npm_version}"
- name: Compare NPM version
id: compare_npm_versions
run: |
if [ "${{ steps.get_latest_npm_version.outputs.npm_version }}" == "${{ steps.get_package_version.outputs.package_version }}" ]; then
echo "NPM version matches package.json version."
echo "::set-output name=should_publish_npm::false"
else
echo "NPM version does not match package.json version."
echo "::set-output name=should_publish_npm::true"
fi
- name: Publish to NPM
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
if: steps.compare_npm_versions.outputs.should_publish_npm == 'true'
run: bun run npm publish --//registry.npmjs.org/:_authToken=${NPM_TOKEN}

- name: Success message
if: steps.compare_github_versions.outputs.should_create_release == 'false' && steps.compare_npm_versions.outputs.should_publish_npm == 'false' || success()
run: echo "NPM package and GitHub release are up to date or published successfully."

- name: Fail if publish failed
if: failure()
run: exit 1
16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pull Request

on:
pull_request:
branches: [develop]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun eslint
- run: bun test
- run: bun run build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/coverage
**/dist
**/node_modules
**/npm-debug.log
**/package-lock.json
12 changes: 2 additions & 10 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
**/.circleci
**/.eslintrc
**/.gitignore
**/.vscode
**/jest
**/jest.config.js
**/node_modules
**/test-coverage
**/webpack.*.js
**/yarn-error.log

**/demo.*
**/*.html
**/*.test.js
**/*.test.tsx
**/demo
**/*.test.*
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun 1.2.1
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll.eslint": "always",
"source.fixAll.tslint": "always",
"source.fixAll.ts": "always",
},
"files.insertFinalNewline": true
}
25 changes: 25 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"tasks": [
{
"command": "asdf install && bun install",
"group": {
"isDefault": true,
"kind": "build"
},
"isBackground": true,
"label": "Setup Project",
"presentation": {
"echo": false,
"focus": false,
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [],
"runOptions": {
"runOn": "folderOpen"
},
"type": "shell"
}
],
"version": "2.0.0"
}
11 changes: 0 additions & 11 deletions babel.config.js

This file was deleted.

16 changes: 0 additions & 16 deletions babel.es5.js

This file was deleted.

Binary file added bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[install.lockfile]
print = "yarn"

[test]
preload = ["./test/happydom.ts"]
18 changes: 18 additions & 0 deletions demo/demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable no-console */
import React from 'react'
import { createRoot } from 'react-dom/client'
import JsxParser from '../source'

const root = createRoot(document.querySelector('#root')!)

root.render(
<JsxParser
autoCloseVoidElements
jsx={`
<img src="https://picsum.photos/300/500">
<div className="foo">bar</div>
`}
onError={console.error}
showWarnings
/>,
)
6 changes: 3 additions & 3 deletions source/index.html → demo/index.html
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>react-jsx-parser demo</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script defer src="react-jsx-parser-demo.min.js"></script>
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script defer src="/demo.min.js"></script>
</head>
<body>
<div id="root"></div>
43 changes: 43 additions & 0 deletions demo/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as path from 'path';

const server = Bun.serve({
port: 3000,
async fetch(req) {
const url = new URL(req.url);

switch (url.pathname) {
case '/':
return new Response(
await Bun.file(path.resolve(__dirname, './index.html')).text(),
{ headers: { 'Content-Type': 'text/html' } },
);
case '/demo.min.js':
const build = await Bun.build({
entrypoints: [path.resolve(__dirname, './demo.tsx')],
minify: true,
target: 'browser',
});
if (!build.success) {
const errorMessages = build.logs
.filter(log => log.level === "error")
.map(log => log.message)
.join("\n");

console.error("Build failed:", errorMessages);

return new Response(`Build failed:\n${errorMessages}`, {
status: 500,
headers: { "Content-Type": "text/plain" }
});
}
return new Response(
build.outputs[0],
{ headers: { 'Content-Type': 'application/javascript' } },
);
default:
return new Response('Not Found', { status: 404 });
}
}
});

console.log(`Listening on http://localhost:${server.port}`);
2 changes: 0 additions & 2 deletions dist/cjs/react-jsx-parser.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/cjs/react-jsx-parser.min.js.map

This file was deleted.

30 changes: 0 additions & 30 deletions dist/components/JsxParser.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/constants/attributeNames.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions dist/constants/specialTags.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/es5/react-jsx-parser.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/es5/react-jsx-parser.min.js.map

This file was deleted.

7 changes: 0 additions & 7 deletions dist/helpers/camelCase.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions dist/helpers/hash.d.ts

This file was deleted.

Loading