Skip to content

Commit 7a24b87

Browse files
feat(serverless-runtime-types): provide bundled type files (#369)
* Initial commit to bundle types.d.ts and index.d.ts * Added npm prepare and wrote some commentary in the script * feat(serverless-runtime-types): Cleaning and making executable shell script. * feat: using node script instead of shell. (Windows support) * feat(serverless-runtime-types): refactor
1 parent 15501ea commit 7a24b87

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Diff for: packages/serverless-runtime-types/bundler.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Script to merge all the types files into bundle.d.ts
2+
// bundle.d.ts can be added into Monaco/react editor, until Monaco supports
3+
// importing multiple files.
4+
5+
const fs = require('fs')
6+
7+
const indexFile = fs.readFileSync('index.d.ts', 'utf8');
8+
// remove all import statements from index.d.ts
9+
const indexFileNoImports = indexFile.replace(/import .*?;/gs, '');
10+
const typesFile = fs.readFileSync('types.d.ts', 'utf8');
11+
12+
fs.writeFileSync('bundle.d.ts', typesFile + '\n' + indexFileNoImports.trim());

Diff for: packages/serverless-runtime-types/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"main": "index.js",
66
"types": "index.d.ts",
77
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"build": "node bundler.js",
10+
"prepack": "npm run build"
911
},
1012
"keywords": [
1113
"twilio",
@@ -41,7 +43,8 @@
4143
"README.md",
4244
"index.js",
4345
"index.d.ts",
44-
"types.d.ts"
46+
"types.d.ts",
47+
"bundle.d.ts"
4548
],
4649
"gitHead": "9382ba7f1c23cdf18ac8bb6cada92340d63491dd"
4750
}

0 commit comments

Comments
 (0)