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

Add support for jsx-runtime #129

Merged
merged 45 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
461742f
feat: add support for jsx-runtime
JacopoPatroclo Feb 18, 2024
2284dfc
docs: update with example using tsconfig jsxImportSource
JacopoPatroclo Feb 19, 2024
749debb
feat: jsx-runtime
arthurfiorette Feb 22, 2024
9115c4b
style: formatted code
arthurfiorette Feb 22, 2024
c79676a
chore: jsx benchmark
arthurfiorette Feb 23, 2024
2a41a44
sty
arthurfiorette Feb 23, 2024
30016a6
code
arthurfiorette Feb 23, 2024
8483e53
fix tests
arthurfiorette Feb 23, 2024
316b232
fix bench
arthurfiorette Feb 23, 2024
1340015
doc: update readme to be react-jsx first
JacopoPatroclo Feb 23, 2024
eabb7fa
doc: update jsdocs for jsx and jsxs functions
JacopoPatroclo Feb 23, 2024
1e540f5
doc: add deprecation warning message to the top of the register file,…
JacopoPatroclo Feb 23, 2024
4d9cb00
doc: add serialization table in the readme file, update tests to be c…
JacopoPatroclo Feb 24, 2024
aaf7d9f
feat: improved jsx and createElement
arthurfiorette Feb 24, 2024
6419d25
deps: updated dependencies and benchmark
arthurfiorette Feb 24, 2024
2415990
feat: updates
arthurfiorette Feb 24, 2024
5b87e85
feat: added more serialization examples
arthurfiorette Feb 24, 2024
b7c1919
lockfile
arthurfiorette Feb 24, 2024
fc3c1b8
feat: migrate tests to use jsx-runtime by default
JacopoPatroclo Feb 25, 2024
c659145
doc: fix typo in output table
JacopoPatroclo Feb 25, 2024
799f392
fix: refactor project to be a pnpm workspace, refactor benchmarsk to …
JacopoPatroclo Feb 28, 2024
ad0f79f
initial monorepo with changesets
arthurfiorette Feb 29, 2024
c7f369d
changeset
arthurfiorette Feb 29, 2024
e4b3d27
nvm
arthurfiorette Feb 29, 2024
11c8307
feat: ts-html-plugin
arthurfiorette Feb 29, 2024
3d05717
feat: fastify-html-plugin
arthurfiorette Feb 29, 2024
a4d64c3
feat: removed MdnHomepage to a real world scenario
arthurfiorette Mar 1, 2024
2c75b94
feat: added notes regarding benchmarks
arthurfiorette Mar 1, 2024
bba98e2
docs: updated package json links
arthurfiorette Mar 1, 2024
d38983e
test: 100% coverage
arthurfiorette Mar 1, 2024
8eadee3
doc: fix grammar on benchmark readme, add reference to it on the root…
JacopoPatroclo Mar 2, 2024
932a955
feat: reserved key atttribute
arthurfiorette Mar 2, 2024
cc76ff7
feat: avoid hijacking reply
arthurfiorette Mar 2, 2024
73a07f1
code
arthurfiorette Mar 2, 2024
67ac1d2
packagejson
arthurfiorette Mar 2, 2024
c00efaf
ci
arthurfiorette Mar 2, 2024
9f35b92
lockfile
arthurfiorette Mar 2, 2024
b3732c2
ci
arthurfiorette Mar 2, 2024
b611195
vscode
arthurfiorette Mar 2, 2024
a9a765e
ts-html-plugin: solve path resolution issue on tests, add debug file …
JacopoPatroclo Mar 4, 2024
26fe409
refactor: renamed testing env var to a more descriptive one
arthurfiorette Mar 8, 2024
1d96f49
fix: test inconsistencies
arthurfiorette Mar 8, 2024
aa8973d
merge: merge main
arthurfiorette Mar 8, 2024
7a51612
chore: declaration maps for benchmarks
arthurfiorette Mar 9, 2024
f4656f4
chore: changeset
arthurfiorette Mar 9, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
index.tsbuildinfo
dist
coverage

