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

Build runtime packages for ESM + CJS #259

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ jobs:
- setup-node
- run: npm run prettier-check

ESLint:
docker:
- image: cimg/base:stable
steps:
- setup-node
- run: npm run lint

workflows:
version: 2
Build:
Expand All @@ -82,3 +89,4 @@ workflows:
- GraphQL v14 - backcompat
- GraphQL v15 - backcompat
- Prettier
- ESLint
16 changes: 16 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import"],
extends: ["plugin:import/typescript"],
overrides: [
{
// Enable import/extensions on all TS files because our ESM builds require
// you to specify local imports as full paths with extensions. We don't
// need this on tests because Jest doesn't require it.
files: ["**/*.ts"],
excludedFiles: "**/__tests__/**/*.ts",
rules: { "import/extensions": ["error", "ignorePackages"] },
},
],
};
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md)
5. Copy the following files from a neighbor package and adjust appropriately (if necessary):

- `.npmignore`
- `jest.config.ts`
- `jest.config.js`
- `LICENSE`
- `tsconfig.json`
- `src/__tests__/tsconfig.json`

# TODO - add notes about ESM/CJS config and type-only vs runtime packages
24 changes: 24 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defaults } from "jest-config";

export default {
testEnvironment: "node",
preset: "ts-jest",
testMatch: null,
testRegex: "/__tests__/.*\\.test\\.(js|ts)$",
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
moduleFileExtensions: [...defaults.moduleFileExtensions, "ts", "tsx"],
clearMocks: true,
transform: {
"^.+\\.test.ts$": [
"ts-jest",
{
tsconfig: "<rootDir>/src/__tests__/tsconfig.json",
diagnostics: true,
},
],
},
moduleNameMapper: {
// Ignore '.js' at the end of imports; part of ESM support.
"^(\\.{1,2}/.*)\\.js$": "$1",
},
};
15 changes: 0 additions & 15 deletions jest.config.base.ts

This file was deleted.

6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('@jest/types').Config.InitialOptions}
*/
export default {
projects: ["<rootDir>/packages/*/jest.config.js"],
};
7 changes: 0 additions & 7 deletions jest.config.ts

This file was deleted.

Loading