Skip to content

Commit b9a3055

Browse files
authored
Fix/release build (#294)
* fix command * ignore *.d.ts from eslint * fix clean * Use old babel conf * remove @polkadot/dev
1 parent 46bf43a commit b9a3055

File tree

7 files changed

+172
-1977
lines changed

7 files changed

+172
-1977
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
**/*.spec.*
66
/scripts/*
77
packages/**/build/**
8+
**/*.d.ts

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build
66
node_modules
77
.DS_Store
88
coverage
9-
packages/**/*.d.ts
9+
**/*.d.ts
1010
.vscode
1111
.iml
1212
api_docs

babel.config.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
module.exports = {
2-
extends: '@polkadot/dev/config/babel-config-cjs.cjs',
3-
"plugins": [
4-
["@babel/plugin-proposal-private-methods", { "loose": true }]
2+
presets: [
3+
['@babel/preset-env', {
4+
modules: 'commonjs',
5+
targets: {
6+
browsers: '>0.25% and last 2 versions and not ie 11 and not OperaMini all',
7+
node: '10'
8+
}
9+
}],
10+
'@babel/preset-typescript'
11+
],
12+
plugins: [
13+
['@babel/plugin-proposal-class-properties', { loose: true }],
14+
'@babel/plugin-proposal-numeric-separator',
15+
'@babel/plugin-proposal-object-rest-spread',
16+
'@babel/plugin-proposal-optional-chaining',
17+
'@babel/plugin-transform-runtime',
18+
['@babel/plugin-proposal-private-methods', { loose: true }]
519
]
620
};

package.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
],
1111
"scripts": {
1212
"build": "tsc",
13-
"build:release": "sh scripts/build-release.sh",
14-
"clean": "rm -rf **/build",
13+
"build:release": "yarn clean && sh scripts/build-release.sh",
14+
"clean": "rm -rf build && npx lerna exec -- rm -rf build",
1515
"docs:meta": "node ./scripts/metadataMdWrapper.js",
1616
"docs:src": "rm -rf api_docs && typedoc --plugin typedoc-plugin-markdown --options typedoc.config.js .",
1717
"meta:slim": "node ./scripts/generateSlimMetadataWrapper",
@@ -21,7 +21,15 @@
2121
"test:e2e": "TEST_TYPE=integration jest -c ./jest/integration.config.js --bail --forceExit --detectOpenHandles"
2222
},
2323
"devDependencies": {
24-
"@polkadot/dev": "0.62.7",
24+
"@babel/plugin-proposal-class-properties": "^7.0.0",
25+
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
26+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
27+
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
28+
"@babel/plugin-proposal-private-methods": "^7.0.0",
29+
"@babel/plugin-transform-runtime": "^7.0.0",
30+
"@babel/preset-env": "^7.0.0",
31+
"@babel/preset-typescript": "^7.13.0",
32+
"@babel/core": "^7.0.0-0",
2533
"@types/jest": "^26.0.23",
2634
"@typescript-eslint/eslint-plugin": "^4.22.1",
2735
"@typescript-eslint/parser": "^4.22.1",

packages/util/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "utils for cennznet sdk",
55
"author": "Centrality Developers <[email protected]>",
66
"keywords": [
7-
"CENNZNet"
7+
"CENNZnet"
88
],
99
"homepage": "https://github.com/cennznet/api.js/tree/master/packages/util",
1010
"license": "Apache-2.0",

scripts/build-release.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ set -e
33
BUILD_DIR="build"
44
rm -rf $BUILD_DIR
55
printf '\n\nChecking TS definitions..\n\n'
6-
# this is just for type checking we don't publish the output files.
7-
# babel will produce the real *.d.ts file within each package/build dir.
6+
# generate typescript definitions
87
tsc --outDir $BUILD_DIR
98

109
for d in $(pwd)/packages/* ; do
11-
printf "\n\nBuilding $d...\n\n"
12-
npx babel -f babel.config.js --ignore='**/*.d.ts' --extensions='.ts' --out-file-extension='.js' --copy-files -d "$d/build" "$d/src"
10+
PACKAGE=$(basename $d)
11+
printf "\n\nBuilding @cennznet/$PACKAGE...\n\n"
12+
npx babel -f babel.config.js --ignore='**/*.d.ts,**/*.e2e.ts,**/*.spec.ts' --extensions='.ts' -d "$d/build" "$d/src"
13+
# copy in *d.ts definitions. ignore tests
14+
rsync \
15+
--exclude '**/*.e2e.d.ts' \
16+
--exclude '**/*.spec.d.ts' \
17+
-av "$BUILD_DIR/packages/$PACKAGE/src/" "$d/build/"
1318
# copy in essential files for publishing to npm
1419
cp LICENSE $d/build/LICENSE
1520
ls $d

0 commit comments

Comments
 (0)