Skip to content
This repository has been archived by the owner on Mar 7, 2022. It is now read-only.

Commit

Permalink
build: use esbuild to generate esm+cjs output (#6)
Browse files Browse the repository at this point in the history
* feat: esbuild to generate esm+cjs output

* fix: package.json setup

* fix: missing build.js

* fix: package.json formatting

* fix: merge conflicts

* fix: build.js tab -> spaces
  • Loading branch information
ndom91 committed Jun 9, 2021
1 parent 3deb10c commit 77e56c8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
node_modules
node_modules
dist
29 changes: 29 additions & 0 deletions build.js
@@ -0,0 +1,29 @@
const build = require("esbuild");

build
.build({
entryPoints: ["index.js"],
bundle: true,
minify: true,
loader: {
".js": "ts"
},
format: "esm",
external: ["react", "react-dom"],
outfile: "dist/index.mjs"
})
.catch(() => process.exit(1));

build
.build({
entryPoints: ["index.js"],
bundle: true,
minify: true,
loader: {
".js": "ts"
},
format: "cjs",
external: ["react", "react-dom"],
outfile: "dist/index.js"
})
.catch(() => process.exit(1));
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions package.json
Expand Up @@ -10,23 +10,27 @@
"license": "ISC",
"version": "0.0.6",
"description": "React Query wrapper for NextAuth.js session management",
"main": "index.js",
"types": "./index.d.ts",
"type": "commonjs",
"keywords": [
"next-auth",
"react-query"
],
"main": "dist/index.js",
"exports": {
".": {
"import": "./index.js",
"default": "./index.js"
"require": "dist/index.js",
"default": "dist/index.mjs"
}
},
"module": "dist/index.mjs",
"types": "./index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.js",
"dist/*"
],
"scripts": {
"build": "node build.js",
"test:ci": "npm run lint",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
Expand All @@ -38,6 +42,7 @@
"react-query": "^3.13.11"
},
"devDependencies": {
"esbuild": "^0.12.6",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"next": "^10.0.3",
Expand All @@ -48,19 +53,19 @@
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"eslint:recommended",
"prettier"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"ignorePatterns": [
"node_modules",
"index.d.ts"
],
"globals": {
"fetch": "readonly"
}
"globals": {
"fetch": "readonly"
}
}
}

0 comments on commit 77e56c8

Please sign in to comment.