Skip to content

Commit

Permalink
chore(build): Use ES Module for config files
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Jul 27, 2023
1 parent 4fbfde0 commit d9806ed
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 72 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
"plugin:prettier/recommended"
],
"plugins": ["import", "simple-import-sort"],
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"env": {
"browser": true,
"node": true
Expand All @@ -32,6 +27,11 @@
"plugin:import/typescript",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/explicit-member-accessibility": [
Expand Down
30 changes: 0 additions & 30 deletions jest.config.cjs

This file was deleted.

30 changes: 30 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
projects: [
{
displayName: "unit",
testEnvironment: "node",
testMatch: ["<rootDir>/src/**/*.spec.ts"],
transform: { "^.+\\.tsx?$": "ts-jest" },
},
{
displayName: "e2e",
testEnvironment: "./test-utils/jest-environment.ts",
testMatch: ["<rootDir>/tests/**/*.spec.ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: {
target: "esnext",
module: "esnext",
},
},
],
},
globalSetup: "<rootDir>/test-utils/jest-global-setup.ts",
setupFilesAfterEnv: ["<rootDir>/test-utils/jest-setup-after-env.ts"],
},
],
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.spec.ts", "!**/__mocks__/**"],
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"scripts": {
"test": "npm-run-all test:*",
"test:unit": "jest --coverage --config=jest.config.cjs --selectProjects unit",
"test:e2e": "jest --coverage --config=jest.config.cjs --selectProjects e2e",
"test:unit": "jest --coverage --config=jest.config.js --selectProjects unit",
"test:e2e": "jest --coverage --config=jest.config.js --selectProjects e2e",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint --ext ts --report-unused-disable-directives --cache '{src,tests,test-utils}/**/*'",
"lint:spellcheck": "cspell '{src,test,test-utils}/**/*.{ts,tsx,js,json,md}'",
"build": "rollup -c rollup.config.cjs",
"build": "rollup -c rollup.config.js",
"prepublishOnly": "yarn run build",
"docs:build": "typedoc ./src/index.ts && touch ./docs/.nojekyll",
"purge:cache": "rm -rf ./node_modules/.cache/masto"
Expand Down
34 changes: 0 additions & 34 deletions rollup.config.cjs

This file was deleted.

35 changes: 35 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import autoExternal from "rollup-plugin-auto-external";
import dts from "rollup-plugin-dts";
import typescript from "rollup-plugin-typescript2";

import packageJSON from "./package.json" assert { type: "json" };

/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: "./src/index.ts",
output: {
file: packageJSON.exports["."].require,
format: "cjs",
},
plugins: [json(), typescript(), autoExternal()],
},
{
input: "./src/index.ts",
output: {
file: packageJSON.exports["."].import,
format: "esm",
},
plugins: [commonjs(), json(), typescript(), autoExternal()],
},
{
input: "./src/index.ts",
output: {
file: packageJSON.exports["."].types,
format: "esm",
},
plugins: [dts()],
},
];
1 change: 1 addition & 0 deletions test-utils/jest-setup-after-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./jest-extend-expect";
import { createRestClient } from "../src";
import { SessionPoolImpl } from "./pools";

jest.retryTimes(3);
jest.setTimeout(1000 * 60);

globalThis.admin = createRestClient({
Expand Down

0 comments on commit d9806ed

Please sign in to comment.