Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Upgrade primary build target to ES2017, add browser build #28

Merged
merged 3 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Common test coverage configuration for `EthereumJS` libraries.

Tool: [nyc](https://istanbul.js.org/)

Supported Version: `^11.7.0`

Exposed CLI command:

- `ethereumjs-config-coverage`
Expand Down
4 changes: 1 addition & 3 deletions packages/format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Common formatting configuration for `EthereumJS` libraries.

Tool: [Prettier](https://prettier.io/)

Supported Version: `^1.15.3`

Exposed CLI commands:

- `ethereumjs-config-format`
Expand All @@ -16,7 +14,7 @@ Exposed CLI commands:
Add `prettier.config.js`:

```javascript
module.exports = require('@ethereumjs/config-format')
module.exports = require('@ethereumjs/config-format');
```

Add `.prettierignore`:
Expand Down
31 changes: 22 additions & 9 deletions packages/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Common `TypeScript` configuration for `EthereumJS` libraries.

Tool: [TypeScript](https://www.typescriptlang.org/)

Supported Version: `^3.2.2`

Exposed CLI commands:

- `ethereumjs-config-ts-compile`
Expand All @@ -17,7 +15,7 @@ Add `tsconfig.json`:

```json
{
"extends": "@ethereumjs/config-typescript",
"extends": "@ethereumjs/config-typescript/tsconfig.json",
"include": ["src/**/*.ts", "test/**/*.ts"]
}
```
Expand All @@ -26,15 +24,21 @@ Add `tsconfig.prod.json`:

```json
{
"extends": "@ethereumjs/config-typescript",
"compilerOptions": {
"outDir": "./dist"
},
"extends": "@ethereumjs/config-typescript/tsconfig.prod.json",
"include": ["src/**/*.ts"]
}
```

Use CLI commands above in `package.json`:
Add `tsconfig.browser.json`:

```json
{
"extends": "@ethereumjs/config-typescript/tsconfig.browser.json",
"include": ["src/**/*.ts"]
}
```

Use CLI commands above in your `package.json`:

```json
"scripts": {
Expand All @@ -43,5 +47,14 @@ Use CLI commands above in `package.json`:
}
```

The default production target is ES2017. To support shipping the ES5 target for browsers, add to your `package.json`:


```json
"main": "dist/index.js",
"types": "dist/index.d.ts",
"browser": "dist.browser/index.js",
"files": [
"dist",
"dist.browser"
]
```
2 changes: 1 addition & 1 deletion packages/typescript/cli/ts-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
set -o xtrace
exec tsc -p ./tsconfig.prod.json
tsc -p ./tsconfig.prod.json && test -f ./tsconfig.browser.json && tsc -p ./tsconfig.browser.json
Copy link
Contributor

@evertonfraga evertonfraga May 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the execs there. Reference: #13 (review)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea to silently fail when there's no browser config? If so, 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: exec I was having issues with it, I will dig deeper for its purpose, thanks for the link

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the exec is right, as it means "replace the bash process with this other one". So the script will stop after tsc executes, even if it's successful. For example, this never prints Hi:

exec true
echo "Hi"

What I'd do is set -e at the beginning of the script. That makes the bash process fail if any of the commands fail.

2 changes: 1 addition & 1 deletion packages/typescript/cli/ts-compile.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
set -o xtrace
exec tsc --noEmit
tsc -p ./tsconfig.json
ryanio marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"author": "Krzysztof Kaczor <chris@kaczor.io>",
"files": [
"tsconfig.json",
"tsconfig.prod.json",
"tsconfig.browser.json",
"cli"
],
"bin": {
Expand Down
8 changes: 8 additions & 0 deletions packages/typescript/tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist.browser",
"target": "es5",
"lib": ["dom", "es5"]
}
}
4 changes: 2 additions & 2 deletions packages/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"resolveJsonModule": true,
"downlevelIteration": true,
"strict": true,
"target": "es5",
"target": "ES2017",
"lib": ["es2018"]
}
}
}
6 changes: 6 additions & 0 deletions packages/typescript/tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
}
}