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

Use ESNext as default module system #188

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 4 additions & 11 deletions jest.config.ts
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { type JestConfigWithTsJest } from "ts-jest";

const jestConfig: JestConfigWithTsJest = {
rootDir: "./",
moduleFileExtensions: ["ts", "js"],
preset: "ts-jest/presets/default-esm",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved
testMatch: ["**/test/**/*.test.ts", "**/test/tests.ts"],
coverageProvider: "v8",
coveragePathIgnorePatterns: ["/node_modules/", "./test"],
extensionsToTreatAsEsm: [".ts"],
reporters: [
"default",
["jest-junit", { outputDirectory: "test-results/jest" }],
],
coverageReporters: ["lcov", "text", "text-summary"],
setupFiles: [],
preset: "ts-jest/presets/default-esm",
transform: {
"^.+\\.ts?$": [
"ts-jest",
{ useESM: true, tsconfig: "./tsconfig.test.json" },
],
},
};

export default jestConfig;
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { base64UrlDecode } from "./base64-url-decode";
import { base64UrlDecode } from "./base64-url-decode.js";

export interface JwtDecodeOptions {
header?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/index.umd.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { jwtDecode as default } from "./index";
export { jwtDecode as default } from "./index.js";
5 changes: 1 addition & 4 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import livereload from "rollup-plugin-livereload";
import serve from "rollup-plugin-serve";

const isProduction = process.env.NODE_ENV === "production";
const tsPlugin = typescript({
rootDir: "lib",
sourceMap: true,
});
const tsPlugin = typescript({ tsconfig: "tsconfig.build.json" });

const plugins = [
tsPlugin,
Expand Down
2 changes: 1 addition & 1 deletion test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { jwtDecode, InvalidTokenError, JwtPayload } from "./../lib/index";
import { jwtDecode, InvalidTokenError, JwtPayload } from "./../lib/index.js";
import { describe, expect, it } from "@jest/globals";

const token =
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2017",
"rootDir": "./lib",
"sourceMap": true
}
}
14 changes: 4 additions & 10 deletions tsconfig.json
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"compilerOptions": {
"target": "ES2017",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"sourceMap": false,
"moduleResolution": "node",
"noImplicitAny": true,
"downlevelIteration": true,
"noImplicitThis": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved
"strict": true,
"noEmitOnError": true
},
"exclude": ["./test", "./build/typings"]
}
}
13 changes: 0 additions & 13 deletions tsconfig.test.json
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.