Skip to content

Commit 03a9ffe

Browse files
committed
[javascript] Add es modules build
1 parent 484d8e0 commit 03a9ffe

13 files changed

+1542
-2835
lines changed

javascript/.eslintrc.js

-87
This file was deleted.

javascript/.prettierrc.js

-4
This file was deleted.

javascript/.prettierrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"trailingComma": "es5",
3+
"printWidth": 90
4+
}

javascript/eslint.config.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import js from "@eslint/js";
2+
import typescriptParser from "@typescript-eslint/parser";
3+
import eslintPluginTypescriptEslint from "@typescript-eslint/eslint-plugin";
4+
import eslintConfigPrettier from "eslint-config-prettier";
5+
import globals from "globals";
6+
7+
export default [
8+
js.configs.recommended,
9+
eslintConfigPrettier,
10+
{
11+
files: ["src/**/*.ts"],
12+
languageOptions: {
13+
parser: typescriptParser,
14+
globals: {
15+
...globals.browser,
16+
},
17+
},
18+
plugins: { "@typescript-eslint": eslintPluginTypescriptEslint },
19+
rules: {
20+
"@typescript-eslint/explicit-function-return-type": "off",
21+
"@typescript-eslint/no-use-before-define": "off",
22+
"@typescript-eslint/no-non-null-assertion": "off",
23+
"@typescript-eslint/no-explicit-any": "off",
24+
"@typescript-eslint/explicit-module-boundary-types": "off",
25+
"@typescript-eslint/member-delimiter-style": [
26+
"error",
27+
{
28+
multiline: {
29+
delimiter: "semi",
30+
requireLast: true,
31+
},
32+
singleline: {
33+
delimiter: "semi",
34+
requireLast: false,
35+
},
36+
},
37+
],
38+
"@typescript-eslint/no-unused-vars": [
39+
"warn",
40+
{
41+
vars: "all",
42+
args: "all",
43+
ignoreRestSiblings: true,
44+
argsIgnorePattern: "^_",
45+
},
46+
],
47+
48+
quotes: "off",
49+
"@typescript-eslint/quotes": [
50+
"error",
51+
"double",
52+
{ allowTemplateLiterals: true, avoidEscape: true },
53+
],
54+
semi: "off",
55+
"@typescript-eslint/semi": ["error", "always", { omitLastInOneLineBlock: true }],
56+
"comma-dangle": [
57+
"error",
58+
{
59+
arrays: "always-multiline",
60+
objects: "always-multiline",
61+
imports: "always-multiline",
62+
exports: "always-multiline",
63+
functions: "never",
64+
},
65+
],
66+
"comma-spacing": ["error"],
67+
eqeqeq: ["error", "smart"],
68+
indent: "off",
69+
"@typescript-eslint/indent": 0,
70+
"no-multi-spaces": "error",
71+
"object-curly-spacing": ["error", "always"],
72+
"arrow-parens": "error",
73+
"arrow-spacing": "error",
74+
"key-spacing": "error",
75+
"keyword-spacing": "error",
76+
"func-call-spacing": "off",
77+
"@typescript-eslint/func-call-spacing": ["error"],
78+
"space-before-function-paren": [
79+
"error",
80+
{
81+
anonymous: "always",
82+
named: "never",
83+
asyncArrow: "always",
84+
},
85+
],
86+
"space-in-parens": ["error", "never"],
87+
"space-before-blocks": "error",
88+
curly: ["error", "all"],
89+
"space-infix-ops": "error",
90+
"consistent-return": "error",
91+
"jsx-quotes": ["error"],
92+
"array-bracket-spacing": "error",
93+
"brace-style": "off",
94+
"@typescript-eslint/brace-style": ["error", "1tbs", { allowSingleLine: true }],
95+
"no-useless-constructor": "off",
96+
"@typescript-eslint/no-useless-constructor": "warn",
97+
},
98+
},
99+
{
100+
ignores: ["eslint.config.js", "dist/**/*", "**/.*", "src/openapi/*"],
101+
},
102+
];

javascript/jest.config.js

-4
This file was deleted.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"npmName": "svix",
33
"useObjectParameters": true,
4-
"supportsES6": true
4+
"supportsES6": true,
5+
"platform": "browser"
56
}

javascript/package.json

+25-19
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,52 @@
44
"description": "Svix webhooks API client and webhook verification library",
55
"author": "svix",
66
"repository": "https://github.com/svix/svix-libs",
7-
"type": "commonjs",
7+
"type": "module",
88
"keywords": [
99
"svix",
1010
"diahook",
1111
"webhooks",
1212
"typescript"
1313
],
1414
"license": "MIT",
15-
"main": "./dist/index.js",
15+
"main": "./dist/index.cjs",
16+
"module": "./dist/index.js",
1617
"typings": "./dist/index.d.ts",
18+
"exports": {
19+
".": {
20+
"import": "./dist/index.js",
21+
"require": "./dist/index.cjs"
22+
}
23+
},
1724
"files": [
1825
"dist/**/*"
1926
],
27+
"sideEffects": false,
2028
"scripts": {
21-
"build": "tsc",
29+
"build": "tsup src/index.ts",
2230
"prepare": "yarn run build",
23-
"test": "jest",
31+
"test": "vitest run",
2432
"prepublishOnly": "yarn lint",
25-
"lint:eslint": "eslint --ignore-path .lintignore --ext .js,.jsx,.ts,.tsx src",
33+
"lint:eslint": "eslint .",
2634
"lint:prettier": "prettier --ignore-path .lintignore --write src/**.ts",
2735
"lint": "yarn run lint:prettier && yarn run lint:eslint --max-warnings=0",
2836
"lint:fix": "yarn run lint:prettier --write && yarn run lint:eslint --fix"
2937
},
3038
"dependencies": {
31-
"@stablelib/base64": "^1.0.0",
32-
"es6-promise": "^4.2.4",
39+
"js-base64": "^3.7.6",
3340
"fast-sha256": "^1.3.0",
34-
"svix-fetch": "^3.0.0",
35-
"url-parse": "^1.4.3"
41+
"svix-fetch": "^3.0.0"
3642
},
3743
"devDependencies": {
38-
"@stablelib/utf8": "^1.0.1",
39-
"@types/jest": "^26.0.23",
40-
"@typescript-eslint/eslint-plugin": "^4.15.2",
41-
"@typescript-eslint/parser": "^4.15.2",
42-
"@typescript-eslint/typescript-estree": "^4.15.2",
43-
"eslint": "^7.20.0",
44-
"jest": "^27.0.4",
45-
"prettier": "^2.2.1",
46-
"ts-jest": "^27.0.3",
47-
"typescript": "^3.9.3"
44+
"@types/node": "^20.11.10",
45+
"@typescript-eslint/eslint-plugin": "^6.19.1",
46+
"@typescript-eslint/parser": "^6.19.1",
47+
"eslint": "^8.56.0",
48+
"eslint-config-prettier": "^9.1.0",
49+
"globals": "^13.24.0",
50+
"prettier": "^3.2.4",
51+
"tsup": "^8.0.1",
52+
"typescript": "^5.3.3",
53+
"vitest": "^1.2.1"
4854
}
4955
}

0 commit comments

Comments
 (0)