Skip to content

Commit

Permalink
♻️ refactor: migrate project to esm (#62)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* chore: fix codegen

* chore: fix tests

* chore: revert unintended additions

* chore: lint

* chore: remove casting

* chore: lint

* chore: lint
  • Loading branch information
larwaa authored Jul 15, 2023
1 parent e6c85f1 commit 67790c2
Show file tree
Hide file tree
Showing 51 changed files with 8,723 additions and 5,022 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ env:
node: true

ignorePatterns:
- "src/graphql/generated"
- "src/graphql/__types__.ts"
- dist

plugins:
Expand Down Expand Up @@ -45,7 +45,7 @@ overrides:
rules:
"@graphql-eslint/known-type-names": error
parserOptions:
schema: src/graphql/generated/schema.graphql
schema: schema.graphql

rules:
import/no-extraneous-dependencies:
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/graphql/generated
src/graphql/__types__.ts
6 changes: 1 addition & 5 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"module": {
"type": "commonjs"
"type": "es6"
},
"jsc": {
"target": "es2022",
Expand All @@ -11,10 +11,6 @@
"decorators": true
},

"transform": {
"decoratorMetadata": true
},

"paths": {
"@/*": ["./src/*"]
},
Expand Down
14 changes: 8 additions & 6 deletions codegen.config.ts → codegen.config.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { CodegenConfig } from "@graphql-codegen/cli";
// @ts-check

const config: CodegenConfig = {
/** @type {import("@graphql-codegen/cli").CodegenConfig} */
const config = {
overwrite: true,
schema: "src/graphql/type-defs.ts",
schema: "./src/graphql/type-defs.ts",
emitLegacyCommonJSImports: false,
generates: {
"src/graphql/generated/types.ts": {
"src/graphql/__types__.ts": {
config: {
useIndexSignature: true,
showUnusedMappers: true,
Expand All @@ -27,10 +29,10 @@ const config: CodegenConfig = {
},
plugins: ["typescript", "typescript-resolvers"],
},
"src/graphql/generated/schema.graphql": {
"schema.graphql": {
plugins: ["schema-ast"],
},
},
};

export default config;
module.exports = config;
14 changes: 11 additions & 3 deletions jest.config.ts → jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* https://jestjs.io/docs/configuration
*/

export default {
preset: "ts-jest",
module.exports = {
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

Expand All @@ -22,8 +21,17 @@ export default {

modulePathIgnorePatterns: ["<rootDir>/dist/"],

extensionsToTreatAsEsm: [".ts"],

// https://github.com/swc-project/jest/issues/64
// imports with .js extension fails
// this is a workaround
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},

// A map from regular expressions to paths to transformers
transform: {
"^.+\\.(t|j)sx?$": ["@swc/jest"],
"^.+\\.(t|j)sx?$": "@swc/jest",
},
};
4 changes: 2 additions & 2 deletions jest.integration.config.ts → jest.integration.config.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import base from "./jest.config";
const base = require("./jest.config.cjs");
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

export default {
module.exports = {
...base,
testMatch: ["**/__tests__/integration/**/*.test.ts", "**/?(*.)+integration.test.ts"],
coverageDirectory: "coverage/integration",
Expand Down
Loading

0 comments on commit 67790c2

Please sign in to comment.