Skip to content

Commit d3e87c2

Browse files
committed
chore: Use tsdx instead of plain rollup
1 parent a87f640 commit d3e87c2

File tree

6 files changed

+4095
-1731
lines changed

6 files changed

+4095
-1731
lines changed

__tests__/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { proxy } from "../src/proxy";
1+
import { proxy } from "../src";
22

33
describe("proxy", () => {
44
it("wraps URL that may required proxy", () => {

package.json

+20-36
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
"proxy",
99
"typescript"
1010
],
11-
"main": "dist/proxy.es5.js",
12-
"module": "dist/proxy.esm.js",
13-
"typings": "dist/proxy.d.ts",
14-
"sideEffects": false,
11+
"main": "dist/index.js",
12+
"typings": "dist/index.d.ts",
13+
"module": "dist/index.esm.js",
1514
"files": [
16-
"dist"
15+
"dist",
16+
"src"
1717
],
18+
"engines": {
19+
"node": ">=12"
20+
},
21+
"sideEffects": false,
1822
"author": "Patricio López Juri <[email protected]>",
1923
"repository": {
2024
"type": "git",
@@ -23,12 +27,13 @@
2327
"license": "MIT",
2428
"private": false,
2529
"scripts": {
26-
"prebuild": "rimraf dist",
27-
"build": "rollup -c rollup.config.ts",
28-
"prepublishOnly": "yarn run build",
29-
"start": "rollup -c rollup.config.ts -w",
30+
"start": "tsdx watch",
31+
"build": "tsdx build",
32+
"test": "tsdx test",
3033
"lint": "eslint '*/**/*.{js,ts,tsx}'",
31-
"test": "jest"
34+
"prepare": "tsdx build",
35+
"size": "size-limit",
36+
"analyze": "size-limit --why"
3237
},
3338
"husky": {
3439
"hooks": {
@@ -43,37 +48,16 @@
4348
"dependencies": {},
4449
"peerDependencies": {},
4550
"devDependencies": {
46-
"@flyyer/eslint-config": "^2.0.0",
47-
"@types/jest": "^27.0.1",
51+
"@flyyer/eslint-config": "^2.1.1",
52+
"babel-jest": "^27.2.0",
4853
"eslint": "^7.32.0",
54+
"eslint-plugin-jest": "^24.4.0",
4955
"husky": "^4.3",
50-
"jest": "^27.2.0",
5156
"lint-staged": "^11.1.2",
5257
"prettier": "^2.4.0",
53-
"rollup": "^2.56.3",
54-
"rollup-plugin-commonjs": "^10.1.0",
55-
"rollup-plugin-json": "^4.0.0",
56-
"rollup-plugin-node-resolve": "^5.2.0",
57-
"rollup-plugin-sourcemaps": "^0.6.3",
58-
"rollup-plugin-typescript2": "^0.30.0",
5958
"ts-jest": "^27.0.5",
60-
"ts-node": "^10.2.1",
59+
"tsdx": "^0.14.1",
60+
"tslib": "^2.3.1",
6161
"typescript": "^4.4.3"
62-
},
63-
"jest": {
64-
"transform": {
65-
".(ts|tsx)": "ts-jest"
66-
},
67-
"testEnvironment": "jsdom",
68-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
69-
"moduleFileExtensions": [
70-
"ts",
71-
"tsx",
72-
"js"
73-
],
74-
"coveragePathIgnorePatterns": [
75-
"/node_modules/",
76-
"/test/"
77-
]
7862
}
7963
}

rollup.config.ts

-39
This file was deleted.

src/proxy.ts renamed to src/index.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* https://stackoverflow.com/a/61934195/3416691
3+
*/
4+
export const FORCE_HTTPS = (url: string) =>
5+
url.replace(/^(?:(.*:)?\/\/)?(.*)/i, (match, schema, nonSchemaURL) => (schema ? match : `https://${nonSchemaURL}`));
6+
7+
/**
8+
* https://stackoverflow.com/a/19709846/3416691
9+
*/
10+
export const EXTERNAL_URL_REGEX = new RegExp("^(?:[a-z]+:)?//", "i");
11+
112
/**
213
* Returns an URL to proxy request via flyyer network.
314
*
@@ -34,14 +45,3 @@ export function proxy(src: string): string {
3445
return src;
3546
}
3647
}
37-
38-
/**
39-
* https://stackoverflow.com/a/61934195/3416691
40-
*/
41-
export const FORCE_HTTPS = (url: string) =>
42-
url.replace(/^(?:(.*:)?\/\/)?(.*)/i, (match, schema, nonSchemaURL) => (schema ? match : `https://${nonSchemaURL}`));
43-
44-
/**
45-
* https://stackoverflow.com/a/19709846/3416691
46-
*/
47-
export const EXTERNAL_URL_REGEX = new RegExp("^(?:[a-z]+:)?//", "i");

tsconfig.json

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
{
2+
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
3+
"include": ["src", "types"],
24
"compilerOptions": {
3-
"moduleResolution": "node",
4-
"target": "es5",
5-
"module":"es2015",
6-
"alwaysStrict": true,
5+
"module": "esnext",
6+
"lib": ["dom", "esnext"],
7+
"importHelpers": true,
8+
// output .d.ts declaration files for consumers
9+
"declaration": true,
10+
// output .js.map sourcemap files for consumers
11+
"sourceMap": true,
12+
// match output dir to input dir. e.g. dist/index instead of dist/src/index
13+
"rootDir": "./src",
14+
// stricter type-checking for stronger correctness. Recommended by TS
715
"strict": true,
8-
"strictNullChecks": true,
9-
"strictPropertyInitialization": true,
10-
"strictFunctionTypes": true,
11-
"strictBindCallApply": true,
12-
"noImplicitAny": true,
13-
"noImplicitThis": true,
14-
"noUncheckedIndexedAccess": true,
15-
"noFallthroughCasesInSwitch": true,
16+
// linter checks for common issues
1617
"noImplicitReturns": true,
17-
"preserveConstEnums": true,
18-
"sourceMap": true,
19-
"declaration": true,
20-
"allowSyntheticDefaultImports": true,
21-
"declarationDir": "dist/types",
22-
"outDir": "dist/lib",
23-
"typeRoots": [
24-
"node_modules/@types", "types"
25-
],
26-
},
27-
"include": ["types/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx"]
18+
"noFallthroughCasesInSwitch": true,
19+
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
// use Node's module resolution algorithm, instead of the legacy TS one
23+
"moduleResolution": "node",
24+
// transpile JSX to React.createElement
25+
"jsx": "react",
26+
// interop between ESM and CJS modules. Recommended by TS
27+
"esModuleInterop": true,
28+
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
29+
"skipLibCheck": true,
30+
// error out if import and file system have a casing mismatch. Recommended by TS
31+
"forceConsistentCasingInFileNames": true,
32+
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
33+
"noEmit": true,
34+
}
2835
}

0 commit comments

Comments
 (0)