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

convert to typescript, add comment tag, text node #39

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .esbuildrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { build } = require('esbuild')

const options = {
jsxFactory: 'h'
}

build(options).catch(err => {
process.stderr.write(err.stderr)
process.exit(1)
})
45 changes: 36 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"browser": true,
Expand All @@ -18,16 +17,41 @@
"rules": {
"no-empty": 0,
"no-console": 0,
"no-unused-vars": [0, { "varsIgnorePattern": "^h$" }],
"no-unused-vars": [
0,
{
"varsIgnorePattern": "^h$"
}
],
"no-cond-assign": 1,
"semi": 2,
"camelcase": 0,
"comma-style": 2,
"comma-dangle": [2, "never"],
"indent": [2, "tab", {"SwitchCase": 1}],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"max-nested-callbacks": [2, 3],
"comma-dangle": [
2,
"never"
],
"indent": [
2,
"tab",
{
"SwitchCase": 1
}
],
"no-mixed-spaces-and-tabs": [
2,
"smart-tabs"
],
"no-trailing-spaces": [
2,
{
"skipBlankLines": true
}
],
"max-nested-callbacks": [
2,
3
],
"no-eval": 2,
"no-implied-eval": 2,
"no-new-func": 2,
Expand All @@ -37,7 +61,10 @@
"no-redeclare": 2,
"no-dupe-keys": 2,
"radix": 2,
"strict": [2, "never"],
"strict": [
2,
"never"
],
"no-shadow": 0,
"no-delete-var": 2,
"no-undef-init": 2,
Expand All @@ -54,4 +81,4 @@
"object-shorthand": 2,
"prefer-arrow-callback": 2
}
}
}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,17 @@ The above outputs the following HTML:
</ul>
</div>
```

### To generate comment in h

```js
h('!', null)
h('!', null, <p>foo</p>, <em>bar</em>, <div class="qqqqqq">baz</div>)
```

The above outputs the following HTML:

```html
<!-- -->
<!-- <p>foo</p><em>bar</em><div class="qqqqqq">baz</div> -->
````
126 changes: 56 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,59 @@
{
"name": "vhtml",
"amdName": "vhtml",
"version": "2.2.0",
"description": "Hyperscript reviver that constructs a sanitized HTML string.",
"main": "dist/vhtml.js",
"minified:main": "dist/vhtml.min.js",
"jsnext:main": "src/vhtml.js",
"scripts": {
"build": "npm-run-all transpile minify size",
"transpile": "rollup -c rollup.config.js",
"minify": "uglifyjs $npm_package_main -cm -o $npm_package_minified_main -p relative --in-source-map ${npm_package_main}.map --source-map ${npm_package_minified_main}.map",
"size": "echo \"gzip size: $(gzip-size $npm_package_minified_main | pretty-bytes)\"",
"test": "eslint {src,test} && mocha --compilers js:babel-register test/**/*.js",
"prepublish": "npm-run-all build test",
"release": "npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
},
"babel": {
"presets": [
"es2015",
"stage-0"
"name": "vhtml",
"amdName": "vhtml",
"version": "2.2.2",
"description": "Hyperscript reviver that constructs a sanitized HTML string.",
"main": "./dist/vhtml.cjs.js",
"module": "./dist/vhtml.es.js",
"browser": "./dist/vhtml.umd.js",
"types": "./dist/types/vhtml.d.ts",
"minified:main": "./dist/vhtml.umd.js",
"jsnext:main": "./src/vhtml.ts",
"scripts": {
"release1": "git add . && git commit -m \"Bump version\" && git push && pnpm version patch",
"preinstall": "npx only-allow pnpm",
"build": "vite build && tsc --declaration && pnpm size",
"tsc": "tsc",
"size": "echo \"gzip size: $(gzip-size $npm_package_minified_main | pretty-bytes)\"",
"test": "mocha --require esbuild-register test/**/*.ts*",
"prepublish": "pnpm build && pnpm test",
"release": "npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
},
"files": [
"src",
"dist"
],
"plugins": [
"transform-object-rest-spread",
[
"transform-react-jsx",
{
"pragma": "h"
}
]
]
},
"files": [
"src",
"dist"
],
"keywords": [
"hyperscript",
"html",
"renderer",
"strings"
],
"repository": {
"type": "git",
"url": "git+https://github.com/developit/vhtml.git"
},
"author": "Jason Miller <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/developit/vhtml/issues"
},
"homepage": "https://github.com/developit/vhtml",
"devDependencies": {
"babel-core": "^6.6.4",
"babel-eslint": "^7.0.0",
"babel-plugin-transform-object-rest-spread": "^6.6.4",
"babel-plugin-transform-react-jsx": "^6.6.5",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.7.2",
"chai": "^3.5.0",
"eslint": "^3.1.0",
"gzip-size-cli": "^1.0.0",
"mkdirp": "^0.5.1",
"mocha": "^3.1.2",
"npm-run-all": "^2.3.0",
"pretty-bytes-cli": "^1.0.0",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.4.0",
"rollup-plugin-es3": "^1.0.3",
"uglify-js": "^2.6.2"
}
"keywords": [
"hyperscript",
"html",
"renderer",
"strings"
],
"repository": {
"type": "git",
"url": "git+https://github.com/developit/vhtml.git"
},
"author": "Jason Miller <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/developit/vhtml/issues"
},
"homepage": "https://github.com/developit/vhtml",
"devDependencies": {
"chai": "^5.1.0",
"esbuild-register": "^3.5.0",
"eslint": "^9.0.0",
"gzip-size-cli": "^5.1.0",
"mocha": "^10.4.0",
"npm-run-all": "^4.1.5",
"pretty-bytes-cli": "^3.0.0",
"uglify-js": "^3.17.4",
"vite": "^5.2.8",
"vite-plugin-clean": "^1.0.0"
},
"dependencies": {
"@types/mocha": "^10.0.2",
"pnpm": "^8.15.7",
"typescript": "5.4.5"
}
}
26 changes: 0 additions & 26 deletions rollup.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/empty-tags.js → src/empty-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export default [
'param',
'source',
'track',
'wbr'
];
'wbr',
]
60 changes: 0 additions & 60 deletions src/vhtml.js

This file was deleted.

Loading