Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ts): expose built files in umd #4844

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sandboxes": ["instantsearchjs-es-template-pcw1k"],
"buildCommand": "build:es"
"buildCommand": "build"
}
3 changes: 2 additions & 1 deletion scripts/typescript/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mainEntryPointFilePath": "<projectFolder>/es/index.d.ts",

"dtsRollup": {
"enabled": false
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/instantsearch.production.d.ts"
},

"apiReport": {
Expand Down
27 changes: 21 additions & 6 deletions scripts/typescript/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ shell.sed(
path.join(__dirname, '../../es/**/*.d.ts')
);

// expose only the es entry point, not the umd entry point
shell.mv(
path.join(__dirname, '../../es/index.es.d.ts'),
path.join(__dirname, '../../es/index.d.ts')
);

console.log();
console.log(`Validating definitions...`);

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

process.exitCode = 1;
}

// move the right entry points
// esm to override umd
shell.mv(
path.join(__dirname, '../../es/index.es.d.ts'),
path.join(__dirname, '../../es/index.d.ts')
);

// production and development umd
shell.cp(
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
path.join(__dirname, '../../dist/instantsearch.production.min.d.ts')
);
shell.cp(
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
path.join(__dirname, '../../dist/instantsearch.development.d.ts')
);
shell.cp(
path.join(__dirname, '../../dist/instantsearch.production.d.ts'),
path.join(__dirname, '../../dist/instantsearch.development.min.d.ts')
Copy link
Contributor

Choose a reason for hiding this comment

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

in which case do people need development.d.ts file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all the files are the same, but typescript works by matching a .d.ts file to a .js file, so if you're importing /dist/development.min.js then the .d.ts is needed for that to work

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining!

);