Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

Commit b4afed7

Browse files
committed
chore: publish commonjs and es6 (modules) files
Node.js (non-web) tooling generally prefers CommonJS, and web tooling (e.g., parcel-bundler) generally works better with ES6 modules (for tree shaking). The paths for ES6 modules are `cxp/module/...` (`cxp/lib/...` is for CommonJS).
1 parent 288d170 commit b4afed7

8 files changed

+118
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ coverage/
44
.nyc_output/
55
dist
66
.cache/
7+
/module/

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ script:
1414
- npm run prettier
1515
- npm run tslint
1616
- npm run build
17-
- npm run build:all
17+
- npm run typecheck
1818
- npm run cover
1919
- ./node_modules/.bin/nyc report --reporter json
2020
- bash <(curl -s https://codecov.io/bash)

.vscode/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"tasks": [
44
{
55
"type": "npm",
6-
"script": "watch",
6+
"script": "watch:typecheck",
77
"problemMatcher": ["$tsc-watch"],
88
"isBackground": true
99
},

package-lock.json

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,26 @@
1212
"url": "https://github.com/sourcegraph/cxp-js/issues"
1313
},
1414
"main": "lib/index.js",
15+
"module": "module/index.js",
1516
"files": [
16-
"lib"
17+
"lib",
18+
"module"
1719
],
1820
"scripts": {
1921
"commitmsg": "commitlint -e $GIT_PARAMS",
2022
"semantic-release": "semantic-release",
2123
"prettier": "prettier '**/*.{js?(on),ts}' --write --list-different",
2224
"tslint": "tslint -c tslint.json -p tsconfig.json './src/**/*.ts'",
23-
"build": "tsc -p tsconfig.dist.json",
24-
"build:all": "tsc -p tsconfig.json",
25+
"typecheck": "tsc -p tsconfig.json",
26+
"build:commonjs": "tsc -p tsconfig.dist.commonjs.json",
27+
"build:module": "tsc -p tsconfig.dist.module.json",
28+
"build": "tsc -p tsconfig.dist.commonjs.json && tsc -p tsconfig.dist.module.json",
2529
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha --require ts-node/register --require source-map-support/register --opts mocha.opts",
2630
"cover": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --require ts-node/register --require source-map-support/register --all mocha --opts mocha.opts --timeout 10000",
27-
"watch": "tsc -p tsconfig.json -w",
28-
"watch:build": "tsc -p tsconfig.dist.json -w",
31+
"watch:typecheck": "tsc -p tsconfig.json -w",
32+
"watch:build:commonjs": "tsc -p tsconfig.dist.commonjs.json -w",
33+
"watch:build:module": "tsc -p tsconfig.dist.module.json -w",
34+
"watch:build": "concurrently --kill-others 'npm:watch:build:*'",
2935
"watch:test": "npm run test -- -w",
3036
"watch:cover": "nodemon --watch src/ --ext ts,js,json --watch package.json --exec 'npm run cover || exit 1'"
3137
},
@@ -68,6 +74,7 @@
6874
"@types/node": "^10.5.0",
6975
"@types/uuid": "^3.4.3",
7076
"@types/ws": "^5.1.2",
77+
"concurrently": "^3.6.0",
7178
"husky": "^0.14.3",
7279
"mocha": "^5.2.0",
7380
"nodemon": "^1.18.2",

tsconfig.dist.commonjs.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.dist.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "lib"
6+
}
7+
}

tsconfig.dist.module.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.dist.json",
3+
"compilerOptions": {
4+
"module": "es6",
5+
"outDir": "module"
6+
}
7+
}

tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
"extends": "./node_modules/@sourcegraph/tsconfig/tsconfig.json",
33
"compilerOptions": {
44
"target": "es2018",
5-
"module": "es2015",
5+
"module": "es6",
66
"moduleResolution": "node",
77
"sourceMap": true,
88
"declaration": true,
9-
"outDir": "lib",
109
"noEmit": true,
1110
"lib": ["es2018"],
1211
"sourceRoot": "src",

0 commit comments

Comments
 (0)