Skip to content

Commit

Permalink
Use ESNext as default module system
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops committed Aug 6, 2023
1 parent 7694b50 commit 8350b53
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 41 deletions.
15 changes: 4 additions & 11 deletions jest.config.ts
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",
},
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
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",
"strict": true,
"noEmitOnError": true
},
"exclude": ["./test", "./build/typings"]
}
}
13 changes: 0 additions & 13 deletions tsconfig.test.json

This file was deleted.

0 comments on commit 8350b53

Please sign in to comment.