Skip to content

Commit 8578ae3

Browse files
authoredAug 24, 2021
feat(ts): expose built files in umd (#4844)
* feat(ts): expose built files in umd This can be achieved using the dtsRollup feature of api-extractor, which isn't needed for the es build, as local files work perfectly fine in that case. Make sure to check the generated files when reviewing this PR * change sandbox to allow debugging all types
1 parent 44574bc commit 8578ae3

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed
 

‎.codesandbox/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"sandboxes": ["instantsearchjs-es-template-pcw1k"],
3-
"buildCommand": "build:es"
3+
"buildCommand": "build"
44
}

‎scripts/typescript/api-extractor.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"mainEntryPointFilePath": "<projectFolder>/es/index.d.ts",
77

88
"dtsRollup": {
9-
"enabled": false
9+
"enabled": true,
10+
"untrimmedFilePath": "<projectFolder>/dist/instantsearch.production.d.ts"
1011
},
1112

1213
"apiReport": {

‎scripts/typescript/extract.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ shell.sed(
1919
path.join(__dirname, '../../es/**/*.d.ts')
2020
);
2121

22-
// expose only the es entry point, not the umd entry point
23-
shell.mv(
24-
path.join(__dirname, '../../es/index.es.d.ts'),
25-
path.join(__dirname, '../../es/index.d.ts')
26-
);
27-
2822
console.log();
2923
console.log(`Validating definitions...`);
3024

@@ -47,3 +41,24 @@ if (!result.succeeded) {
4741

4842
process.exitCode = 1;
4943
}
44+
45+
// move the right entry points
46+
// esm to override umd
47+
shell.mv(
48+
path.join(__dirname, '../../es/index.es.d.ts'),
49+
path.join(__dirname, '../../es/index.d.ts')
50+
);
51+
52+
// production and development umd
53+
shell.cp(
54+
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
55+
path.join(__dirname, '../../dist/instantsearch.production.min.d.ts')
56+
);
57+
shell.cp(
58+
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
59+
path.join(__dirname, '../../dist/instantsearch.development.d.ts')
60+
);
61+
shell.cp(
62+
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
63+
path.join(__dirname, '../../dist/instantsearch.development.min.d.ts')
64+
);

0 commit comments

Comments
 (0)
Please sign in to comment.