Skip to content

Commit dfbc258

Browse files
authored
feature: Migrated to vite (#8)
1 parent a31f639 commit dfbc258

File tree

7 files changed

+130
-115
lines changed

7 files changed

+130
-115
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.eslintrc.json

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
{
22
"env": {
33
"browser": true,
4-
"es2021": true,
4+
"es6": true,
55
"node": true
66
},
7-
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/strict", "prettier"],
8+
"plugins": ["@typescript-eslint"],
89
"parser": "@typescript-eslint/parser",
910
"parserOptions": {
10-
"ecmaVersion": 12,
11-
"sourceType": "module"
11+
"ecmaVersion": "latest",
12+
"sourceType": "module",
13+
"project": ["./tsconfig.json"]
1214
},
13-
"plugins": ["@typescript-eslint"],
1415
"rules": {
1516
"no-console": "error",
16-
"@typescript-eslint/no-var-requires": "error",
17-
"@typescript-eslint/no-non-null-assertion": "error",
18-
"@typescript-eslint/explicit-function-return-type": ["error"],
19-
"@typescript-eslint/ban-ts-comment": "error"
17+
"@typescript-eslint/ban-ts-comment": "off",
18+
"arrow-body-style": "off",
19+
"no-param-reassign": [
20+
"error",
21+
{
22+
"props": false
23+
}
24+
],
25+
"no-unused-vars": "off",
26+
"@typescript-eslint/no-unused-vars": [
27+
"error",
28+
{
29+
"varsIgnorePattern": "^_",
30+
"argsIgnorePattern": "^_"
31+
}
32+
],
33+
"no-nested-ternary": "warn",
34+
"@typescript-eslint/no-shadow": "off",
35+
"@typescript-eslint/naming-convention": [
36+
"error",
37+
{
38+
"selector": "enum",
39+
"format": ["UPPER_CASE"]
40+
}
41+
],
42+
"no-useless-catch": "error",
43+
"no-underscore-dangle": "off",
44+
"@typescript-eslint/no-invalid-void-type": "off"
2045
}
2146
}

lib/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
11
import { PubSub as PubSubInstance } from "./pubSub";
22

3-
export type PubSubInterface = Omit<PubSubInstance, "subscribers">;
4-
5-
const PubSub = (): PubSubInterface => {
6-
const pubSub = new PubSubInstance();
7-
8-
return {
9-
subscribe: pubSub.subscribe,
10-
unsubscribe: pubSub.unsubscribe,
11-
publish: pubSub.publish,
12-
getAllSubscribers: pubSub.getAllSubscribers,
13-
};
14-
};
15-
16-
export default PubSub;
3+
export default PubSubInstance;

package.json

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
11
{
2-
"name": "awesome-pubsub-js",
3-
"version": "1.1.0",
4-
"description": "JavaScript implementation of the Publish/Subscribe pattern with TypeScript support.",
5-
"main": "index.js",
6-
"scripts": {
7-
"build": "webpack --config webpack.config.ts --bail --progress",
8-
"build:package": "npm run build && cp package.json ./dist && cp README.md ./dist && cd dist && npm publish",
9-
"check-types": "tsc",
10-
"test": "jest --collectCoverage",
11-
"prettier": "prettier --check 'lib/**/*.ts' '__tests__/**/*.ts'",
12-
"prettier:fix": "prettier --write 'lib/**/*.ts' '__tests__/**/*.ts'",
13-
"lint": "eslint --ext .ts lib __tests__",
14-
"lint:fix": "npm run lint --fix"
15-
},
16-
"repository": {
17-
"type": "git",
18-
"url": "git+https://github.com/a-bugaj/awesome-pubsub-js.git"
19-
},
20-
"keywords": [],
21-
"author": "",
22-
"license": "ISC",
23-
"bugs": {
24-
"url": "https://github.com/a-bugaj/awesome-pubsub-js/issues"
25-
},
26-
"homepage": "https://github.com/a-bugaj/awesome-pubsub-js#readme",
27-
"devDependencies": {
28-
"@types/jest": "^26.0.24",
29-
"@types/node": "^16.4.1",
30-
"@types/webpack": "^5.28.0",
31-
"@typescript-eslint/eslint-plugin": "^4.28.4",
32-
"@typescript-eslint/parser": "^4.28.4",
33-
"clean-webpack-plugin": "^4.0.0-alpha.0",
34-
"eslint": "^7.31.0",
35-
"jest": "^27.0.6",
36-
"prettier": "^2.3.2",
37-
"ts-jest": "^27.0.4",
38-
"ts-loader": "^9.2.3",
39-
"ts-node": "^10.1.0",
40-
"tsconfig-paths": "^3.10.1",
41-
"typescript": "^4.3.5",
42-
"webpack-cli": "^4.7.2"
43-
}
2+
"name": "awesome-pubsub-js",
3+
"version": "1.2.0",
4+
"description": "JavaScript implementation of the Publish/Subscribe pattern with TypeScript support.",
5+
"main": "dist/index.cjs.js",
6+
"types": "dist/index.d.ts",
7+
"exports": {
8+
"import": "./dist/index.es.js",
9+
"require": "./dist/index.cjs.js"
10+
},
11+
"files": [
12+
"dist"
13+
],
14+
"scripts": {
15+
"build": "vite build",
16+
"build:package": "npm run build && cp package.json ./dist && cp README.md ./dist && cd dist && npm publish",
17+
"check-types": "tsc",
18+
"test": "jest --collectCoverage",
19+
"prettier": "prettier --check 'lib/**/*.ts' '__tests__/**/*.ts'",
20+
"prettier:fix": "prettier --write 'lib/**/*.ts' '__tests__/**/*.ts'",
21+
"lint": "eslint --ext .ts lib __tests__",
22+
"lint:fix": "npm run lint --fix"
23+
},
24+
"repository": {
25+
"type": "git",
26+
"url": "git+https://github.com/a-bugaj/awesome-pubsub-js.git"
27+
},
28+
"keywords": [],
29+
"author": "",
30+
"license": "ISC",
31+
"bugs": {
32+
"url": "https://github.com/a-bugaj/awesome-pubsub-js/issues"
33+
},
34+
"homepage": "https://github.com/a-bugaj/awesome-pubsub-js#readme",
35+
"devDependencies": {
36+
"@types/jest": "^29.5.14",
37+
"@types/node": "^22.13.1",
38+
"@typescript-eslint/eslint-plugin": "8.23.0",
39+
"@typescript-eslint/parser": "8.23.0",
40+
"eslint": "8.57.1",
41+
"eslint-config-prettier": "9.1.0",
42+
"jest": "^29.7.0",
43+
"prettier": "^3.4.2",
44+
"ts-jest": "^29.2.5",
45+
"ts-loader": "^9.5.2",
46+
"ts-node": "^10.9.2",
47+
"typescript": "^5.7.3",
48+
"vite": "^6.1.0",
49+
"vite-plugin-dts": "^4.5.0",
50+
"vite-tsconfig-paths": "5.1.4"
51+
}
4452
}

tsconfig.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
22
"compilerOptions": {
3-
"target": "ES3",
4-
"module": "commonjs",
3+
"target": "esnext",
4+
"module": "ESNext",
5+
"useDefineForClassFields": true,
6+
"lib": ["ES2020"],
7+
"allowJs": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true,
510
"sourceMap": true,
11+
"baseUrl": ".",
12+
"outDir": "dist",
13+
"resolveJsonModule": true,
14+
15+
/* Bundler mode */
16+
"moduleResolution": "node",
17+
"allowImportingTsExtensions": true,
18+
"isolatedModules": true,
19+
"moduleDetection": "force",
20+
"noEmit": true,
21+
22+
/* Linting */
623
"strict": true,
7-
"noImplicitAny": true,
8-
"strictNullChecks": true,
9-
"strictFunctionTypes": true,
10-
"strictBindCallApply": true,
11-
"strictPropertyInitialization": true,
12-
"noImplicitThis": true,
13-
"alwaysStrict": true,
1424
"noUnusedLocals": true,
1525
"noUnusedParameters": true,
16-
"noImplicitReturns": true,
1726
"noFallthroughCasesInSwitch": true,
18-
"noUncheckedIndexedAccess": true,
19-
"noImplicitOverride": true,
20-
"noPropertyAccessFromIndexSignature": true,
21-
"esModuleInterop": true,
22-
"allowSyntheticDefaultImports": true,
23-
"declaration": true,
24-
"declarationMap": true,
25-
"declarationDir": "dist",
26-
"baseUrl": ".",
27-
"outDir": "./dist"
27+
"noImplicitAny": true
2828
},
2929
"include": ["./lib/**/*"],
3030
"exclude": ["./__tests__", "./webpack.config.ts"]

vite.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig } from "vite";
2+
import path from "path";
3+
import dts from "vite-plugin-dts";
4+
5+
export default defineConfig({
6+
build: {
7+
lib: {
8+
entry: path.resolve(__dirname, "lib/index.ts"),
9+
name: "pubsub",
10+
fileName: (format) => `index.${format}.js`,
11+
formats: ["es", "cjs"],
12+
},
13+
rollupOptions: {
14+
external: [],
15+
},
16+
sourcemap: false,
17+
emptyOutDir: true,
18+
},
19+
plugins: [
20+
dts({
21+
rollupTypes: true,
22+
insertTypesEntry: true,
23+
}),
24+
],
25+
});

webpack.config.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)