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

feat: typescript support #185

Merged
merged 63 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
65d73eb
feat: initial typescript support
JiLiZART Aug 18, 2023
7d6e35f
feat: typescript support
JiLiZART Aug 20, 2023
224a891
feat(plugin-helper): move files to typescript
JiLiZART Oct 24, 2023
21513f2
chore: update lock files
JiLiZART Oct 24, 2023
51f6ab8
feat: preset types
JiLiZART Oct 27, 2023
804079a
fix: build
JiLiZART Oct 28, 2023
2098591
fix: benchmark
JiLiZART Oct 28, 2023
ceb20ac
fix: remove pnpm cache
JiLiZART Oct 28, 2023
b424fa3
fix: bench action
JiLiZART Oct 28, 2023
964ac7d
fix: pnpm recursive install
JiLiZART Oct 28, 2023
b984eca
fix: nx cache
JiLiZART Oct 28, 2023
c38a49f
fix: lock file
JiLiZART Oct 30, 2023
b1fe879
fix: workflows
JiLiZART Oct 30, 2023
a03fc4e
fix: lerna support in pnpm
JiLiZART Oct 30, 2023
89df1b0
fix: pnpm workspace
JiLiZART Oct 30, 2023
1b7f6e8
fix: remove unused files
JiLiZART Oct 30, 2023
ca9b1da
fix: pnpm lock file
JiLiZART Oct 30, 2023
d21a4f9
fix: update lerna for support pnpm
JiLiZART Oct 30, 2023
b6a1c1f
fix: lerna bootstrap
JiLiZART Oct 30, 2023
5ce4568
fix: rollup build
JiLiZART Oct 30, 2023
3377fa6
fix: update nx
JiLiZART Oct 30, 2023
13fd9d1
fix: build
JiLiZART Oct 30, 2023
a581218
fix: add nx dep target
JiLiZART Oct 30, 2023
b8c319b
fix: remove nx cache
JiLiZART Oct 30, 2023
f8ec6ad
fix: workflow run on push only for master
JiLiZART Oct 30, 2023
6e4739d
fix: test workflow run on push only for master
JiLiZART Oct 30, 2023
f9ee548
fix: remove parallel for gen types
JiLiZART Oct 30, 2023
c5fabf2
fix: benchmark
JiLiZART Oct 30, 2023
509b5df
fix: benchmark imports
JiLiZART Oct 30, 2023
9f7e38e
fix: pnpm
JiLiZART Dec 22, 2023
7251a9d
fix: types errors and pnpm
JiLiZART Dec 22, 2023
d36f69c
fix: types
JiLiZART Dec 22, 2023
19191e8
fix: types
JiLiZART Dec 26, 2023
2a2dd91
refactor: parser
JiLiZART Dec 26, 2023
2e604c6
fix(parser): tests
JiLiZART Dec 26, 2023
583a6e6
fix: preset tests
JiLiZART Dec 26, 2023
51a2340
fix: react types
JiLiZART Dec 26, 2023
0b7bb91
fix: react type declarations
JiLiZART Dec 26, 2023
d0fc1a7
fix: pnpm lock file
JiLiZART Feb 7, 2024
a67beb4
fix: react preset types
JiLiZART Feb 7, 2024
084aec8
fix: lock file
JiLiZART Feb 7, 2024
14982cc
fix: vue2 types
JiLiZART Feb 7, 2024
dbf3c02
feat: dev container support
JiLiZART Feb 20, 2024
32f78cd
fix: types
JiLiZART Mar 25, 2024
54a8237
fix: types
JiLiZART Mar 25, 2024
d161762
Merge remote-tracking branch 'origin/master' into feat/typescript-sup…
JiLiZART Mar 27, 2024
d1915b4
refactor: rewrite pkg-task, add nx gen-types deps, fix react/render.ts
JiLiZART Mar 27, 2024
d7c2f04
refactor: types
JiLiZART Mar 27, 2024
8be912d
fix: types
JiLiZART Apr 20, 2024
72e1926
fix: rename gen-types to types
JiLiZART Apr 20, 2024
db9c64a
Merge remote-tracking branch 'origin/master' into feat/typescript-sup…
JiLiZART Apr 20, 2024
241f4d1
fix: nx build order
JiLiZART Apr 20, 2024
158acf2
fix: nx reset
JiLiZART Apr 20, 2024
5223396
fix: define nx deps explicit
JiLiZART Apr 20, 2024
02eec5c
fix: build
JiLiZART Apr 20, 2024
3e197f6
fix: nx
JiLiZART Apr 20, 2024
a0c3282
fix: nx order build
JiLiZART Apr 23, 2024
2d99220
fix: nx deps
JiLiZART Apr 23, 2024
2906ee9
fix: bbob cli tests
JiLiZART Apr 23, 2024
1298685
fix: tests
JiLiZART Apr 23, 2024
2816f5f
fix: cli tests and import
JiLiZART Apr 23, 2024
e8d06f8
fix: test cover
JiLiZART Apr 23, 2024
3c0940b
fix: cli cover
JiLiZART Apr 23, 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
5 changes: 5 additions & 0 deletions .changeset/khaki-cobras-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"feat: typescript support": minor
---

