Skip to content

Commit

Permalink
2.0.0 - Candy
Browse files Browse the repository at this point in the history
- Improve syntax
  - Change text nodes from [...] to "...", '...', and [>...] to `${...}`
  - Change attributes from value=>"1 + 2" to value=(1 + 2), or for example value=`${1 + 2}`, value=[1, 2]
  - Remove the dynamic <> block and instead allow `for`, `if`, and `else` in child {} blocks
  - Template definitions are now permitted outside of the toplevel, and are declared with $$name(props){children} instead of $name(props){children}
  - Add // line comments
- Use deno instead of node
- Use esbuild with bundling and minification instead of tsc for js output
- (internal, perf) use a Reader class instead of constantly creating new { result, pos } objects
- fix html escaping
- more eslint
- start test and bench infrastructure a little bit
  • Loading branch information
esthedebeste committed Sep 18, 2023
1 parent 96a33c3 commit b1515b1
Show file tree
Hide file tree
Showing 26 changed files with 2,983 additions and 683 deletions.
34 changes: 10 additions & 24 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -10,30 +7,19 @@
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 10,
"ecmaVersion": 2022,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "unicorn"],
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"unicorn/escape-case": "off",
"unicorn/no-hex-escape": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/numeric-separators-style": "off",
"unicorn/no-null": "off",
"unicorn/prefer-code-point": "off",
"unicorn/no-array-callback-reference": "off",
"no-fallthrough": "off"
},
"root": true,
"overrides": [
{
"files": ["*.js"],
"env": {
"browser": true
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": "allow-with-description",
"minimumDescriptionLength": 3
}
}
]
]
},
"root": true
}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
test/output
node_modules
dist
package-lock.json
dist
7 changes: 0 additions & 7 deletions .npmignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Launch render-input.ts",
"type": "node",
"program": "${workspaceFolder}/test/render-input.ts",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-wait", "-A"],
"attachSimplePort": 9229
},
{
"request": "launch",
"name": "Launch bench.ts",
"type": "node",
"program": "${workspaceFolder}/test/bench.ts",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-wait", "-A"],
"attachSimplePort": 9229
}
]
}
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
// Required to compile directly to ES modules.
"typescript.preferences.importModuleSpecifierEnding": "js"
"deno.enable": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
17 changes: 0 additions & 17 deletions .vscode/snippets.code-snippets

This file was deleted.

16 changes: 16 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"lint": {
"exclude": ["dist", "test/dist"],
"include": ["*.ts"]
},
"fmt": {
"useTabs": true,
"semiColons": false,
"lineWidth": 120
},
"tasks": {
"build": "deno run -A ./esbuild.ts && deno fmt dist/poggies.d.ts",
"bench": "deno run -A ./test/bench.ts"
},
"nodeModulesDir": true
}
2,052 changes: 2,052 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions esbuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { build } from "npm:esbuild"
await build({
entryPoints: ["src/poggies.ts"],
outfile: "dist/poggies.js",
format: "esm",
bundle: true,
treeShaking: true,
external: ["node:fs"],
minify: true,
})

import("npm:typescript/lib/tsc.js") // fun way to run `tsc` to generate types
45 changes: 18 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
{
"name": "poggies",
"version": "1.2.1",
"version": "2.0.0",
"description": "A simple JavaScript templating engine",
"main": "./dist/poggies.js",
"types": "./dist/poggies.d.ts",
"repository": "github:tbhmens/poggies",
"exports": {
"import": "./dist/poggies.js"
"main": "dist/poggies.js",
"types": "dist/poggies.d.ts",
"repository": "github:esthedebeste/poggies",
"scripts": {
"prepack": "deno task build"
},
"type": "module",
"author": "tbhmens",
"author": "esthedebeste",
"license": "MIT",
"keywords": [
"templating",
"poggies",
"template",
"engine"
],
"bugs": {
"url": "https://github.com/tbhmens/poggies/issues"
},
"files": [
"dist/**/*.js",
"dist/poggies.d.ts"
"dist/poggies.*"
],
"homepage": "https://github.com/tbhmens/poggies#readme",
"scripts": {
"build": "tsc && prettier -w ./dist",
"prepack": "npm run build",
"test": "tsm ./test/test.ts"
},
"bugs": "https://github.com/esthedebeste/poggies/issues",
"homepage": "https://github.com/esthedebeste/poggies#readme",
"devDependencies": {
"@types/node": "^16.11.9",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-unicorn": "^39.0.0",
"prettier": "^2.4.1",
"tsm": "^2.1.4",
"typescript": "^4.5.2"
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"esbuild": "^0.19.3",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-unicorn": "^48.0.1",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit b1515b1

Please sign in to comment.