Skip to content

Commit

Permalink
Merge pull request #305 from remarkablemark/build/esm
Browse files Browse the repository at this point in the history
fix(package): fix "module" field in package.json
  • Loading branch information
remarkablemark authored Jul 18, 2023
2 parents 00c4588 + efc54f8 commit d66fe71
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: npm run test:ci

- name: Run module tests
run: npm run test:module
run: npm run test:esm

- name: Codecov
uses: codecov/codecov-action@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ jspm_packages
.node_repl_history

# Build files
cjs/
docs/
lib/
esm/

# Vim swap files
*.swp
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

npm run lint:tsc
npm run test:ci
npm run test:esm
npx lint-staged
1 change: 0 additions & 1 deletion module/index.mjs

This file was deleted.

27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@
"version": "2.2.1",
"description": "Track users, send messages, export data, and more with Braze API.",
"author": "Mark <mark@remarkablemark.org>",
"main": "lib/index.js",
"module": "index.mjs",
"main": "cjs/index.js",
"module": "esm/index.js",
"exports": {
"types": "./lib/index.d.ts",
"import": "./module/index.mjs",
"require": "./lib/index.js"
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"scripts": {
"build": "tsc --project tsconfig.build.json",
"clean": "rm -rf coverage docs lib",
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc",
"build:esm": "tsc --module nodenext --outDir esm",
"clean": "rm -rf cjs coverage docs esm",
"docs": "typedoc",
"docs:watch": "npm run docs -- --watch",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts .",
"lint": "eslint --ignore-path .gitignore --ext .js,.mjs,.ts .",
"lint:fix": "npm run lint -- --fix",
"lint:tsc": "tsc && tsc --project tsconfig.test.json",
"lint:tsc": "tsc --noEmit && tsc --project tsconfig.test.json",
"postinstall": "husky install",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable && npm run lint && npm run lint:tsc && npm run test:ci && npm run clean && npm run build",
"prepublishOnly": "pinst --disable && npm run lint && npm run lint:tsc && npm run test:ci && npm run test:esm && npm run clean && npm run build",
"test": "jest",
"test:ci": "CI=true jest --ci --colors --coverage",
"test:module": "npm run build && node --test module",
"test:esm": "npm run build:esm && node --test src",
"test:watch": "jest --watch"
},
"repository": {
Expand Down Expand Up @@ -64,8 +65,8 @@
"typescript": "5.1.6"
},
"files": [
"lib/",
"module/"
"cjs/",
"esm/"
],
"engines": {
"node": ">=14"
Expand Down
2 changes: 1 addition & 1 deletion module/index.test.mjs → src/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it } from 'node:test'

import assert from 'assert'

import { Braze } from './index.mjs'
import { Braze } from '../esm/index.js'

describe('index', () => {
it('exports "Braze" class', () => {
Expand Down
7 changes: 0 additions & 7 deletions tsconfig.build.json

This file was deleted.

5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"outDir": "lib",
"noEmit": true
"outDir": "cjs"
},
"include": ["src"],
"exclude": ["**/*.test.ts"]
"exclude": ["node_modules", "**/*.test.ts"]
}
3 changes: 2 additions & 1 deletion tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": ["es2020", "dom"]
"lib": ["es2020", "dom"],
"noEmit": true
},
"include": ["**/*.test.ts"],
"exclude": []
Expand Down

0 comments on commit d66fe71

Please sign in to comment.