Now BBob supports Typescript with typings
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ jobs:
cache: 'pnpm'

- name: Install
run: pnpm install --frozen-lockfile --strict-peer-dependencies
run: pnpm i --frozen-lockfile --strict-peer-dependencies

- name: Run the lint
run: pnpm lint
run: pnpm run lint

- name: Install coverage
run: pnpm install --global codecov

- name: Run the coverage
run: pnpm cover
run: pnpm run cover

- name: Run the coverage
run: codecov
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ typings/
# benchmark test files
benchmark/html5
.nx

.nx


.nx/cache
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
registry=https://registry.npmjs.org/
link-workspace-packages=true
9 changes: 4 additions & 5 deletions .swcrc-commonjs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"module": {
"type": "commonjs",

Expand All @@ -9,14 +10,12 @@
},
"jsc": {
"transform": {
"optimizer": {
"simplify": false
}
"optimizer": {}
},
"loose": true,
"parser": {
"syntax": "ecmascript",
"jsx": true
"syntax": "typescript",
"tsx": true
}
}
}
9 changes: 4 additions & 5 deletions .swcrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"module": {
"type": "es6",
"strict": false,
Expand All @@ -9,15 +10,13 @@
"minify": false,
"jsc": {
"transform": {
"optimizer": {
"simplify": false
}
"optimizer": {}
},
"target": "es2018",
"loose": true,
"parser": {
"syntax": "ecmascript",
"jsx": true
"syntax": "typescript",
"tsx": true
},
"externalHelpers": false
}
Expand Down
8 changes: 4 additions & 4 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ suite
});
})
.add('@bbob/parser lexer old', () => {
const lexer1 = require('@bbob/parser/lib/lexer_old');
const lexer1 = require('./lexer_old');

return require('@bbob/parser/lib/index').parse(stub, {
return require('@bbob/parser').parse(stub, {
onlyAllowTags: ['ch'],
createTokenizer: lexer1.createLexer,
});
})
.add('@bbob/parser lexer', () => {
const lexer2 = require('@bbob/parser/lib/lexer');
const lexer2 = require('@bbob/parser');

return require('@bbob/parser/lib/index').parse(stub, {
return require('@bbob/parser').parse(stub, {
onlyAllowTags: ['ch'],
createTokenizer: lexer2.createLexer,
});
Expand Down
13 changes: 6 additions & 7 deletions packages/bbob-parser/src/lexer_old.js → benchmark/lexer_old.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-plusplus,no-param-reassign */
import {
const {
OPEN_BRAKET,
CLOSE_BRAKET,
QUOTEMARK,
Expand All @@ -9,12 +9,12 @@ import {
TAB,
EQ,
N,
} from '@bbob/plugin-helper';
} = require('@bbob/plugin-helper');

import {
const {
Token, TYPE_ATTR_NAME, TYPE_ATTR_VALUE, TYPE_NEW_LINE, TYPE_SPACE, TYPE_TAG, TYPE_WORD,
} from './Token';
import { createCharGrabber, trimChar, unquote } from './utils';
} = require('@bbob/parser/Token');
const { createCharGrabber, trimChar, unquote } = require('@bbob/parser/utils');

// for cases <!-- -->
const EM = '!';
Expand Down Expand Up @@ -238,5 +238,4 @@ function createLexer(buffer, options = {}) {
};
}

export const createTokenOfType = createToken;
export { createLexer };
module.exports.createLexer = createLexer;
3 changes: 2 additions & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"url": "https://artkost.ru/"
},
"dependencies": {
"@bbob/parser": "workspace:*",
"@bbob/parser": "*",
"@bbob/plugin-helper": "*",
"benchmark": "2.1.4",
"picocolors": "1.0.0",
"xbbcode-parser": "0.1.2",
Expand Down
4 changes: 3 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
"message": "chore(release): publish %s"
}
},
"useNx": true
"npmClient": "pnpm",
"useNx": true,
"useWorkspaces": true
}
83 changes: 76 additions & 7 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,81 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"targetDefaults": {
"types": {
"dependsOn": [
"^types"
],
"outputs": ["{projectRoot}/types"],
"cache": true
},
"build": {
"dependsOn": [
"^types",
"^build:commonjs",
"^build:es",
"^build:umd"
],
"outputs": ["{projectRoot}/lib", "{projectRoot}/es", "{projectRoot}/dist"],
"cache": true
},
"test": {
"dependsOn": [
"^build",
"^test"
]
},
"cover": {
"dependsOn": [
"^build",
"^cover"
],
"outputs": ["{projectRoot}/coverage"]
},
"lint": {
"dependsOn": [
"^lint"
]
},
"build:commonjs": {
"dependsOn": [
"^build:es",
"^build:commonjs"
],
"outputs": ["{projectRoot}/lib"],
"cache": true
},
"build:es": {
"dependsOn": [
"^build:es"
],
"outputs": ["{projectRoot}/es"],
"cache": true
},
"build:umd": {
"dependsOn": [
"^build:es",
"^build:umd"
],
"outputs": ["{projectRoot}/dist"],
"cache": true
}
},
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"defaultBase": "master",
"extends": "nx/presets/npm.json",
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"cacheableOperations": ["build"]
"targetName": "eslint:lint",
"extensions": [
"ts",
"tsx",
"js",
"jsx",
"html",
"vue"
]
}
}
},
"targetDefaults": {},
"defaultBase": "master"
]
}
68 changes: 42 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "bbob",
"scripts": {
"prepublishOnly": "npm run test",
"bootstrap": "lerna bootstrap --no-ci",
"bootstrap": "pnpm re",
"publish-ci": "npm run build && lerna publish from-package --yes --include-merged-tags --conventional-commits",
"publish-canary": "npm run build && lerna publish --yes --include-merged-tags --conventional-commits --no-private --no-git-tag-version",
"publish-from-packages": "npm run build && lerna publish from-package --yes --include-merged-tags --conventional-commits --create-release github",
Expand All @@ -10,11 +11,13 @@
"publish-minor": "npm run build && lerna version minor --include-merged-tags --conventional-commits --no-git-tag-version --no-private",
"size": "nx run-many --target=size",
"bundlesize": "nx run-many --target=bundlesize",
"test": "npm run build && nx run-many --target=link && nx run-many --target=test",
"test": "nx run-many --target=test",
"cover": "nx run-many --target=cover",
"build": "nx run-many --target=build",
"types": "nx run-many --target=types",
"release": "npm run build && changeset publish",
"lint": "nx run-many --target=link && npm run build && nx run-many --target=lint"
"lint": "nx run-many --target=lint",
"cleanup": "node scripts/cleanup"
},
"author": {
"name": "Nikolay Kostyurin <[email protected]>",
Expand All @@ -26,14 +29,13 @@
"@changesets/cli": "2.26.2",
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@nrwl/cli": "15.3.3",
"@rollup/plugin-commonjs": "23.0.2",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-replace": "5.0.1",
"@size-limit/preset-small-lib": "6.0.1",
"@swc/cli": "0.1.57",
"@swc/core": "1.3.16",
"@swc/jest": "0.2.23",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "5.0.5",
"@size-limit/preset-small-lib": "11.0.1",
"@swc/cli": "0.3.10",
"@swc/core": "1.3.107",
"@swc/jest": "0.2.36",
"@testing-library/dom": "9.3.1",
"@testing-library/jest-dom": "6.1.2",
"bundlesize2": "0.0.31",
Expand All @@ -46,18 +48,26 @@
"eslint-plugin-react": "7.26.1",
"eslint-plugin-react-hooks": "4.6.0",
"husky": "7.0.2",
"jest": "29.5.0",
"jest-environment-jsdom": "29.6.4",
"lerna": "6.0.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"lerna": "7.4.1",
"lint-staged": "11.2.3",
"microtime": "3.0.0",
"nx": "15.3.3",
"posthtml-render": "^3.0.0",
"rimraf": "^3.0.2",
"rollup": "3.3.0",
"nx": "18.3.3",
"posthtml-render": "3.0.0",
"rimraf": "5.0.5",
"rollup": "4.1.5",
"rollup-plugin-gzip": "3.1.0",
"rollup-plugin-swc3": "0.7.0",
"size-limit": "6.0.1"
"rollup-plugin-swc3": "0.11.0",
"size-limit": "11.0.1",
"typescript": "5.1.6",
"@types/node": "20.4.5",
"@types/jest": "29.5.3",
"@types/react": "18.2.18",
"@nx/eslint": "18.3.3",
"@nx/rollup": "18.3.3",
"@nx/jest": "18.3.3",
"@bbob/scripts": "*"
},
"publishConfig": {
"access": "public",
Expand All @@ -69,15 +79,18 @@
}
},
"pkgTasks": {
"build-commonjs": "@/cross-env BABEL_ENV=commonjs NODE_ENV=production @/swc --config-file ../../.swcrc-commonjs.json --out-dir lib src",
"build-es": "@/cross-env BABEL_ENV=es NODE_ENV=production @/swc --config-file ../../.swcrc.json --out-dir es src",
"build-umd": "@/cross-env BABEL_ENV=rollup NODE_ENV=production @/rollup --config ../../rollup.config.mjs",
"build:commonjs": "@/cross-env BABEL_ENV=commonjs NODE_ENV=production @/swc ./src/ --config-file ../../.swcrc-commonjs.json --out-dir lib --strip-leading-paths",
"build:es": "@/cross-env BABEL_ENV=es NODE_ENV=production @/swc ./src/ --config-file ../../.swcrc.json --out-dir es --strip-leading-paths",
"build:umd": "@/cross-env BABEL_ENV=rollup NODE_ENV=production @/rollup --config ../../rollup.config.mjs",
"build": "npm run build:es && npm run build:commonjs && npm run build:umd",
"test": "@/jest",
"cover": "@/jest --config ../../jest.config.js --coverage .",
"cover": "@/jest --coverage .",
"lint": "@/eslint .",
"bundlesize": "npm run build && @/cross-env NODE_ENV=production @/bundlesize ."
"types": "@/tsc",
"bundlesize": "npm run build && @/cross-env NODE_ENV=production @/bundlesize .",
"size": "npm run build && @/cross-env NODE_ENV=production @/size-limit ."
},
"packageManager": "pnpm@8.7.6",
"packageManager": "pnpm@8.15.1",
"pnpm": {
"overrides": {
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
Expand All @@ -100,5 +113,8 @@
}
}
}
},
"nx": {
"includedScripts": []
}
}
5 changes: 5 additions & 0 deletions packages/bbob-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
coverage
dist
lib
es
types
test/*.d.ts
test/*.map
Loading
Loading