Skip to content

Commit

Permalink
enable ESM (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
huan authored Oct 27, 2021
1 parent fb0ba26 commit f300ab5
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 147 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Place your settings in this file to overwrite default and user settings.
{
"typescript.tsdk": "node_modules/typescript/lib"
,
"window.zoomLevel": 1, "editor.minimap.enabled": true
, "files.exclude": {
"typescript.tsdk": "node_modules/typescript/lib",
"window.zoomLevel": 0,
"editor.minimap.enabled": true,
"files.exclude": {
"node_modules/": true
, "dist": true
},
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ P.S. running E2E test is based on *brolog demo project*: [git repository](https:

## CHANGELOG

### main v1.14 (Oct 27, 2021)

1. ES Module support
1. export `Loggable` interface

### v1.12 (Jun 18, 2020)

1. Update to use Chatie DevOps toolsets.
Expand Down
2 changes: 1 addition & 1 deletion examples/npm-like-logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Brolog } = require('brolog')
import { Brolog } from 'brolog'

const log = new Brolog()

Expand Down
66 changes: 35 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
{
"name": "brolog",
"version": "1.12.4",
"version": "1.14.0",
"description": "Npmlog like logger for Browser",
"main": "bundles/brolog.umd.js",
"typings": "dist/brolog.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/esm/src/mod.js",
"require": "./dist/cjs/src/mod.js"
}
},
"typings": "./dist/esm/src/mod.d.ts",
"engines": {
"node": ">=16",
"npm": ">=7"
},
"scripts": {
"clean": "rm -fr dist/* bundles/*",
"dist": "npm run clean && npm run build && npm run rollup && npm run dist:es6to5",
"dist:es6to5": "tsc --out ./bundles/brolog.umd.js --target es5 --allowJs bundles/brolog.es6.umd.js --lib es6,dom",
"build": "tsc --module es6",
"lint": "npm run lint:es && npm run lint:ts",
"rollup": "rollup -c",
"lint:ts": "tsc --noEmit",
"test": "npm run lint && npm run dist && npm run test:unit && npm run test:e2e",
"build": "tsc && tsc -p tsconfig.cjs.json",
"clean": "shx rm -fr dist/*",
"dist": "npm-run-all clean build dist:commonjs",
"dist:commonjs": "jq -n \"{ type: \\\"commonjs\\\" }\" > dist/cjs/package.json",
"lint": "npm-run-all lint:es lint:ts",
"lint:ts": "tsc --isolatedModules --noEmit",
"test": "npm-run-all lint dist test:unit test:e2e",
"test:e2e": "bash -x tests/protractor.sh",
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"test:unit": "tap -R tap \"src/**/*.spec.ts\"",
"test:unit": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" tap -R tap \"src/**/*.spec.ts\"",
"lint:es": "eslint --ignore-pattern tests/fixtures/ '{bin,examples,scripts,src,tests}/**/*.ts'"
},
"repository": {
Expand All @@ -38,33 +47,28 @@
"homepage": "https://github.com/huan/brolog#readme",
"dependencies": {},
"devDependencies": {
"@chatie/eslint-config": "^0.12.1",
"@chatie/eslint-config": "^1.0.2",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.10.1",
"@chatie/tsconfig": "^1.0.2",
"@types/chokidar": "^2.1.3",
"@types/jasmine": "^3.5.10",
"@types/puppeteer": "^5.4.1",
"@types/rollup-plugin-json": "^3.0.0",
"chokidar": "^3.4.0",
"jasmine-spec-reporter": "^5.0.2",
"magic-string": "^0.25.0",
"pkg-jq": "^0.2.4",
"@types/jasmine": "^3.10.1",
"@types/puppeteer": "^5.4.4",
"@types/rollup-plugin-json": "^3.0.3",
"chokidar": "^3.5.2",
"jasmine-spec-reporter": "^7.0.0",
"magic-string": "^0.25.7",
"pkg-jq": "^0.2.11",
"protractor": "^7.0.0",
"puppeteer": "^5.1.0",
"rollup": "^2.13.1",
"puppeteer": "^10.4.0",
"rollup": "^2.58.3",
"rollup-plugin-json": "^4.0.0",
"source-map": "^0.7.2",
"tap": "^14.10.7",
"source-map": "^0.7.3",
"tap": "^15.0.10",
"tslint": "^6.1.2",
"tstest": "^0.4.10"
"tstest": "^1.0.1"
},
"files": [
"package.json",
"README.md",
"CHANGELOG.md",
"LICENSE",
"bundles/",
"src/",
"dist/"
],
Expand Down
37 changes: 35 additions & 2 deletions scripts/npm-pack-testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,48 @@ mv *-*.*.*.tgz "$TMPDIR"
cp tests/fixtures/smoke-testing.ts "$TMPDIR"

cd $TMPDIR

npm init -y
npm install *-*.*.*.tgz \
typescript
@types/node \
typescript \

#
# CommonJS
#
./node_modules/.bin/tsc \
--esModuleInterop \
--lib esnext \
--noEmitOnError \
--noImplicitAny \
--skipLibCheck \
--target es5 \
--module CommonJS \
--moduleResolution node \
smoke-testing.ts

echo
echo "CommonJS: pack testing..."
node smoke-testing.js

#
# ES Modules
#

# https://stackoverflow.com/a/59203952/1123955
echo "`jq '.type="module"' package.json`" > package.json

./node_modules/.bin/tsc \
--lib esnext,dom \
--esModuleInterop \
--lib esnext \
--noEmitOnError \
--noImplicitAny \
--skipLibCheck \
--target es2020 \
--module es2020 \
--moduleResolution node \
smoke-testing.ts

echo
echo "ES Module: pack testing..."
node smoke-testing.js
Loading

0 comments on commit f300ab5

Please sign in to comment.