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

Provide a CJS build #13

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@
"license": "MIT",
"author": "Robin Löffel (https://robinloeffel.ch) <[email protected]>",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
},
"files": [
"src",
"dist"
],
"scripts": {
"build": "rm -rf dist && tsc --project tsconfig.build.json",
"build": "rm -rf dist && concurrently npm:build:*",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"build:types": "tsc --project tsconfig.types.json",
"prepack": "npm run build",
"start": "npm run watch",
"watch": "concurrently npm:watch:*",
Expand Down
2 changes: 1 addition & 1 deletion test/esbuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build } from "esbuild";
import eslint from "../dist/index.js";
import eslint from "../dist/esm/index.js";

const absolute = relative => new URL(relative, import.meta.url).pathname;

Expand Down
15 changes: 15 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "./dist/cjs",

// Enable CJS output
"module": "CommonJS",
"moduleResolution": "Node",

// verbatimModuleSyntax doesn't transform import to require
"verbatimModuleSyntax": false
},
"include": ["./src"]
}
8 changes: 8 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "./dist/esm"
},
"include": ["./src"]
}
7 changes: 3 additions & 4 deletions tsconfig.build.json → tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"compilerOptions": {
"noEmit": false,
"declaration": true,
"outDir": "./dist"
"emitDeclarationOnly": true,
"outDir": "./dist/types"
},
"include": [
"./src"
]
"include": ["./src"]
}