Skip to content

Commit

Permalink
Revamp bundling and testing strategies.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Jun 27, 2019
1 parent bb5ef44 commit 3fb0342
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -41,3 +41,6 @@ lib

# Cache directory for rollup-plugin-typescript2
.rpt2_cache

# Cache directory for Reify-compiled tests
.reify-cache
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -3,6 +3,7 @@
/lib/tests
.travis.yml
.rpt2_cache
.reify-cache
tsconfig.json
tsconfig.rollup.json
rollup.config.js
31 changes: 28 additions & 3 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -14,7 +14,7 @@
"tracker",
"memoization"
],
"main": "lib/index.js",
"main": "lib/bundle.cjs.js",
"module": "lib/bundle.esm.js",
"types": "lib/index.d.ts",
"license": "MIT",
Expand All @@ -27,9 +27,9 @@
"url": "https://github.com/benjamn/optimism/issues"
},
"scripts": {
"build": "npm run clean && tsc && rollup -c",
"build": "npm run clean && tsc --emitDeclarationOnly && rollup -c",
"clean": "rimraf lib",
"mocha": "mocha --require source-map-support/register --reporter spec --full-trace lib/tests/index",
"mocha": "mocha --require source-map-support/register --reporter spec --full-trace test.js",
"prepublish": "npm run build",
"test": "npm run build && npm run mocha"
},
Expand All @@ -38,10 +38,12 @@
"@types/node": "12.0.10",
"fibers": "4.0.1",
"mocha": "6.1.4",
"reify": "0.20.6",
"rimraf": "2.6.3",
"rollup": "1.16.2",
"rollup-plugin-typescript2": "0.21.2",
"source-map-support": "0.5.12",
"tslib": "1.10.0",
"typescript": "3.5.2"
},
"dependencies": {
Expand Down
14 changes: 12 additions & 2 deletions rollup.config.js
Expand Up @@ -38,9 +38,19 @@ export default [
"lib/bundle.esm.js",
"esm"
),
build(
"src/index.ts",
"lib/bundle.cjs.js",
"cjs"
),
build(
"src/tests/main.ts",
"lib/tests/bundle.js",
"lib/tests/bundle.esm.js",
"esm"
),
build(
"src/tests/main.ts",
"lib/tests/bundle.cjs.js",
"cjs"
)
),
];
7 changes: 0 additions & 7 deletions src/tests/index.ts

This file was deleted.

8 changes: 8 additions & 0 deletions test.js
@@ -0,0 +1,8 @@
describe("Compiled to CommonJS", function () {
require("./lib/tests/bundle.cjs.js");
});

describe("Compiled to ECMAScript module syntax", function () {
require("reify/node"); // Enable ESM syntax.
require("./lib/tests/bundle.esm.js");
});
3 changes: 2 additions & 1 deletion tsconfig.rollup.json
@@ -1,7 +1,8 @@
{
"extends": "tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2015",
"declaration": false,
"sourceMap": true,
},
}

0 comments on commit 3fb0342

Please sign in to comment.