*.log
4 changes: 2 additions & 2 deletions packages/ts-html-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"build": "tsc -p tsconfig.build.json",
"dev": "tsc -p tsconfig.build.json --watch",
"prepack": "npm run build",
"test": "node --require @swc-node/register --test test/**/*.test.ts",
"test-procedure": "pnpm build && pnpm install && pnpm test"
"test": "pnpm build && pnpm install && pnpm test-exec",
"test-exec": "node --require @swc-node/register --test test/**/*.test.ts"
},
"dependencies": {
"chalk": "^4.1.2",
Expand Down
8 changes: 7 additions & 1 deletion packages/ts-html-plugin/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ export function isSafeAttribute(
(type.aliasSymbol.parent?.escapedName === 'Html' ||
// @ts-expect-error - When using export as namespace X, parent.escapedName ends up
// as a complete (without resolving symlinks) quoted import path to its original file.
type.aliasSymbol.parent?.escapedName.endsWith('@kitajs/html/index"'))
type.aliasSymbol.parent?.escapedName.endsWith('@kitajs/html/index"') ||
// This is needed because of the resolved path of the parent if is installed with pnpm is a symlink
// that ts resolves to the original file path, so the path is not related to the node_modules but instead
// is absolute to the file system (this is only here because of the monorepo setup, it is not needed when used as a package)
(process.env.KITAJS_TESTING === 'true' &&
// @ts-expect-error - When using export as namespace X, parent.escapedName ends up
type.aliasSymbol.parent?.escapedName.endsWith('packages/html/index"')))
) {
return true;
}
Expand Down
24 changes: 8 additions & 16 deletions packages/ts-html-plugin/test/unsafe-tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ it('Detect xss prone usage', async () => {
<>
<div>
<div>{html}</div>
<div>{object}</div>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arthurfiorette I'm not sure about this, empty Objects are no longer supported by kitajs/html, right? Should we live this line by adding an expected ts error or should we, as I did, remove the line completely?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but the error thrown in this line is not from the ts-html-plugin and just a type error from typescript.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's correct. So we should not test this behavior. I'll leave it like this.

<div>{union}</div>
<div>
{['a', 'b', 'c'].map((i) => (
Expand All @@ -38,42 +37,35 @@ it('Detect xss prone usage', async () => {
},
{
start: { line: 38, offset: 15 },
end: { line: 38, offset: 21 },
end: { line: 38, offset: 20 },
text: Xss.message,
code: Xss.code,
category: 'error'
},
{
start: { line: 39, offset: 15 },
end: { line: 39, offset: 20 },
start: { line: 41, offset: 16 },
end: { line: 41, offset: 17 },
text: Xss.message,
code: Xss.code,
category: 'error'
},
{
start: { line: 42, offset: 16 },
end: { line: 42, offset: 17 },
start: { line: 44, offset: 19 },
end: { line: 44, offset: 20 },
text: Xss.message,
code: Xss.code,
category: 'error'
},
{
start: { line: 45, offset: 19 },
end: { line: 45, offset: 20 },
start: { line: 47, offset: 15 },
end: { line: 47, offset: 44 },
text: Xss.message,
code: Xss.code,
category: 'error'
},
{
start: { line: 48, offset: 15 },
end: { line: 48, offset: 44 },
text: Xss.message,
code: Xss.code,
category: 'error'
},
{
start: { line: 49, offset: 15 },
end: { line: 49, offset: 52 },
end: { line: 48, offset: 52 },
text: Xss.message,
code: Xss.code,
category: 'error'
Expand Down
6 changes: 5 additions & 1 deletion packages/ts-html-plugin/test/util/lang-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export class TSLangServer {
) {
this.server = fork(require.resolve('typescript/lib/tsserver'), {
cwd: projectPath,
stdio: ['pipe', 'pipe', 'pipe', 'ipc']
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
env: {
TSS_LOG: debug ? `-level verbose -file ${projectPath}/tss.log` : undefined,
KITAJS_TESTING: 'true'
}
});

this.exitPromise = deferred();
Expand Down